diff options
author | scottc <scottc> | 2002-06-25 10:50:36 +0000 |
---|---|---|
committer | scottc <scottc> | 2002-06-25 10:50:36 +0000 |
commit | 20a9a636fcb9ce2638e71763cc027a564c75a568 (patch) | |
tree | 116b261fce84bc9039d1df8521239e22e20c8408 | |
parent | cbaed72614ebad606872753d0aee3cf2f686b104 (diff) | |
download | gdb-20a9a636fcb9ce2638e71763cc027a564c75a568.tar.gz |
Merged changes from HEAD
-rw-r--r-- | winsup/cygwin/ChangeLog | 31 | ||||
-rw-r--r-- | winsup/cygwin/dtable.cc | 40 | ||||
-rw-r--r-- | winsup/cygwin/security.cc | 12 | ||||
-rw-r--r-- | winsup/cygwin/security.h | 4 | ||||
-rw-r--r-- | winsup/cygwin/syscalls.cc | 10 | ||||
-rw-r--r-- | winsup/cygwin/uinfo.cc | 12 |
6 files changed, 71 insertions, 38 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 1bb877de41f..eac8abe4891 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,34 @@ +2002-06-25 Corinna Vinschen <corinna@vinschen.de> + + * syscalls.cc (chown): Convert uid to 32 bit. + (lchown): Ditto. + (fchown): Ditto. + +2002-06-24 Christopher Faylor <cgf@redhat.com> + + * dtable.cc (dtable::find_unused_handle): Avoid coercion. + +2002-06-24 Christopher Faylor <cgf@redhat.com> + + * dtable.cc (fhandler_base::dup2): Cleanup. Ensure that lock is turned + off in error condition. + +2002-06-24 Corinna Vinschen <corinna@vinschen.de> + + * uinfo.cc (internal_getlogin): Set myself->uid and myself->gid instead + of user.real_uid and user.real_gid. + (uinfo_init): Evaluate orig_uid and real_uid from myself->uid. Ditto + for gid. + +2002-06-23 Pierre Humblet <pierre.humblet@ieee.org> + + * security.cc (get_group_sidlist): Add pw argument and use pw->pw_name + in call to get_supplementary_group_sidlist. + (create_token): Add pw argument and use it in call to + get_group_sidlist. + * security.h: Add pw argument in declaration of create_token. + * syscalls.cc (seteuid32): Add pw argument in call to create_token. + 2002-06-24 Conrad Scott <conrad.scott@dsl.pipex.com> * cygserver_client (client_request::make_request): Replace my diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index b94e9cf385b..bc7a86ee0cd 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -167,10 +167,9 @@ int dtable::find_unused_handle (int start) { AssertResourceOwner (LOCK_FD_LIST, READ_LOCK); - do { - for (int i = start; i < (int) size; i++) + for (size_t i = start; i < size; i++) /* See if open -- no need for overhead of not_open */ if (fds[i] == NULL) return i; @@ -433,6 +432,7 @@ dtable::dup2 (int oldfd, int newfd) MALLOC_CHECK; debug_printf ("dup2 (%d, %d)", oldfd, newfd); + SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup"); if (not_open (oldfd)) { @@ -441,6 +441,13 @@ dtable::dup2 (int oldfd, int newfd) goto done; } + if (newfd < 0) + { + syscall_printf ("new fd out of bounds: %d", newfd); + set_errno (EBADF); + goto done; + } + if (newfd == oldfd) { res = 0; @@ -453,35 +460,28 @@ dtable::dup2 (int oldfd, int newfd) goto done; } - debug_printf ("newfh->io_handle %p, oldfh->io_handle %p", newfh->get_io_handle (), fds[oldfd]->get_io_handle ()); - SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup"); + debug_printf ("newfh->io_handle %p, oldfh->io_handle %p", + newfh->get_io_handle (), fds[oldfd]->get_io_handle ()); - if (newfd < 0) + if (!not_open (newfd)) + _close (newfd); + else if ((size_t) newfd < size) + /* nothing to do */; + else if (find_unused_handle (newfd) < 0) { - syscall_printf ("new fd out of bounds: %d", newfd); - set_errno (EBADF); + newfh->close (); + res = -1; goto done; } - if ((size_t) newfd >= size) - { - int inc_size = NOFILE_INCR * ((newfd + NOFILE_INCR - 1) / NOFILE_INCR) - - size; - extend (inc_size); - } - - if (!not_open (newfd)) - _close (newfd); fds[newfd] = newfh; - ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup"); - MALLOC_CHECK; - if ((res = newfd) <= 2) set_std_handle (res); - MALLOC_CHECK; done: + MALLOC_CHECK; + ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup"); syscall_printf ("%d = dup2 (%d, %d)", res, oldfd, newfd); return res; diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc index 60b5378f35b..74c4a173b6e 100644 --- a/winsup/cygwin/security.cc +++ b/winsup/cygwin/security.cc @@ -482,7 +482,7 @@ get_supplementary_group_sidlist (const char *username, cygsidlist &grp_list) static BOOL get_group_sidlist (cygsidlist &grp_list, - cygsid &usersid, cygsid &pgrpsid, + cygsid &usersid, cygsid &pgrpsid, struct passwd * pw, PTOKEN_GROUPS my_grps, LUID auth_luid, int &auth_pos, BOOL * special_pgrp) { @@ -554,7 +554,7 @@ get_group_sidlist (cygsidlist &grp_list, get_user_primary_group (wserver, user, usersid, pgrpsid); } else * special_pgrp = TRUE; - if (get_supplementary_group_sidlist (user, sup_list)) + if (pw->pw_name && get_supplementary_group_sidlist (pw->pw_name, sup_list)) { for (int i = 0; i < sup_list.count; ++i) if (!grp_list.contains (sup_list.sids[i])) @@ -734,7 +734,7 @@ verify_token (HANDLE token, cygsid &usersid, cygsid &pgrpsid, BOOL * pintern) } HANDLE -create_token (cygsid &usersid, cygsid &pgrpsid) +create_token (cygsid &usersid, cygsid &pgrpsid, struct passwd * pw) { NTSTATUS ret; LSA_HANDLE lsa = INVALID_HANDLE_VALUE; @@ -818,7 +818,7 @@ create_token (cygsid &usersid, cygsid &pgrpsid) /* Create list of groups, the user is member in. */ int auth_pos; - if (!get_group_sidlist (grpsids, usersid, pgrpsid, + if (!get_group_sidlist (grpsids, usersid, pgrpsid, pw, my_grps, auth_luid, auth_pos, &special_pgrp)) goto out; @@ -1379,13 +1379,13 @@ alloc_sd (__uid32_t uid, __gid32_t gid, int attribute, /* Otherwise retrieve user data from /etc/passwd */ struct passwd *pw = getpwuid32 (uid); if (!pw) - { + { debug_printf ("no /etc/passwd entry for %d", uid); set_errno (EINVAL); return NULL; } else if (!owner_sid.getfrompw (pw)) - { + { debug_printf ("no SID for user %d", uid); set_errno (EINVAL); return NULL; diff --git a/winsup/cygwin/security.h b/winsup/cygwin/security.h index af4b667f8a2..88aa5fdac94 100644 --- a/winsup/cygwin/security.h +++ b/winsup/cygwin/security.h @@ -180,7 +180,7 @@ void set_security_attribute (int attribute, PSECURITY_ATTRIBUTES psa, /* Try a subauthentication. */ HANDLE subauth (struct passwd *pw); /* Try creating a token directly. */ -HANDLE create_token (cygsid &usersid, cygsid &pgrpsid); +HANDLE create_token (cygsid &usersid, cygsid &pgrpsid, struct passwd * pw); /* Verify an existing token */ BOOL verify_token (HANDLE token, cygsid &usersid, cygsid &pgrpsid, BOOL * pintern = NULL); @@ -206,7 +206,7 @@ extern BOOL sec_acl (PACL acl, BOOL admins, PSID sid1 = NO_SID, PSID sid2 = NO_S int __stdcall NTReadEA (const char *file, const char *attrname, char *buf, int len); BOOL __stdcall NTWriteEA (const char *file, const char *attrname, const char *buf, int len); PSECURITY_DESCRIPTOR alloc_sd (__uid32_t uid, __gid32_t gid, int attribute, - PSECURITY_DESCRIPTOR sd_ret, DWORD *sd_size_ret); + PSECURITY_DESCRIPTOR sd_ret, DWORD *sd_size_ret); extern inline SECURITY_ATTRIBUTES * sec_user_nih (char sa_buf[], PSID sid = NULL) diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index a788c604bef..54c238e48ad 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -832,7 +832,8 @@ extern "C" int chown (const char * name, __uid16_t uid, __gid16_t gid) { sigframe thisframe (mainthread); - return chown_worker (name, PC_SYM_FOLLOW, uid, gid16togid32 (gid)); + return chown_worker (name, PC_SYM_FOLLOW, + uid16touid32 (uid), gid16togid32 (gid)); } extern "C" int @@ -846,7 +847,8 @@ extern "C" int lchown (const char * name, __uid16_t uid, __gid16_t gid) { sigframe thisframe (mainthread); - return chown_worker (name, PC_SYM_NOFOLLOW, uid, gid16togid32 (gid)); + return chown_worker (name, PC_SYM_NOFOLLOW, + uid16touid32 (uid), gid16togid32 (gid)); } extern "C" int @@ -877,7 +879,7 @@ fchown32 (int fd, __uid32_t uid, __gid32_t gid) extern "C" int fchown (int fd, __uid16_t uid, __gid16_t gid) { - return fchown32 (fd, uid, gid16togid32 (gid)); + return fchown32 (fd, uid16touid32 (uid), gid16togid32 (gid)); } /* umask: POSIX 5.3.3.1 */ @@ -2043,7 +2045,7 @@ seteuid32 (__uid32_t uid) { /* If no impersonation token is available, try to authenticate using NtCreateToken() or subauthentication. */ - cygheap->user.token = create_token (usersid, pgrpsid); + cygheap->user.token = create_token (usersid, pgrpsid, pw_new); if (cygheap->user.token != INVALID_HANDLE_VALUE) explicitly_created_token = TRUE; else diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index fe9e30db7b6..e1e9077299c 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -88,13 +88,13 @@ internal_getlogin (cygheap_user &user) if (pw) { - user.real_uid = pw->pw_uid; - user.real_gid = pw->pw_gid; + myself->uid = pw->pw_uid; + myself->gid = pw->pw_gid; } else { - user.real_uid = DEFAULT_UID; - user.real_gid = DEFAULT_GID; + myself->uid = DEFAULT_UID; + myself->gid = DEFAULT_GID; } (void) cygheap->user.ontherange (CH_HOME, pw); @@ -109,8 +109,8 @@ uinfo_init () internal_getlogin (cygheap->user); /* Set the cygheap->user. */ /* Real and effective uid/gid are identical on process start up. */ - myself->uid = cygheap->user.orig_uid = cygheap->user.real_uid; - myself->gid = cygheap->user.orig_gid = cygheap->user.real_gid; + cygheap->user.orig_uid = cygheap->user.real_uid = myself->uid; + cygheap->user.orig_gid = cygheap->user.real_gid = myself->gid; cygheap->user.set_orig_sid(); /* Update the original sid */ cygheap->user.token = INVALID_HANDLE_VALUE; /* No token present */ |