From 90016a0e4b5b04fead9d05161620d298f6d0136f Mon Sep 17 00:00:00 2001 From: scottc Date: Mon, 26 Aug 2002 11:38:13 +0000 Subject: Merged changes from HEAD --- winsup/cygwin/ChangeLog | 49 +++++++ winsup/cygwin/Makefile.in | 19 ++- winsup/cygwin/cygrun.c | 64 ++++++++++ winsup/cygwin/fhandler.h | 4 +- winsup/cygwin/fhandler_socket.cc | 4 +- winsup/cygwin/include/sys/socket.h | 11 +- winsup/cygwin/net.cc | 32 ++--- winsup/cygwin/sec_acl.cc | 12 +- winsup/cygwin/security.cc | 255 +++++++++++++------------------------ winsup/cygwin/shared.cc | 2 +- 10 files changed, 251 insertions(+), 201 deletions(-) create mode 100644 winsup/cygwin/cygrun.c diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index b43e746cc9d..0384c00aae2 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,52 @@ +2002-08-25 Conrad Scott + + * fhandler.h (fhandler_socket::recvfrom): Fix prototype. + (fhandler_socket::sendto): Ditto. + * fhandler_socket.cc (fhandler_socket::recvfrom): Ditto. + (fhandler_socket::sendto): Ditto. + * include/sys/socket.h (recv): Fix prototype. + (recvfrom): Ditto. + (send): Ditto. + (sendto): Ditto. + * net.cc (cygwin_sendto): Ditto. Improve strace message + (cygwin_recvfrom): Ditto. Ditto. + (cygwin_setsockopt): Improve strace message. + (cygwin_getsockopt): Ditto. + (cygwin_connect): Ditto. + (cygwin_accept): Ditto. + (cygwin_bind): Ditto. + (cygwin_getsockname): Ditto. + (cygwin_getpeername): Ditto. + (cygwin_recv): Fix prototype. + (cygwin_send): Ditto. + (cygwin_recvmsg): Improve strace message. + (cygwin_sendmsg): Ditto. + +2002-08-25 Pierre Humblet + + * sec_acl.cc (getacl): Check ace_sid == well_known_world_sid + before owner_sid and group_sid so that well_known_world_sid + means "other" even when owner_sid and/or group_sid are Everyone. + * security.cc (get_attribute_from_acl): Created from code common + to get_nt_attribute() and get_nt_object_attribute(), with same + reordering as in getacl() above. + (get_nt_attribute): Call get_attribute_from_acl(). + (get_nt_object_attribute): Ditto. + +2002-08-26 Christopher Faylor + + * Makefile.in (cygcheck.exe): Make a -mno-cygwin program. + * cygrun.c (main): Export CYGWIN=ntsec unless otherwise set. + + * shared.cc (shared_name): Only add build date to shared name when + *testing*. + +2002-08-24 Christopher Faylor + + * Makefile.in (DLL_IMPORTS): Move libuuid.a and libshell32.a to list + rather than referring to them via -l. Add DLL imports last in link + line for new-cygwin.dll and cygrun.exe. + 2002-08-19 Christopher Faylor * pinfo.h (pinfo::remember): Arrange for destructor call if diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in index 2c0e34124f4..2bba7a71d37 100644 --- a/winsup/cygwin/Makefile.in +++ b/winsup/cygwin/Makefile.in @@ -115,7 +115,7 @@ EXTRA_OFILES=$(bupdir1)/libiberty/random.o $(bupdir1)/libiberty/strsignal.o MALLOC_OFILES=@MALLOC_OFILES@ -DLL_IMPORTS:=$(w32api_lib)/libkernel32.a +DLL_IMPORTS:=$(w32api_lib)/libuuid.a $(w32api_lib)/libshell32.a $(w32api_lib)/libkernel32.a # Please maintain this list in sorted order, with maximum files per 80 col line @@ -159,7 +159,7 @@ EXTRALIBS:=libautomode.a libbinmode.a libtextmode.a INSTOBJS:=automode.o binmode.o textmode.o TARGET_LIBS:=$(LIB_NAME) $(SUBLIBS) $(GMON_START) $(LIBGMON_A) $(SUBLIBS) $(INSTOBJS) $(EXTRALIBS) .PHONY: all force dll_ofiles install all_target install_target all_host install_host \ - install install-libs install-headers + install install-libs install-headers -lgcc .SUFFIXES: .SUFFIXES: .c .cc .def .a .o .d @@ -259,8 +259,8 @@ maintainer-clean realclean: clean new-$(DLL_NAME): $(LDSCRIPT) $(DLL_OFILES) $(DEF_FILE) $(DLL_IMPORTS) $(LIBC) $(LIBM) $(API_VER) Makefile winver_stamp $(CXX) $(CXXFLAGS) -nostdlib -Wl,-T$(firstword $^) -Wl,--out-implib,cygdll.a -shared -o $@ \ -e $(DLL_ENTRY) $(DEF_FILE) $(DLL_OFILES) version.o winver.o \ - $(DLL_IMPORTS) $(MALLOC_OBJ) $(LIBM) $(LIBC) \ - -lstdc++ -lgcc -lshell32 -luuid + $(MALLOC_OBJ) $(LIBM) $(LIBC) \ + -lstdc++ -lgcc $(DLL_IMPORTS) # Rule to build libcygwin.a $(LIB_NAME): rmsym newsym new-$(DLL_NAME) $(LIBCOS) @@ -275,6 +275,7 @@ new-$(LIB_NAME): $(LIB_NAME) $(DLLTOOL) --as=$(AS) --dllname new-$(DLL_NAME) --def $(DEF_FILE) --output-lib new-templib.a $(AR) rcv new-templib.a $(LIBCOS) mv new-templib.a new-$(LIB_NAME) + $(RANLIB) $@ dll_ofiles: $(DLL_OFILES) @@ -319,9 +320,12 @@ winver_stamp: mkvers.sh include/cygwin/version.h winver.rc $(DLL_OFILES) malloc.o: malloc.cc $(COMPILE_CXX) -fomit-frame-pointer -o $@ $< -cygrun.exe : cygrun.o $(LIB_NAME) $(w32api_lib)/libuser32.a \ +cygrun.o: cygrun.c + $(CC) $(MINGW_CFLAGS) -o $@ -c $< + +cygrun.exe : cygrun.o -lgcc $(w32api_lib)/libuser32.a \ $(w32api_lib)/libshell32.a $(w32api_lib)/libkernel32.a - $(CC) -nodefaultlibs -o $@ $^ -lgcc -lcygwin + $(CC) -mno-cygwin -o $@ $^ cygserver_transport_outside.o: cygserver_transport.cc $(COMPILE_CXX) -D__OUTSIDE_CYGWIN__ -o $@ $< @@ -344,6 +348,9 @@ cygserver.exe: cygserver.o cygserver_shm.o cygserver_transport_outside.o cygserv # $(CXX) $(MINGW_CXXFLAGS) -o $@ ${wordlist 1,3,$^} -B$(mingw_build)/ $(MINGW_LDFLAGS) #endif +-lgcc: + : + # Makefile: cygwin.din diff --git a/winsup/cygwin/cygrun.c b/winsup/cygwin/cygrun.c new file mode 100644 index 00000000000..94b0c399f5e --- /dev/null +++ b/winsup/cygwin/cygrun.c @@ -0,0 +1,64 @@ +/* cygrun.c: testsuite support program + + Copyright 1999, 2000, 2001, 2002 Red Hat, Inc. + +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. */ + +/* This program is intended to be used only by the testsuite. It runs + programs without using the cygwin api, so that the just-built dll + can be tested without interference from the currently installed + dll. */ + +#include +#include +#include + +int +main (int argc, char **argv) +{ + STARTUPINFO sa; + PROCESS_INFORMATION pi; + DWORD ec = 1; + char *p; + + if (argc < 2) + { + fprintf (stderr, "Usage: cygrun [program]\n"); + exit (0); + } + + SetEnvironmentVariable ("CYGWIN_TESTING", "1"); + if ((p = getenv ("CYGWIN")) == NULL || (strstr (p, "ntsec") == NULL)) + { + char buf[4096]; + if (!p) + p[0] = '\0'; + else + { + strcat (buf, p); + strcat (buf, " "); + } + strcat(buf, "ntsec"); + SetEnvironmentVariable ("CYGWIN", buf); + } + + memset (&sa, 0, sizeof (sa)); + memset (&pi, 0, sizeof (pi)); + if (!CreateProcess (0, argv[1], 0, 0, 1, 0, 0, 0, &sa, &pi)) + { + fprintf (stderr, "CreateProcess %s failed\n", argv[1]); + exit (1); + } + + WaitForSingleObject (pi.hProcess, INFINITE); + + GetExitCodeProcess (pi.hProcess, &ec); + + CloseHandle (pi.hProcess); + CloseHandle (pi.hThread); + return ec; +} diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 6f9a5cbe5b5..ec72091e364 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -398,12 +398,12 @@ class fhandler_socket: public fhandler_base int getpeername (struct sockaddr *name, int *namelen); int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3))); - int recvfrom (void *ptr, size_t len, unsigned int flags, + int recvfrom (void *ptr, size_t len, int flags, struct sockaddr *from, int *fromlen); int recvmsg (struct msghdr *msg, int flags); int write (const void *ptr, size_t len); - int sendto (const void *ptr, size_t len, unsigned int flags, + int sendto (const void *ptr, size_t len, int flags, const struct sockaddr *to, int tolen); int sendmsg (const struct msghdr *msg, int flags); diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index c938773185b..ded5935a1a1 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -675,7 +675,7 @@ fhandler_socket::read (void *ptr, size_t len) } int -fhandler_socket::recvfrom (void *ptr, size_t len, unsigned int flags, +fhandler_socket::recvfrom (void *ptr, size_t len, int flags, struct sockaddr *from, int *fromlen) { int res = -1; @@ -763,7 +763,7 @@ fhandler_socket::write (const void *ptr, size_t len) } int -fhandler_socket::sendto (const void *ptr, size_t len, unsigned int flags, +fhandler_socket::sendto (const void *ptr, size_t len, int flags, const struct sockaddr *to, int tolen) { int res = -1; diff --git a/winsup/cygwin/include/sys/socket.h b/winsup/cygwin/include/sys/socket.h index 51ed54e54eb..3bda9f9bf46 100644 --- a/winsup/cygwin/include/sys/socket.h +++ b/winsup/cygwin/include/sys/socket.h @@ -32,13 +32,14 @@ extern "C" int getpeername (int, struct sockaddr *__peer, int *); int getsockname (int, struct sockaddr *__addr, int *); int listen (int, int __n); - int recv (int, void *__buff, int __len, unsigned int __flags); - int recvfrom (int, char *__buff, int __len, int __flags, - struct sockaddr *__from, int *__fromlen); + int recv (int, void *__buff, int __len, int __flags); + int recvfrom (int, void *__buff, int __len, int __flags, + struct sockaddr *__from, int *__fromlen); int recvmsg(int s, struct msghdr *msg, int flags); - int send (int, const void *__buff, int __len, unsigned int __flags); + int send (int, const void *__buff, int __len, int __flags); int sendmsg(int s, const struct msghdr *msg, int flags); - int sendto (int, const void *, int, unsigned int, const struct sockaddr *, int); + int sendto (int, const void *, int __len, int __flags, + const struct sockaddr *__to, int __tolen); int setsockopt (int __s, int __level, int __optname, const void *optval, int __optlen); int getsockopt (int __s, int __level, int __optname, void *__optval, int *__optlen); int shutdown (int, int); diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 00fea193c9d..888c34eccd8 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -564,7 +564,7 @@ done: /* exported as sendto: standards? */ extern "C" int -cygwin_sendto (int fd, const void *buf, int len, unsigned int flags, +cygwin_sendto (int fd, const void *buf, int len, int flags, const struct sockaddr *to, int tolen) { int res; @@ -577,15 +577,16 @@ cygwin_sendto (int fd, const void *buf, int len, unsigned int flags, else if ((res = len) != 0) res = fh->sendto (buf, len, flags, to, tolen); - syscall_printf ("%d = sendto (%d, %x, %x, %x)", res, fd, buf, len, flags); + syscall_printf ("%d = sendto (%d, %p, %d, %x, %p, %d)", + res, fd, buf, len, flags, to, tolen); return res; } /* exported as recvfrom: standards? */ extern "C" int -cygwin_recvfrom (int fd, void *buf, int len, int flags, struct sockaddr *from, - int *fromlen) +cygwin_recvfrom (int fd, void *buf, int len, int flags, + struct sockaddr *from, int *fromlen) { int res; fhandler_socket *fh = get (fd); @@ -599,7 +600,8 @@ cygwin_recvfrom (int fd, void *buf, int len, int flags, struct sockaddr *from, else if ((res = len) != 0) res = fh->recvfrom (buf, len, flags, from, fromlen); - syscall_printf ("%d = recvfrom (%d, %x, %x, %x)", res, fd, buf, len, flags); + syscall_printf ("%d = recvfrom (%d, %p, %d, %x, %p, %p)", + res, fd, buf, len, flags, from, fromlen); return res; } @@ -662,7 +664,7 @@ cygwin_setsockopt (int fd, int level, int optname, const void *optval, set_winsock_errno (); } - syscall_printf ("%d = setsockopt (%d, %d, %x (%s), %x, %d)", + syscall_printf ("%d = setsockopt (%d, %d, %x (%s), %p, %d)", res, fd, level, optname, name, optval, optlen); return res; } @@ -730,7 +732,7 @@ cygwin_getsockopt (int fd, int level, int optname, void *optval, int *optlen) set_winsock_errno (); } - syscall_printf ("%d = getsockopt (%d, %d, %x (%s), %x, %d)", + syscall_printf ("%d = getsockopt (%d, %d, %x (%s), %p, %p)", res, fd, level, optname, name, optval, optlen); return res; } @@ -747,7 +749,7 @@ cygwin_connect (int fd, const struct sockaddr *name, int namelen) else res = fh->connect (name, namelen); - syscall_printf ("%d = connect (%d, %x, %x)", res, fd, name, namelen); + syscall_printf ("%d = connect (%d, %p, %d)", res, fd, name, namelen); return res; } @@ -1009,7 +1011,7 @@ cygwin_accept (int fd, struct sockaddr *peer, int *len) else res = fh->accept (peer, len); - syscall_printf ("%d = accept (%d, %x, %x)", res, fd, peer, len); + syscall_printf ("%d = accept (%d, %p, %d)", res, fd, peer, len); return res; } @@ -1025,7 +1027,7 @@ cygwin_bind (int fd, const struct sockaddr *my_addr, int addrlen) else res = fh->bind (my_addr, addrlen); - syscall_printf ("%d = bind (%d, %x, %d)", res, fd, my_addr, addrlen); + syscall_printf ("%d = bind (%d, %p, %d)", res, fd, my_addr, addrlen); return res; } @@ -1043,7 +1045,7 @@ cygwin_getsockname (int fd, struct sockaddr *addr, int *namelen) else res = fh->getsockname (addr, namelen); - syscall_printf ("%d = getsockname (%d, %x, %d)", res, fd, addr, namelen); + syscall_printf ("%d = getsockname (%d, %p, %d)", res, fd, addr, namelen); return res; } @@ -1146,14 +1148,14 @@ cygwin_getpeername (int fd, struct sockaddr *name, int *len) /* exported as recv: standards? */ extern "C" int -cygwin_recv (int fd, void *buf, int len, unsigned int flags) +cygwin_recv (int fd, void *buf, int len, int flags) { return cygwin_recvfrom (fd, buf, len, flags, NULL, NULL); } /* exported as send: standards? */ extern "C" int -cygwin_send (int fd, const void *buf, int len, unsigned int flags) +cygwin_send (int fd, const void *buf, int len, int flags) { return cygwin_sendto (fd, buf, len, flags, NULL, 0); } @@ -2096,7 +2098,7 @@ cygwin_recvmsg (int fd, struct msghdr *msg, int flags) else res = fh->recvmsg (msg, flags); - syscall_printf ("%d = recvmsg (%d, %x, %x)", res, fd, msg, flags); + syscall_printf ("%d = recvmsg (%d, %p, %d)", res, fd, msg, flags); return res; } @@ -2116,6 +2118,6 @@ cygwin_sendmsg (int fd, const struct msghdr *msg, int flags) else res = fh->sendmsg (msg, flags); - syscall_printf ("%d = recvmsg (%d, %x, %x)", res, fd, msg, flags); + syscall_printf ("%d = recvmsg (%d, %p, %d)", res, fd, msg, flags); return res; } diff --git a/winsup/cygwin/sec_acl.cc b/winsup/cygwin/sec_acl.cc index 26ab878c1a4..cd20cfd54f3 100644 --- a/winsup/cygwin/sec_acl.cc +++ b/winsup/cygwin/sec_acl.cc @@ -314,7 +314,12 @@ getacl (const char *file, DWORD attr, int nentries, __aclent16_t *aclbufp) int id; int type = 0; - if (ace_sid == owner_sid) + if (ace_sid == well_known_world_sid) + { + type = OTHER_OBJ; + id = 0; + } + else if (ace_sid == owner_sid) { type = USER_OBJ; id = uid; @@ -324,11 +329,6 @@ getacl (const char *file, DWORD attr, int nentries, __aclent16_t *aclbufp) type = GROUP_OBJ; id = gid; } - else if (ace_sid == well_known_world_sid) - { - type = OTHER_OBJ; - id = 0; - } else { id = ace_sid.get_id (FALSE, &type); diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc index f22c7dc8f0a..43841c1f541 100644 --- a/winsup/cygwin/security.cc +++ b/winsup/cygwin/security.cc @@ -1202,6 +1202,95 @@ write_sd (const char *file, PSECURITY_DESCRIPTOR sd_buf, DWORD sd_size) return 0; } +static void +get_attribute_from_acl(int * attribute, PACL acl, PSID owner_sid, + PSID group_sid, BOOL grp_member) +{ + ACCESS_ALLOWED_ACE *ace; + int allow = 0; + int deny = 0; + int *flags, *anti; + + for (DWORD i = 0; i < acl->AceCount; ++i) + { + if (!GetAce (acl, i, (PVOID *) &ace)) + continue; + if (ace->Header.AceFlags & INHERIT_ONLY) + continue; + switch (ace->Header.AceType) + { + case ACCESS_ALLOWED_ACE_TYPE: + flags = &allow; + anti = &deny; + break; + case ACCESS_DENIED_ACE_TYPE: + flags = &deny; + anti = &allow; + break; + default: + continue; + } + + cygsid ace_sid ((PSID) &ace->SidStart); + if (ace_sid == well_known_world_sid) + { + if (ace->Mask & FILE_READ_DATA) + *flags |= S_IROTH + | ((!(*anti & S_IRGRP)) ? S_IRGRP : 0) + | ((!(*anti & S_IRUSR)) ? S_IRUSR : 0); + if (ace->Mask & FILE_WRITE_DATA) + *flags |= S_IWOTH + | ((!(*anti & S_IWGRP)) ? S_IWGRP : 0) + | ((!(*anti & S_IWUSR)) ? S_IWUSR : 0); + if (ace->Mask & FILE_EXECUTE) + { + *flags |= S_IXOTH + | ((!(*anti & S_IXGRP)) ? S_IXGRP : 0) + | ((!(*anti & S_IXUSR)) ? S_IXUSR : 0); + } + if ((*attribute & S_IFDIR) && + (ace->Mask & (FILE_WRITE_DATA | FILE_EXECUTE | FILE_DELETE_CHILD)) + == (FILE_WRITE_DATA | FILE_EXECUTE)) + *flags |= S_ISVTX; + } + else if (ace_sid == well_known_null_sid) + { + /* Read SUID, SGID and VTX bits from NULL ACE. */ + if (ace->Mask & FILE_READ_DATA) + *flags |= S_ISVTX; + if (ace->Mask & FILE_WRITE_DATA) + *flags |= S_ISGID; + if (ace->Mask & FILE_APPEND_DATA) + *flags |= S_ISUID; + } + else if (owner_sid && ace_sid == owner_sid) + { + if (ace->Mask & FILE_READ_DATA) + *flags |= S_IRUSR; + if (ace->Mask & FILE_WRITE_DATA) + *flags |= S_IWUSR; + if (ace->Mask & FILE_EXECUTE) + *flags |= S_IXUSR; + } + else if (group_sid && ace_sid == group_sid) + { + if (ace->Mask & FILE_READ_DATA) + *flags |= S_IRGRP + | ((grp_member && !(*anti & S_IRUSR)) ? S_IRUSR : 0); + if (ace->Mask & FILE_WRITE_DATA) + *flags |= S_IWGRP + | ((grp_member && !(*anti & S_IWUSR)) ? S_IWUSR : 0); + if (ace->Mask & FILE_EXECUTE) + *flags |= S_IXGRP + | ((grp_member && !(*anti & S_IXUSR)) ? S_IXUSR : 0); + } + } + *attribute &= ~(S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX | S_ISGID | S_ISUID); + *attribute |= allow; + *attribute &= ~deny; + return; +} + static int get_nt_attribute (const char *file, int *attribute, __uid32_t *uidret, __gid32_t *gidret) @@ -1264,89 +1353,8 @@ get_nt_attribute (const char *file, int *attribute, file, *attribute, uid, gid); return 0; } + get_attribute_from_acl (attribute, acl, owner_sid, group_sid, grp_member); - ACCESS_ALLOWED_ACE *ace; - int allow = 0; - int deny = 0; - int *flags, *anti; - - for (DWORD i = 0; i < acl->AceCount; ++i) - { - if (!GetAce (acl, i, (PVOID *) &ace)) - continue; - if (ace->Header.AceFlags & INHERIT_ONLY) - continue; - switch (ace->Header.AceType) - { - case ACCESS_ALLOWED_ACE_TYPE: - flags = &allow; - anti = &deny; - break; - case ACCESS_DENIED_ACE_TYPE: - flags = &deny; - anti = &allow; - break; - default: - continue; - } - - cygsid ace_sid ((PSID) &ace->SidStart); - if (owner_sid && ace_sid == owner_sid) - { - if (ace->Mask & FILE_READ_DATA) - *flags |= S_IRUSR; - if (ace->Mask & FILE_WRITE_DATA) - *flags |= S_IWUSR; - if (ace->Mask & FILE_EXECUTE) - *flags |= S_IXUSR; - } - else if (group_sid && ace_sid == group_sid) - { - if (ace->Mask & FILE_READ_DATA) - *flags |= S_IRGRP - | ((grp_member && !(*anti & S_IRUSR)) ? S_IRUSR : 0); - if (ace->Mask & FILE_WRITE_DATA) - *flags |= S_IWGRP - | ((grp_member && !(*anti & S_IWUSR)) ? S_IWUSR : 0); - if (ace->Mask & FILE_EXECUTE) - *flags |= S_IXGRP - | ((grp_member && !(*anti & S_IXUSR)) ? S_IXUSR : 0); - } - else if (ace_sid == well_known_world_sid) - { - if (ace->Mask & FILE_READ_DATA) - *flags |= S_IROTH - | ((!(*anti & S_IRGRP)) ? S_IRGRP : 0) - | ((!(*anti & S_IRUSR)) ? S_IRUSR : 0); - if (ace->Mask & FILE_WRITE_DATA) - *flags |= S_IWOTH - | ((!(*anti & S_IWGRP)) ? S_IWGRP : 0) - | ((!(*anti & S_IWUSR)) ? S_IWUSR : 0); - if (ace->Mask & FILE_EXECUTE) - { - *flags |= S_IXOTH - | ((!(*anti & S_IXGRP)) ? S_IXGRP : 0) - | ((!(*anti & S_IXUSR)) ? S_IXUSR : 0); - } - if ((*attribute & S_IFDIR) && - (ace->Mask & (FILE_WRITE_DATA | FILE_EXECUTE | FILE_DELETE_CHILD)) - == (FILE_WRITE_DATA | FILE_EXECUTE)) - *flags |= S_ISVTX; - } - else if (ace_sid == well_known_null_sid) - { - /* Read SUID, SGID and VTX bits from NULL ACE. */ - if (ace->Mask & FILE_READ_DATA) - *flags |= S_ISVTX; - if (ace->Mask & FILE_WRITE_DATA) - *flags |= S_ISGID; - if (ace->Mask & FILE_APPEND_DATA) - *flags |= S_ISUID; - } - } - *attribute &= ~(S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX | S_ISGID | S_ISUID); - *attribute |= allow; - *attribute &= ~deny; syscall_printf ("file: %s %x, uid %d, gid %d", file, *attribute, uid, gid); return 0; } @@ -1437,88 +1445,7 @@ get_nt_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type, return 0; } - ACCESS_ALLOWED_ACE *ace; - int allow = 0; - int deny = 0; - int *flags, *anti; - - for (DWORD i = 0; i < acl->AceCount; ++i) - { - if (!GetAce (acl, i, (PVOID *) & ace)) - continue; - if (ace->Header.AceFlags & INHERIT_ONLY) - continue; - switch (ace->Header.AceType) - { - case ACCESS_ALLOWED_ACE_TYPE: - flags = &allow; - anti = &deny; - break; - case ACCESS_DENIED_ACE_TYPE: - flags = &deny; - anti = &allow; - break; - default: - continue; - } - - cygsid ace_sid ((PSID) & ace->SidStart); - if (owner_sid && ace_sid == owner_sid) - { - if (ace->Mask & FILE_READ_DATA) - *flags |= S_IRUSR; - if (ace->Mask & FILE_WRITE_DATA) - *flags |= S_IWUSR; - if (ace->Mask & FILE_EXECUTE) - *flags |= S_IXUSR; - } - else if (group_sid && ace_sid == group_sid) - { - if (ace->Mask & FILE_READ_DATA) - *flags |= S_IRGRP - | ((grp_member && !(*anti & S_IRUSR)) ? S_IRUSR : 0); - if (ace->Mask & FILE_WRITE_DATA) - *flags |= S_IWGRP - | ((grp_member && !(*anti & S_IWUSR)) ? S_IWUSR : 0); - if (ace->Mask & FILE_EXECUTE) - *flags |= S_IXGRP - | ((grp_member && !(*anti & S_IXUSR)) ? S_IXUSR : 0); - } - else if (ace_sid == well_known_world_sid) - { - if (ace->Mask & FILE_READ_DATA) - *flags |= S_IROTH - | ((!(*anti & S_IRGRP)) ? S_IRGRP : 0) - | ((!(*anti & S_IRUSR)) ? S_IRUSR : 0); - if (ace->Mask & FILE_WRITE_DATA) - *flags |= S_IWOTH - | ((!(*anti & S_IWGRP)) ? S_IWGRP : 0) - | ((!(*anti & S_IWUSR)) ? S_IWUSR : 0); - if (ace->Mask & FILE_EXECUTE) - { - *flags |= S_IXOTH - | ((!(*anti & S_IXGRP)) ? S_IXGRP : 0) - | ((!(*anti & S_IXUSR)) ? S_IXUSR : 0); - } - if ((*attribute & S_IFDIR) && - (ace->Mask & (FILE_WRITE_DATA | FILE_EXECUTE | FILE_DELETE_CHILD)) - == (FILE_WRITE_DATA | FILE_EXECUTE)) - *flags |= S_ISVTX; - } - else if (ace_sid == well_known_null_sid) - { - /* Read SUID, SGID and VTX bits from NULL ACE. */ - if (ace->Mask & FILE_READ_DATA) - *flags |= S_ISVTX; - if (ace->Mask & FILE_WRITE_DATA) - *flags |= S_ISGID; - if (ace->Mask & FILE_APPEND_DATA) - *flags |= S_ISUID; - } - } - *attribute &= ~(S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX | S_ISGID | S_ISUID); - *attribute |= allow; - *attribute &= ~deny; + get_attribute_from_acl (attribute, acl, owner_sid, group_sid, grp_member); LocalFree (psd); diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index 7585d63647d..b6d15f3b34c 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -38,7 +38,7 @@ shared_name (const char *str, int num) extern bool _cygwin_testing; __small_sprintf (buf, "%s.%s.%d", cygwin_version.shared_id, str, num); - if (!_cygwin_testing) + if (_cygwin_testing) strcat (buf, cygwin_version.dll_build_date); return buf; } -- cgit v1.2.1