Implement POSIX.1e ACL functions

* Makefile.in (DLL_OFILES): Add sec_posixacl.o.
	(SUBLIBS): Add libacl.a
	(libacl.a): New rule to create libacl.a.
	* common.din: Export POSIX ACL functions as well as most libacl.a
	extensions.
	* fhandler.h (fhander_base::acl_get): New prototype.
	(fhander_base::acl_set): Ditto.
	(fhandler_disk_file::acl_get): Ditto.
	(fhandler_disk_file::acl_set): Ditto.
	* include/acl/libacl.h: New file.
	* include/cygwin/version.h: Bump API minor version.
	* include/sys/acl.h: Drop including cygwin/acl.h.  Accommodate
	throughout Cygwin.  Add POSIX ACL definitions.
	* sec_acl.cc: Include sec_posixacl.h.  Replace ILLEGAL_UID and
	ILLEGAL_GID with ACL_UNDEFINED_ID where sensible.
	(__aclcheck): New internal acl check function to be used for
	Solaris and POSIX ACLs.
	(aclcheck32): Call __aclcheck.
	(__aclcalcmask): New function to compute ACL_MASK value.
	(__aclsort): New internal acl sort function to be used for Solaris
	and POSIX ACLs.
	(aclsort32): Call __aclsort.
	(permtostr): Work directly on provided buffer.
	(__acltotext): New internal acltotext function to be used for
	Solaris and POSIX ACLs.
	(acltotext32): Call __acltotext.
	(__aclfromtext): New internal aclfromtext function to be used for
	Solaris and POSIX ACLs.
	(aclfromtext32): Call __aclfromtext.
	* sec_posixacl.cc: New file implemeting POSIX ACL functions.
	* sec_posixacl.h: New internal header.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2016-01-06 18:41:36 +01:00
parent edd7d93484
commit 9ddf063921
18 changed files with 1849 additions and 300 deletions

View File

@@ -0,0 +1,55 @@
/* acl/libacl.h: Non-POSIX extensions of libacl
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#ifndef _ACL_LIBACL_H
#define _ACL_LIBACL_H
#include <sys/acl.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Sync'd with cygwin/acl.h values. */
#define ACL_MULTI_ERROR (0x4)
#define ACL_DUPLICATE_ERROR (0x5)
#define ACL_ENTRY_ERROR (0x6)
#define ACL_MISS_ERROR (0x7)
/* acl_to_any_text options. */
#define TEXT_ABBREVIATE (0x01)
#define TEXT_NUMERIC_IDS (0x02)
#define TEXT_SOME_EFFECTIVE (0x04)
#define TEXT_ALL_EFFECTIVE (0x08)
#define TEXT_SMART_INDENT (0x10)
extern int acl_check (acl_t __acl, int *__last);
extern int acl_cmp (acl_t __acl1, acl_t __acl2);
extern int acl_entries (acl_t __acl);
extern int acl_equiv_mode (acl_t __acl, mode_t *__mode_p);
extern const char *acl_error (int __code);
extern int acl_extended_fd (int __fd);
extern int acl_extended_file (const char *__path_p);
extern int acl_extended_file_nofollow (const char *__path_p);
extern acl_t acl_from_mode (mode_t __mode);
extern int acl_get_perm (acl_permset_t __permset_d, acl_perm_t __perm);
extern char *acl_to_any_text (acl_t __acl, const char *__prefix,
char __separator, int __options);
#if 0
/* TODO */
struct error_context;
extern int perm_copy_file (const char *, const char *, struct error_context *);
extern int perm_copy_fd (const char *, int, const char *, int,
struct error_context *);
#endif
#ifdef __cplusplus
}
#endif
#endif /* _ACL_LIBACL_H */

View File

