aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-01-25 16:37:00 +0000
committerChristopher Faylor <me@cgf.cx>2003-01-25 16:37:00 +0000
commit223e9f5d58cfdeab97ba324d9809a5513a17123c (patch)
tree58cbcc7e2349a6bc3a40fb462bc6120ae38f1ed1 /winsup
parent23803927b011f875ee083791d634429460079baa (diff)
downloadnewlib-223e9f5d58cfdeab97ba324d9809a5513a17123c.zip
newlib-223e9f5d58cfdeab97ba324d9809a5513a17123c.tar.gz
newlib-223e9f5d58cfdeab97ba324d9809a5513a17123c.tar.bz2
merge from trunk
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog19
-rw-r--r--winsup/cygwin/child_info.h1
-rw-r--r--winsup/cygwin/dcrt0.cc5
-rw-r--r--winsup/cygwin/grp.cc1
-rw-r--r--winsup/cygwin/pwdgrp.h5
-rw-r--r--winsup/cygwin/spawn.cc1
-rw-r--r--winsup/cygwin/syscalls.cc28
-rw-r--r--winsup/cygwin/uinfo.cc23
8 files changed, 51 insertions, 32 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 0e5a318..404fd0e 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,22 @@
+2003-01-25 Christopher Faylor <cgf@redhat.com>
+
+ * pwdgrp.cc (pwdgrp::reparse): Declare.
+ * uinfo.cc (pwdgrp::reparse): Define.
+ * grp.cc (pwdgrp::parse_group): Use.
+
+2003-01-25 Pierre Humblet <pierre.humblet@ieee.org>
+
+ * syscalls.cc (seteuid32): On Win95 get the pw entry. If it exists
+ update the euid and call cygheap->user.set_name. Remove special
+ handling of ILLEGAL_UID.
+ (setgid32): Add a debug_printf. On Win95, always set the egid.
+ Remove special handling of ILLEGAL_GID. Do not compare gid and gr_gid.
+ * child_info.h (class cygheap_exec_info): Remove uid.
+ * spawn.cc (spawn_guts): Do not set ciresrv.moreinfo->uid.
+ * dcrto.cc (dll_crt0_1): Always call uinfo_init.
+ * uinfo.cc (uinfo_init): Reorganize and close handle if needed.
+ (cygheap_user::ontherange): Do not call internal_getpwnam if pw is NULL.
+
2003-01-24 Christopher Faylor <cgf@redhat.com>
* fhandler_console.cc (fhandler_console::send_winch_maybe): Reset
diff --git a/winsup/cygwin/child_info.h b/winsup/cygwin/child_info.h
index 2ac0152..f7d69ca 100644
--- a/winsup/cygwin/child_info.h
+++ b/winsup/cygwin/child_info.h
@@ -71,7 +71,6 @@ class fhandler_base;
class cygheap_exec_info
{
public:
- __uid32_t uid;
char *old_title;
int argc;
char **argv;
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 7e3030c..90c2dc1 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -685,9 +685,8 @@ dll_crt0_1 ()
/* Init global well known SID objects */
cygsid::init ();
- /* Initialize uid, gid if necessary. */
- if (child_proc_info == NULL || spawn_info->moreinfo->uid == ILLEGAL_UID)
- uinfo_init ();
+ /* Initialize user info. */
+ uinfo_init ();
/* Initialize signal/subprocess handling. */
sigproc_init ();
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index 9cce888..b4b590b 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -61,6 +61,7 @@ pwdgrp::parse_group ()
char **namearray = (char **) calloc (i + 2, sizeof (char *));
if (namearray)
{
+ reparse (dp);
for (i = 0; (dp = next_str (',')); i++)
namearray[i] = dp;
namearray[i] = NULL;
diff --git a/winsup/cygwin/pwdgrp.h b/winsup/cygwin/pwdgrp.h
index ede3808..aa7ab38 100644
--- a/winsup/cygwin/pwdgrp.h
+++ b/winsup/cygwin/pwdgrp.h
@@ -45,8 +45,9 @@ class pwdgrp
void read_passwd ();
void read_group ();
char *add_line (char *);
- char *pwdgrp::next_str (char = 0);
- int pwdgrp::next_int (char = 0);
+ char *next_str (char = 0);
+ int next_int (char = 0);
+ void reparse (char *);
public:
int curr_lines;
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 9c055c8..9b0b4a9 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -658,7 +658,6 @@ spawn_guts (const char * prog_arg, const char *const *argv,
char wstname[1024];
char dskname[1024];
- ciresrv.moreinfo->uid = ILLEGAL_UID;
hwst = GetProcessWindowStation ();
SetUserObjectSecurity (hwst, &dsi, get_null_sd ());
GetUserObjectInformation (hwst, UOI_NAME, wstname, 1024, &n);
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 4ed57c3..6e20f07 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -2015,21 +2015,14 @@ mkfifo (const char *_path, mode_t mode)
extern "C" int
seteuid32 (__uid32_t uid)
{
- debug_printf ("uid: %d myself->gid: %d", uid, myself->gid);
+ debug_printf ("uid: %u myself->gid: %u", uid, myself->gid);
- if (!wincap.has_security ()
- || (uid == myself->uid && !cygheap->user.groups.ischanged))
+ if (uid == myself->uid && !cygheap->user.groups.ischanged)
{
debug_printf ("Nothing happens");
return 0;
}
- if (uid == ILLEGAL_UID)
- {
- set_errno (EINVAL);
- return -1;
- }
-
sigframe thisframe (mainthread);
cygsid usersid;
user_groups &groups = cygheap->user.groups;
@@ -2040,6 +2033,8 @@ seteuid32 (__uid32_t uid)
PSID origpsid, psid2 = NO_SID;
pw_new = internal_getpwuid (uid);
+ if (!wincap.has_security () && pw_new)
+ goto success;
if (!usersid.getfrompw (pw_new))
{
set_errno (EINVAL);
@@ -2158,9 +2153,9 @@ seteuid32 (__uid32_t uid)
sav_token != cygheap->user.token &&
sav_token_is_internal_token)
CloseHandle (sav_token);
- cygheap->user.set_name (pw_new->pw_name);
cygheap->user.set_sid (usersid);
success:
+ cygheap->user.set_name (pw_new->pw_name);
myself->uid = uid;
groups.ischanged = FALSE;
return 0;
@@ -2226,22 +2221,21 @@ setreuid (__uid16_t ruid, __uid16_t euid)
extern "C" int
setegid32 (__gid32_t gid)
{
- if (!wincap.has_security () || gid == myself->gid)
- return 0;
+ debug_printf ("new egid: %u current: %u", gid, myself->gid);
- if (gid == ILLEGAL_GID)
+ if (gid == myself->gid || !wincap.has_security ())
{
- set_errno (EINVAL);
- return -1;
+ myself->gid = gid;
+ return 0;
}
sigframe thisframe (mainthread);
user_groups * groups = &cygheap->user.groups;
cygsid gsid;
HANDLE ptok;
-
struct __group32 * gr = internal_getgrgid (gid);
- if (!gr || gr->gr_gid != gid || !gsid.getfromgr (gr))
+
+ if (!gsid.getfromgr (gr))
{
set_errno (EINVAL);
return -1;
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index b52cc09..dcc9376 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -102,15 +102,18 @@ internal_getlogin (cygheap_user &user)
void
uinfo_init ()
{
- if (!child_proc_info)
- internal_getlogin (cygheap->user); /* Set the cygheap->user. */
-
+ if (!child_proc_info || cygheap->user.token != INVALID_HANDLE_VALUE)
+ {
+ if (!child_proc_info)
+ internal_getlogin (cygheap->user); /* Set the cygheap->user. */
+ else
+ CloseHandle (cygheap->user.token);
+ cygheap->user.set_orig_sid (); /* Update the original sid */
+ cygheap->user.token = INVALID_HANDLE_VALUE; /* No token present */
+ }
/* Real and effective uid/gid are identical on process start up. */
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 */
}
extern "C" char *
@@ -214,8 +217,6 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw)
debug_printf ("HOME is already in the environment %s", p);
else
{
- if (!pw)
- pw = internal_getpwnam (name ());
if (pw && pw->pw_dir && *pw->pw_dir)
{
debug_printf ("Set HOME (from /etc/passwd) to %s", pw->pw_dir);
@@ -409,6 +410,12 @@ pwdgrp::next_str (char c)
return res;
}
+void
+pwdgrp::reparse (char *in_lptr)
+{
+ lptr = in_lptr;
+}
+
int
pwdgrp::next_int (char c)
{