diff options
| author | Eli Zaretskii | 2012-12-17 21:14:34 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2012-12-17 21:14:34 +0200 |
| commit | 66447e07c1aa037730127d6fcdd2658f87f13dc0 (patch) | |
| tree | 0547cb5e75ae1ffeb51d7b3f80275e0a65f70720 /src/fileio.c | |
| parent | 207a7ef0531ca92468e19115a2c2064c9b22bfd4 (diff) | |
| download | emacs-66447e07c1aa037730127d6fcdd2658f87f13dc0.tar.gz emacs-66447e07c1aa037730127d6fcdd2658f87f13dc0.zip | |
Support Posix ACL APIs on MS-Windows.
src/w32.c: Include sddl.h and sys/acl.h.
(SDDL_REVISION_1): Define if not already defined.
(g_b_init_get_security_descriptor_dacl)
(g_b_init_convert_sd_to_sddl, g_b_init_convert_sddl_to_sd)
(g_b_init_is_valid_security_descriptor)
(g_b_init_set_file_security): New static flags.
(globals_of_w32): Initialize them to zero.
(SetFileSecurity_Name): New string constant.
(SetFileSecurity_Proc, GetSecurityDescriptorDacl_Proc)
(ConvertStringSecurityDescriptorToSecurityDescriptor_Proc)
(ConvertSecurityDescriptorToStringSecurityDescriptor_Proc)
(IsValidSecurityDescriptor_Proc): New typedefs.
(get_file_security, get_security_descriptor_owner)
(get_security_descriptor_group): Set errno to ENOTSUP.
(set_file_security, get_security_descriptor_dacl)
(is_valid_security_descriptor, convert_sd_to_sddl)
(convert_sddl_to_sd, acl_valid, acl_to_text, acl_from_text)
(acl_free, acl_get_file, acl_set_file): New functions.
src/fileio.c (Fcopy_file) [WINDOWSNT]: Support copying ACLs.
nt/inc/sys/acl.h: New file.
nt/inc/ms-w32.h (ENOTSUP): Define if undefined.
nt/config.nt (HAVE_POSIX_ACL): Define.
doc/lispref/files.texi (File Attributes, Changing Files): Update to include
MS-Windows support for ACLs.
Diffstat (limited to 'src/fileio.c')
| -rw-r--r-- | src/fileio.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/fileio.c b/src/fileio.c index f1cfe0eb625..26150a7e55b 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -1956,6 +1956,14 @@ entries (depending on how Emacs was built). */) | |||
| 1956 | out_st.st_mode = 0; | 1956 | out_st.st_mode = 0; |
| 1957 | 1957 | ||
| 1958 | #ifdef WINDOWSNT | 1958 | #ifdef WINDOWSNT |
| 1959 | if (!NILP (preserve_extended_attributes)) | ||
| 1960 | { | ||
| 1961 | #ifdef HAVE_POSIX_ACL | ||
| 1962 | acl = acl_get_file (SDATA (encoded_file), ACL_TYPE_ACCESS); | ||
| 1963 | if (acl == NULL && errno != ENOTSUP) | ||
| 1964 | report_file_error ("Getting ACL", Fcons (file, Qnil)); | ||
| 1965 | #endif | ||
| 1966 | } | ||
| 1959 | if (!CopyFile (SDATA (encoded_file), | 1967 | if (!CopyFile (SDATA (encoded_file), |
| 1960 | SDATA (encoded_newname), | 1968 | SDATA (encoded_newname), |
| 1961 | FALSE)) | 1969 | FALSE)) |
| @@ -1983,6 +1991,17 @@ entries (depending on how Emacs was built). */) | |||
| 1983 | /* Restore original attributes. */ | 1991 | /* Restore original attributes. */ |
| 1984 | SetFileAttributes (filename, attributes); | 1992 | SetFileAttributes (filename, attributes); |
| 1985 | } | 1993 | } |
| 1994 | #ifdef HAVE_POSIX_ACL | ||
| 1995 | if (acl != NULL) | ||
| 1996 | { | ||
| 1997 | bool fail = | ||
| 1998 | acl_set_file (SDATA (encoded_newname), ACL_TYPE_ACCESS, acl) != 0; | ||
| 1999 | if (fail && errno != ENOTSUP) | ||
| 2000 | report_file_error ("Setting ACL", Fcons (newname, Qnil)); | ||
| 2001 | |||
| 2002 | acl_free (acl); | ||
| 2003 | } | ||
| 2004 | #endif | ||
| 1986 | #else /* not WINDOWSNT */ | 2005 | #else /* not WINDOWSNT */ |
| 1987 | immediate_quit = 1; | 2006 | immediate_quit = 1; |
| 1988 | ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0); | 2007 | ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0); |