diff options
author | Christopher Faylor <me@cgf.cx> | 2003-03-21 15:15:19 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2003-03-21 15:15:19 +0000 |
commit | bb0cde10009e9f2b42b47c73538ac18652d0a630 (patch) | |
tree | 85b1466eecdeb19e4d7190c9ab9acd303ca7a45b | |
parent | 72ba2bac4d1bf89ca9ab7d523867ccde8870150b (diff) | |
download | newlib-bb0cde10009e9f2b42b47c73538ac18652d0a630.zip newlib-bb0cde10009e9f2b42b47c73538ac18652d0a630.tar.gz newlib-bb0cde10009e9f2b42b47c73538ac18652d0a630.tar.bz2 |
merge from trunk
-rw-r--r-- | winsup/cygwin/ChangeLog | 39 | ||||
-rw-r--r-- | winsup/cygwin/dcrt0.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/exceptions.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_socket.cc | 9 | ||||
-rw-r--r-- | winsup/cygwin/glob.c | 17 | ||||
-rw-r--r-- | winsup/cygwin/include/cygwin/version.h | 4 | ||||
-rw-r--r-- | winsup/cygwin/security.cc | 25 | ||||
-rw-r--r-- | winsup/cygwin/sigproc.h | 2 | ||||
-rw-r--r-- | winsup/cygwin/syscalls.cc | 22 |
10 files changed, 86 insertions, 40 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 8126535..f2b5123 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,42 @@ +2003-03-20 Corinna Vinschen <corinna@vinschen.de> + + * fhandler_socket.cc (fhandler_socket::sendto): Restrict EPIPE and + SIGPIPE handling to connection oriented sockets. Add comment. + +2003-03-19 Christopher Faylor <cgf@redhat.com> + + * sigproc.h (signal_fixup_after_exec): Eliminate argument in declaration. + * exceptions.cc (signal_fixup_after_exec): Eliminate argument in + definition. Don't reset signal handlers after spawm. Just treat like + fork/exec. + * dcrt0.cc (dll_crt0_1): Don't pass PROC_SPAWN argument to + signal_fixup_after_exec. + * syscalls.cc (unlink): Don't change attributes of file if not readonly/system. + Ditto for resetting of arguments. + +2003-03-19 Corinna Vinschen <corinna@vinschen.de> + + * glob.c: Eliminate __INSIDE_CYGWIN__ preprocessor conditionals + throughout. + +2003-03-19 Corinna Vinschen <corinna@vinschen.de> + + * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Fix + wrong usage of S_IFDIR. + * security.cc (get_attribute_from_acl): Ditto. + (get_file_attribute): Fix wrong usage of S_IFLNK. + (get_object_attribute): Ditto. + (alloc_sd): Fix wrong usage of S_IFDIR. + * syscalls.cc (chmod): Allow chmod'ing of socket files. + +2003-03-19 Corinna Vinschen <corinna@vinschen.de> + + * include/cygwin/version.h (CYGWIN_VERSION_CHECK_FOR_USING_BIG_TYPES): + Define. + * glob.c (g_lstat): Use CYGWIN_VERSION_CHECK_FOR_USING_BIG_TYPES + instead of numerical constants. + (g_stat): Ditto. + 2003-03-18 Thomas Pfaff <tpfaff@gmx.net> * pthread.cc (pthread_attr_init): Remove diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 8407a3b..430b74e 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -611,7 +611,7 @@ dll_crt0_1 () envp = spawn_info->moreinfo->envp; envc = spawn_info->moreinfo->envc; cygheap->fdtab.fixup_after_exec (spawn_info->parent); - signal_fixup_after_exec (child_proc_info->type == PROC_SPAWN); + signal_fixup_after_exec (); CloseHandle (spawn_info->parent); if (spawn_info->moreinfo->old_title) { diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index e2df0c9..5acbe55 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -735,13 +735,13 @@ signal_fixup_after_fork () } void __stdcall -signal_fixup_after_exec (bool isspawn) +signal_fixup_after_exec () { /* Set up child's signal handlers */ for (int i = 0; i < NSIG; i++) { myself->getsig (i).sa_mask = 0; - if (myself->getsig (i).sa_handler != SIG_IGN || isspawn) + if (myself->getsig (i).sa_handler != SIG_IGN) myself->getsig (i).sa_handler = SIG_DFL; } } diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 667f160..9390a31 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -311,7 +311,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf, buf->st_mode |= STD_WBITS; /* | S_IWGRP | S_IWOTH; we don't give write to group etc */ - if (buf->st_mode & S_IFDIR) + if (S_ISDIR (buf->st_mode)) buf->st_mode |= S_IFDIR | STD_XBITS; else if (buf->st_mode & S_IFMT) /* nothing */; diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index a79259d..077d0be 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -1033,8 +1033,13 @@ fhandler_socket::sendto (const void *ptr, size_t len, int flags, else res = ret; - /* Special handling for SIGPIPE */ - if (res == -1 && get_errno () == ESHUTDOWN) + /* Special handling for EPIPE and SIGPIPE. + + EPIPE is generated if the local end has been shut down on a connection + oriented socket. In this case the process will also receive a SIGPIPE + unless MSG_NOSIGNAL is set. */ + if (res == -1 && get_errno () == ESHUTDOWN + && get_socket_type () == SOCK_STREAM) { set_errno (EPIPE); if (! (flags & MSG_NOSIGNAL)) diff --git a/winsup/cygwin/glob.c b/winsup/cygwin/glob.c index c74a781..1db8685 100644 --- a/winsup/cygwin/glob.c +++ b/winsup/cygwin/glob.c @@ -81,6 +81,7 @@ #include <windows.h> #include "perprocess.h" +#include "cygwin/version.h" #ifdef __weak_alias #ifdef __LIBC12_SOURCE__ @@ -96,11 +97,7 @@ __weak_alias(__globfree13,___globfree13); #ifdef __LIBC12_SOURCE__ #define STAT stat12 #else -#if defined (__INSIDE_CYGWIN__) #define STAT __stat64 -#else -#define STAT stat -#endif #endif #define DOLLAR '$' @@ -840,17 +837,13 @@ g_lstat(fn, sb, pglob) struct __stat32 lsb; int ret; - if (user_data->api_major > 0 || user_data->api_minor > 78) + if (CYGWIN_VERSION_CHECK_FOR_USING_BIG_TYPES) ret = (*pglob->gl_lstat)(buf, &sb); else if (!(ret = (*pglob->gl_lstat)(buf, &lsb))) stat32_to_STAT (&lsb, sb); return ret; } -#ifdef __INSIDE_CYGWIN__ return(lstat64(buf, sb)); -#else - return(lstat(buf, sb)); -#endif } static int @@ -866,17 +859,13 @@ g_stat(fn, sb, pglob) struct __stat32 lsb; int ret; - if (user_data->api_major > 0 || user_data->api_minor > 78) + if (CYGWIN_VERSION_CHECK_FOR_USING_BIG_TYPES) ret = (*pglob->gl_stat)(buf, &sb); if (!(ret = (*pglob->gl_stat)(buf, &lsb))) stat32_to_STAT (&lsb, sb); return ret; } -#ifdef __INSIDE_CYGWIN__ return(stat64(buf, sb)); -#else - return(stat(buf, sb)); -#endif } static Char * diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 60cfd10..6ca9100 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -84,6 +84,10 @@ details. */ #define CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK \ (CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) <= \ 28) + +#define CYGWIN_VERSION_CHECK_FOR_USING_BIG_TYPES \ + (CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) >= \ + 79) /* We used to use the DLL major/minor to track non-backward-compatible interface changes to the API. Now we use an API major/minor number for this purpose. */ diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc index 5d0e51b..0295eeb 100644 --- a/winsup/cygwin/security.cc +++ b/winsup/cygwin/security.cc @@ -1267,7 +1267,7 @@ get_attribute_from_acl (mode_t *attribute, PACL acl, PSID owner_sid, *flags |= ((!(*anti & S_IXOTH)) ? S_IXOTH : 0) | ((!(*anti & S_IXGRP)) ? S_IXGRP : 0) | ((!(*anti & S_IXUSR)) ? S_IXUSR : 0); - if ((*attribute & S_IFDIR) && + if ((S_ISDIR (*attribute)) && (ace->Mask & (FILE_WRITE_DATA | FILE_EXECUTE | FILE_DELETE_CHILD)) == (FILE_WRITE_DATA | FILE_EXECUTE)) *flags |= S_ISVTX; @@ -1404,7 +1404,7 @@ get_file_attribute (int use_ntsec, const char *file, if (gidret) *gidret = ILLEGAL_GID; } - else if (attribute && (*attribute & S_IFLNK) == S_IFLNK) + else if (attribute && S_ISLNK (*attribute)) *attribute |= S_IRWXU | S_IRWXG | S_IRWXO; return 0; } @@ -1427,7 +1427,7 @@ get_file_attribute (int use_ntsec, const char *file, res = 0; /* symlinks are everything for everyone! */ - if ((*attribute & S_IFLNK) == S_IFLNK) + if (S_ISLNK (*attribute)) *attribute |= S_IRWXU | S_IRWXG | S_IRWXO; return res > 0 ? 0 : -1; @@ -1498,7 +1498,7 @@ get_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type, { int res = get_nt_object_attribute (handle, object_type, attribute, uidret, gidret); - if (attribute && (*attribute & S_IFLNK) == S_IFLNK) + if (attribute && S_ISLNK (*attribute)) *attribute |= S_IRWXU | S_IRWXG | S_IRWXO; return res; } @@ -1512,7 +1512,7 @@ get_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type, return 0; /* symlinks are everything for everyone! */ - if ((*attribute & S_IFLNK) == S_IFLNK) + if (S_ISLNK (*attribute)) *attribute |= S_IRWXU | S_IRWXG | S_IRWXO; return 0; @@ -1652,8 +1652,8 @@ alloc_sd (__uid32_t uid, __gid32_t gid, int attribute, owner_allow |= FILE_GENERIC_WRITE; if (attribute & S_IXUSR) owner_allow |= FILE_GENERIC_EXECUTE; - if ((attribute & (S_IFDIR | S_IWUSR | S_IXUSR)) - == (S_IFDIR | S_IWUSR | S_IXUSR)) + if (S_ISDIR (attribute) + && (attribute & (S_IWUSR | S_IXUSR)) == (S_IWUSR | S_IXUSR)) owner_allow |= FILE_DELETE_CHILD; /* Construct allow attribute for group. */ @@ -1665,8 +1665,9 @@ alloc_sd (__uid32_t uid, __gid32_t gid, int attribute, group_allow |= STANDARD_RIGHTS_WRITE | FILE_GENERIC_WRITE; if (attribute & S_IXGRP) group_allow |= FILE_GENERIC_EXECUTE; - if ((attribute & (S_IFDIR | S_IWGRP | S_IXGRP)) - == (S_IFDIR | S_IWGRP | S_IXGRP) && !(attribute & S_ISVTX)) + if (S_ISDIR (attribute) + && (attribute & (S_IWGRP | S_IXGRP)) == (S_IWGRP | S_IXGRP) + && !(attribute & S_ISVTX)) group_allow |= FILE_DELETE_CHILD; /* Construct allow attribute for everyone. */ @@ -1678,8 +1679,8 @@ alloc_sd (__uid32_t uid, __gid32_t gid, int attribute, other_allow |= STANDARD_RIGHTS_WRITE | FILE_GENERIC_WRITE; if (attribute & S_IXOTH) other_allow |= FILE_GENERIC_EXECUTE; - if ((attribute & (S_IFDIR | S_IWOTH | S_IXOTH)) - == (S_IFDIR | S_IWOTH | S_IXOTH) + if (S_ISDIR (attribute) + && (attribute & (S_IWOTH | S_IXOTH)) == (S_IWOTH | S_IXOTH) && !(attribute & S_ISVTX)) other_allow |= FILE_DELETE_CHILD; @@ -1788,7 +1789,7 @@ alloc_sd (__uid32_t uid, __gid32_t gid, int attribute, } /* Construct appropriate inherit attribute for new directories */ - if (attribute & S_IFDIR && !acl_exists ) + if (S_ISDIR (attribute) && !acl_exists ) { const DWORD inherit = SUB_CONTAINERS_AND_OBJECTS_INHERIT | INHERIT_ONLY; diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h index c8c208e..cda8cad 100644 --- a/winsup/cygwin/sigproc.h +++ b/winsup/cygwin/sigproc.h @@ -118,7 +118,7 @@ BOOL __stdcall pid_exists (pid_t) __attribute__ ((regparm(1))); int __stdcall sig_send (_pinfo *, int, DWORD ebp = (DWORD) __builtin_frame_address (0), bool exception = 0) __attribute__ ((regparm(3))); void __stdcall signal_fixup_after_fork (); -void __stdcall signal_fixup_after_exec (bool); +void __stdcall signal_fixup_after_exec (); void __stdcall wait_for_sigthread (); extern char myself_nowait_dummy[]; diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index c733566..d40c237 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -152,8 +152,15 @@ unlink (const char *ourname) goto done; } - /* Allow us to delete even if read-only */ - SetFileAttributes (win32_name, (DWORD) win32_name & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)); + bool setattrs; + if (!((DWORD) win32_name & (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM))) + setattrs = false; + else + { + /* Allow us to delete even if read-only */ + SetFileAttributes (win32_name, (DWORD) win32_name & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)); + setattrs = true; + } /* Attempt to use "delete on close" semantics to handle removing a file which may be open. */ HANDLE h; @@ -161,12 +168,12 @@ unlink (const char *ourname) OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, 0); if (h != INVALID_HANDLE_VALUE) { - (void) SetFileAttributes (win32_name, (DWORD) win32_name); + if (wincap.has_hard_links () && setattrs) + (void) SetFileAttributes (win32_name, (DWORD) win32_name); BOOL res = CloseHandle (h); syscall_printf ("%d = CloseHandle (%p)", res, h); - if (!win32_name.isremote () - || (GetFileAttributes (win32_name) == INVALID_FILE_ATTRIBUTES - || wincap.has_delete_on_close ())) + if (GetFileAttributes (win32_name) == INVALID_FILE_ATTRIBUTES + || !win32_name.isremote ()) { syscall_printf ("CreateFile (FILE_FLAG_DELETE_ON_CLOSE) succeeded"); goto ok; @@ -174,7 +181,8 @@ unlink (const char *ourname) else { syscall_printf ("CreateFile (FILE_FLAG_DELETE_ON_CLOSE) failed"); - SetFileAttributes (win32_name, (DWORD) win32_name & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)); + if (setattrs) + SetFileAttributes (win32_name, (DWORD) win32_name & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)); } } |