@@ -476,13 +476,14 @@ details. */
292: Export rpmatch.
293: Convert utmpname/utmpxname to int.
294: Export clog10, clog10f.
295: Export POSIX ACL functions.
*/
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull,
sigaltstack, sethostname. */
#define CYGWIN_VERSION_API_MAJOR 0
#define CYGWIN_VERSION_API_MINOR 294
#define CYGWIN_VERSION_API_MINOR 295
/* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible

View File

@@ -12,6 +12,89 @@ details. */
#ifndef _SYS_ACL_H
#define _SYS_ACL_H
#include <cygwin/acl.h>
#include <_ansi.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef __cplusplus
extern "C" {
#endif
/* POSIX ACL types and functions. The implementation is based on the
internal original Solaris implementation as defined in cygwin/acl.h.
However, we don't include cygwin/acl.h from here to avoid poisoning
the namespace. */
/* acl_perm_t constants */
#define ACL_READ (0x4)
#define ACL_WRITE (0x2)
#define ACL_EXECUTE (0x1)
/* acl_tag_t constants, in sync with values from cygwin/acl.h */
#define ACL_UNDEFINED_TAG (0x0000)
#define ACL_USER_OBJ (0x0001)
#define ACL_USER (0x0002)
#define ACL_GROUP_OBJ (0x0004)
#define ACL_GROUP (0x0008)
#define ACL_MASK (0x0010)
#define ACL_OTHER (0x0020)
/* acl_type_t constants */
#define ACL_TYPE_ACCESS (0x0)
#define ACL_TYPE_DEFAULT (0x1)
/* qualifier constant */
#define ACL_UNDEFINED_ID ((id_t) -1)
/* entry_id constants */
#define ACL_FIRST_ENTRY (0x0)
#define ACL_NEXT_ENTRY (0x1)
/* types */
typedef uint32_t acl_perm_t, acl_type_t, acl_tag_t;
typedef uint64_t acl_permset_t;
typedef uint64_t acl_entry_t;
struct __acl_t;
typedef struct __acl_t *acl_t;
extern int acl_add_perm (acl_permset_t __permset_d, acl_perm_t __perm);
extern int acl_calc_mask (acl_t *__acl_p);
extern int acl_clear_perms (acl_permset_t __permset_d);
extern int acl_copy_entry (acl_entry_t __dest_d, acl_entry_t __src_d);
extern ssize_t acl_copy_ext (void *__buf_p, acl_t __acl, ssize_t __size);
extern acl_t acl_copy_int (const void *__buf_p);
extern int acl_create_entry (acl_t *__acl_p, acl_entry_t *__entry_p);
extern int acl_delete_def_file (const char *__path_p);
extern int acl_delete_entry (acl_t __acl, acl_entry_t __entry_d);
extern int acl_delete_perm (acl_permset_t __permset_d, acl_perm_t __perm);
extern acl_t acl_dup (acl_t __acl);
extern int acl_free (void *__obj_p);
extern acl_t acl_from_text (const char *__buf_p);
extern int acl_get_entry (acl_t __acl, int __entry_id,
acl_entry_t *__entry_p);
extern acl_t acl_get_fd (int __fd);
extern acl_t acl_get_file (const char *__path_p, acl_type_t __type);
extern int acl_get_permset (acl_entry_t __entry_d,
acl_permset_t *__permset_p);
extern void *acl_get_qualifier (acl_entry_t __entry_d);
extern int acl_get_tag_type (acl_entry_t __entry_d,
acl_tag_t *__tag_type_p);
extern acl_t acl_init (int __count);
extern int acl_set_fd (int __fd, acl_t __acl);
extern int acl_set_file (const char *__path_p, acl_type_t __type,
acl_t __acl);
extern int acl_set_permset (acl_entry_t __entry_d,
acl_permset_t __permset_d);
extern int acl_set_qualifier (acl_entry_t __entry_d,
const void *__tag_qualifier_p);
extern int acl_set_tag_type (acl_entry_t __entry_d, acl_tag_t __tag_type);
extern ssize_t acl_size (acl_t __acl);
extern char *acl_to_text (acl_t __acl, ssize_t *__len_p);
extern int acl_valid (acl_t __acl);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_ACL_H */