Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2002-05-28 18:10:55 +0400
committerCorinna Vinschen <corinna@vinschen.de>2002-05-28 18:10:55 +0400
commit571964058165952634fce744588d588096cd1c2c (patch)
tree753fe9a6289181cd0218d36b7b57486194191bf8
parentf542ad4e14fae736164e354cd0f456427c82870c (diff)
Change internal gid datatype from __gid16_t to __gid32_t
throughout. * cygwin.din: Export new symbols chown32, fchown32, getegid32, getgid32, getgrgid32, getgrnam32, getgroups32, initgroups32, lchown32, setgid32, setegid32, getgrent32. * grp.cc (grp32togrp16): New static function. (getgrgid32): New function. (getgrnam32): Ditto. (getgrent32): Ditto. (getgroups32): Change name of internal function from getgroups. (getgroups32): New function. (initgroups32): Ditto. * syscalls.cc (chown32): Ditto. (lchown32): Ditto. (fchown32): Ditto. (setegid32): Ditto. (setgid32): Ditto. * uinfo.cc (getgid32): Ditto. (getegid32): Ditto. * include/cygwin/grp.h: Remove declaration of getgrgid() and getgrnam(). Declare getgrgid32() and getgrnam32() instead. Declare getgid32().
-rw-r--r--winsup/cygwin/ChangeLog24
-rw-r--r--winsup/cygwin/cygheap.h4
-rw-r--r--winsup/cygwin/cygwin.din12
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc4
-rw-r--r--winsup/cygwin/grp.cc103
-rw-r--r--winsup/cygwin/include/cygwin/grp.h5
-rw-r--r--winsup/cygwin/pinfo.h4
-rw-r--r--winsup/cygwin/sec_acl.cc10
-rw-r--r--winsup/cygwin/sec_helper.cc18
-rw-r--r--winsup/cygwin/security.cc18
-rw-r--r--winsup/cygwin/security.h12
-rw-r--r--winsup/cygwin/shm.cc6
-rw-r--r--winsup/cygwin/syscalls.cc73
-rw-r--r--winsup/cygwin/uinfo.cc14
-rw-r--r--winsup/cygwin/winsup.h2
15 files changed, 235 insertions, 74 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 0438b3777..40eed8495 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,27 @@
+2002-05-28 Corinna Vinschen <corinna@vinschen.de>
+
+ Change internal gid datatype from __gid16_t to __gid32_t
+ throughout.
+ * cygwin.din: Export new symbols chown32, fchown32, getegid32,
+ getgid32, getgrgid32, getgrnam32, getgroups32, initgroups32, lchown32,
+ setgid32, setegid32, getgrent32.
+ * grp.cc (grp32togrp16): New static function.
+ (getgrgid32): New function.
+ (getgrnam32): Ditto.
+ (getgrent32): Ditto.
+ (getgroups32): Change name of internal function from getgroups.
+ (getgroups32): New function.
+ (initgroups32): Ditto.
+ * syscalls.cc (chown32): Ditto.
+ (lchown32): Ditto.
+ (fchown32): Ditto.
+ (setegid32): Ditto.
+ (setgid32): Ditto.
+ * uinfo.cc (getgid32): Ditto.
+ (getegid32): Ditto.
+ * include/cygwin/grp.h: Remove declaration of getgrgid() and getgrnam().
+ Declare getgrgid32() and getgrnam32() instead. Declare getgid32().
+
2002-05-27 Christopher Faylor <cgf@redhat.com>
* autoload.cc (noload): Properly mask low order word for determining
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index f7c507e46..aa4e525ab 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -97,9 +97,9 @@ class cygheap_user
PSID orig_psid; /* Remains intact even after impersonation */
public:
__uid16_t orig_uid; /* Remains intact even after impersonation */
- __uid16_t orig_gid; /* Ditto */
+ __gid32_t orig_gid; /* Ditto */
__uid16_t real_uid; /* Remains intact on seteuid, replaced by setuid */
- __gid16_t real_gid; /* Ditto */
+ __gid32_t real_gid; /* Ditto */
/* token is needed if set(e)uid should be called. It can be set by a call
to `set_impersonation_token()'. */
diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index 165c26f03..1d8ae0b81 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -100,6 +100,7 @@ chmod
_chmod = chmod
chown
_chown = chown
+chown32
cleanup_glue
clearerr
_clearerr = clearerr
@@ -205,6 +206,7 @@ fchmod
_fchmod = fchmod
fchown
_fchown = fchown
+fchown32
fclose
_fclose = fclose
fcntl
@@ -344,16 +346,21 @@ getdtablesize
_getdtablesize = getdtablesize
getegid
_getegid = getegid
+getegid32
geteuid
_geteuid = geteuid
getgid
_getgid = getgid
+getgid32
getgrgid
_getgrgid = getgrgid
+getgrgid32
getgrnam
_getgrnam = getgrnam
+getgrnam32
getgroups
_getgroups = getgroups
+getgroups32
gethostname = cygwin_gethostname
_gethostname = cygwin_gethostname
getlogin
@@ -412,6 +419,7 @@ _infinity = infinity
infinityf
_infinityf = infinityf
initgroups
+initgroups32
ioctl
_ioctl = ioctl
iprintf
@@ -468,6 +476,7 @@ labs
_labs = labs
lchown
_lchown = lchown
+lchown32
ldexp
_ldexp = ldexp
ldexpf
@@ -658,6 +667,7 @@ setdtablesize
_setdtablesize = setdtablesize
setgid
_setgid = setgid
+setgid32
setjmp
_setjmp = setjmp
setlocale
@@ -674,6 +684,7 @@ seteuid
_seteuid = seteuid
setegid
_setegid = setegid
+setegid32
setuid
_setuid = setuid
setutent
@@ -1013,6 +1024,7 @@ getpgrp
_getpgrp = getpgrp
getgrent
_getgrent = getgrent
+getgrent32
ntohl
_ntohl = ntohl
htonl
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index aa6b50dc6..a1237cc3c 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -127,7 +127,7 @@ fhandler_disk_file::fstat (struct __stat64 *buf, path_conv *pc)
int res = -1;
int oret;
__uid16_t uid;
- __gid16_t gid;
+ __gid32_t gid;
int open_flags = O_RDONLY | O_BINARY | O_DIROPEN;
bool query_open_already;
@@ -238,7 +238,7 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc,
buf->st_mode = S_IFSOCK;
__uid16_t uid;
- __gid16_t gid;
+ __gid32_t gid;
if (get_file_attribute (pc->has_acls (), get_win32_name (), &buf->st_mode,
&uid, &gid) == 0)
{
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index 4002fbc00..3ec8cd988 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -31,7 +31,7 @@ details. */
on the first call that needs information from it. */
static const char *etc_group NO_COPY = "/etc/group";
-static struct __group16 *group_buf; /* group contents in memory */
+static struct __group32 *group_buf; /* group contents in memory */
static int curr_lines;
static int max_lines;
@@ -45,7 +45,7 @@ static int grp_pos = 0;
static pwdgrp_check group_state;
static int
-parse_grp (struct __group16 &grp, const char *line)
+parse_grp (struct __group32 &grp, const char *line)
{
int len = strlen(line);
char *newline = (char *) malloc (len + 1);
@@ -110,7 +110,7 @@ add_grp_line (const char *line)
if (curr_lines == max_lines)
{
max_lines += 10;
- group_buf = (struct __group16 *) realloc (group_buf, max_lines * sizeof (struct __group16));
+ group_buf = (struct __group32 *) realloc (group_buf, max_lines * sizeof (struct __group32));
}
if (parse_grp (group_buf[curr_lines], line))
curr_lines++;
@@ -210,11 +210,28 @@ read_etc_group ()
return;
}
-extern "C"
+static
struct __group16 *
-getgrgid (__gid16_t gid)
+grp32togrp16 (struct __group16 *gp16, struct __group32 *gp32)
{
- struct __group16 * default_grp = NULL;
+ if (!gp16 || !gp32)
+ return NULL;
+
+ /* Copying the pointers is actually unnecessary. Just having the correct
+ return type is important. */
+ gp16->gr_name = gp32->gr_name;
+ gp16->gr_passwd = gp32->gr_passwd;
+ gp16->gr_gid = (__gid16_t) gp32->gr_gid; /* Not loss-free */
+ gp16->gr_mem = gp32->gr_mem;
+
+ return gp16;
+}
+
+extern "C"
+struct __group32 *
+getgrgid32 (__gid32_t gid)
+{
+ struct __group32 * default_grp = NULL;
if (group_state <= initializing)
read_etc_group();
@@ -231,7 +248,16 @@ getgrgid (__gid16_t gid)
extern "C"
struct __group16 *
-getgrnam (const char *name)
+getgrgid (__gid16_t gid)
+{
+ static struct __group16 g16;
+
+ return grp32togrp16 (&g16, getgrgid32 ((__gid32_t) gid));
+}
+
+extern "C"
+struct __group32 *
+getgrnam32 (const char *name)
{
if (group_state <= initializing)
read_etc_group();
@@ -245,6 +271,15 @@ getgrnam (const char *name)
}
extern "C"
+struct __group16 *
+getgrnam (const char *name)
+{
+ static struct __group16 g16;
+
+ return grp32togrp16 (&g16, getgrnam32 (name));
+}
+
+extern "C"
void
endgrent()
{
@@ -252,8 +287,8 @@ endgrent()
}
extern "C"
-struct __group16 *
-getgrent()
+struct __group32 *
+getgrent32()
{
if (group_state <= initializing)
read_etc_group();
@@ -265,6 +300,15 @@ getgrent()
}
extern "C"
+struct __group16 *
+getgrent()
+{
+ static struct __group16 g16;
+
+ return grp32togrp16 (&g16, getgrent32 ());
+}
+
+extern "C"
void
setgrent ()
{
@@ -272,7 +316,7 @@ setgrent ()
}
/* Internal function. ONLY USE THIS INTERNALLY, NEVER `getgrent'!!! */
-struct __group16 *
+struct __group32 *
internal_getgrent (int pos)
{
if (group_state <= initializing)
@@ -284,12 +328,13 @@ internal_getgrent (int pos)
}
int
-getgroups (int gidsetsize, __gid16_t *grouplist, __gid16_t gid, const char *username)
+getgroups32 (int gidsetsize, __gid32_t *grouplist, __gid32_t gid,
+ const char *username)
{
HANDLE hToken = NULL;
DWORD size;
int cnt = 0;
- struct __group16 *gr;
+ struct __group32 *gr;
if (group_state <= initializing)
read_etc_group();
@@ -359,9 +404,41 @@ error:
extern "C"
int
+getgroups32 (int gidsetsize, __gid32_t *grouplist)
+{
+ return getgroups32 (gidsetsize, grouplist, myself->gid,
+ cygheap->user.name ());
+}
+
+extern "C"
+int
getgroups (int gidsetsize, __gid16_t *grouplist)
{
- return getgroups (gidsetsize, grouplist, myself->gid, cygheap->user.name ());
+ __gid32_t *grouplist32 = NULL;
+
+ if (gidsetsize < 0)
+ {
+ set_errno (EINVAL);
+ return -1;
+ }
+ if (gidsetsize > 0 && grouplist)
+ grouplist32 = (__gid32_t *) alloca (gidsetsize * sizeof (__gid32_t));
+
+ int ret = getgroups32 (gidsetsize, grouplist32, myself->gid,
+ cygheap->user.name ());
+
+ if (gidsetsize > 0 && grouplist)
+ for (int i = 0; i < ret; ++ i)
+ grouplist[i] = grouplist32[i];
+
+ return ret;
+}
+
+extern "C"
+int
+initgroups32 (const char *, __gid32_t)
+{
+ return 0;
}
extern "C"
diff --git a/winsup/cygwin/include/cygwin/grp.h b/winsup/cygwin/include/cygwin/grp.h
index 3a58e2058..46874df0d 100644
--- a/winsup/cygwin/include/cygwin/grp.h
+++ b/winsup/cygwin/include/cygwin/grp.h
@@ -35,8 +35,9 @@ struct __group32
char **gr_mem;
};
-struct __group16 * getgrgid (__gid16_t gid);
-struct __group16 * getgrnam (const char *name);
+struct __group32 * getgrgid32 (__gid32_t gid);
+struct __group32 * getgrnam32 (const char *name);
+__gid32_t getgid32 ();
#endif
#ifdef __cplusplus
diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h
index 55284d15b..a54c9b677 100644
--- a/winsup/cygwin/pinfo.h
+++ b/winsup/cygwin/pinfo.h
@@ -65,8 +65,8 @@ public:
if not found. This data resides in the shared data area (allowing
tasks to store whatever they want here) so it's for informational
purposes only. */
- __uid16_t uid; /* User ID */
- __gid16_t gid; /* Group ID */
+ __uid32_t uid; /* User ID */
+ __gid32_t gid; /* Group ID */
pid_t pgid; /* Process group ID */
pid_t sid; /* Session ID */
int ctty; /* Control tty */
diff --git a/winsup/cygwin/sec_acl.cc b/winsup/cygwin/sec_acl.cc
index 0ef423f7b..47f1cb426 100644
--- a/winsup/cygwin/sec_acl.cc
+++ b/winsup/cygwin/sec_acl.cc
@@ -107,7 +107,7 @@ setacl (const char *file, int nentries, __aclent16_t *aclbufp)
cygsid sid;
struct passwd *pw;
- struct __group16 *gr;
+ struct __group32 *gr;
int pos;
if (!InitializeAcl (acl, 3072, ACL_REVISION))
@@ -172,7 +172,7 @@ setacl (const char *file, int nentries, __aclent16_t *aclbufp)
break;
case GROUP:
case DEF_GROUP:
- if (!(gr = getgrgid (aclbufp[i].a_id))
+ if (!(gr = getgrgid32 (aclbufp[i].a_id))
|| !sid.getfromgr (gr)
|| !add_access_allowed_ace (acl, ace_off++, allow,
sid, acl_len, inheritance))
@@ -256,7 +256,7 @@ getacl (const char *file, DWORD attr, int nentries, __aclent16_t *aclbufp)
PSID group_sid;
BOOL dummy;
__uid16_t uid;
- __gid16_t gid;
+ __gid32_t gid;
if (!GetSecurityDescriptorOwner (psd, &owner_sid, &dummy))
{
@@ -424,7 +424,7 @@ acl_access (const char *path, int flags)
cygsid owner;
cygsid group;
struct passwd *pw;
- struct __group16 *gr = NULL;
+ struct __group32 *gr = NULL;
if ((pw = getpwuid (acls[i].a_id)) != NULL
&& owner.getfrompw (pw))
@@ -994,7 +994,7 @@ aclfromtext (char *acltextp, int *)
c += 5;
if (isalpha (*c))
{
- struct __group16 *gr = getgrnam (c);
+ struct __group32 *gr = getgrnam32 (c);
if (!gr)
{
set_errno (EINVAL);
diff --git a/winsup/cygwin/sec_helper.cc b/winsup/cygwin/sec_helper.cc
index 365364d9f..c5341128f 100644
--- a/winsup/cygwin/sec_helper.cc
+++ b/winsup/cygwin/sec_helper.cc
@@ -127,7 +127,7 @@ cygsid::getfrompw (const struct passwd *pw)
}
BOOL
-cygsid::getfromgr (const struct __group16 *gr)
+cygsid::getfromgr (const struct __group32 *gr)
{
char *sp = (gr && gr->gr_passwd) ? gr->gr_passwd : NULL;
return (*this = sp ?: "") != NULL;
@@ -174,7 +174,7 @@ cygsid::get_id (BOOL search_grp, int *type)
}
if (search_grp || type)
{
- struct __group16 *gr;
+ struct __group32 *gr;
for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx)
{
if (sid.getfromgr (gr) && sid == psid)
@@ -224,7 +224,7 @@ cygsid::get_id (BOOL search_grp, int *type)
*type = GROUP;
if (id == -1)
{
- struct __group16 *gr = getgrnam (account);
+ struct __group32 *gr = getgrnam32 (account);
if (gr)
id = gr->gr_gid;
}
@@ -249,16 +249,16 @@ cygsid::get_id (BOOL search_grp, int *type)
}
BOOL
-is_grp_member (__uid16_t uid, __gid16_t gid)
+is_grp_member (__uid32_t uid, __gid32_t gid)
{
- extern int getgroups (int, __gid16_t *, __gid16_t, const char *);
+ extern int getgroups32 (int, __gid32_t *, __gid32_t, const char *);
BOOL grp_member = TRUE;
struct passwd *pw = getpwuid (uid);
- __gid16_t grps[NGROUPS_MAX];
- int cnt = getgroups (NGROUPS_MAX, grps,
- pw ? pw->pw_gid : myself->gid,
- pw ? pw->pw_name : cygheap->user.name ());
+ __gid32_t grps[NGROUPS_MAX];
+ int cnt = getgroups32 (NGROUPS_MAX, grps,
+ pw ? pw->pw_gid : myself->gid,
+ pw ? pw->pw_name : cygheap->user.name ());
int i;
for (i = 0; i < cnt; ++i)
if (grps[i] == gid)
diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc
index 2c90f621f..b16934114 100644
--- a/winsup/cygwin/security.cc
+++ b/winsup/cygwin/security.cc
@@ -456,7 +456,7 @@ get_user_primary_group (WCHAR *wlogonserver, const char *user,
static int
get_supplementary_group_sidlist (const char *username, cygsidlist &grp_list)
{
- struct __group16 *gr;
+ struct __group32 *gr;
int cnt = 0;
for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx)
@@ -1130,7 +1130,7 @@ write_sd(const char *file, PSECURITY_DESCRIPTOR sd_buf, DWORD sd_size)
static int
get_nt_attribute (const char *file, int *attribute,
- __uid16_t *uidret, __gid16_t *gidret)
+ __uid16_t *uidret, __gid32_t *gidret)
{
if (!wincap.has_security ())
return 0;
@@ -1169,7 +1169,7 @@ get_nt_attribute (const char *file, int *attribute,
}
__uid16_t uid = cygsid(owner_sid).get_uid ();
- __gid16_t gid = cygsid(group_sid).get_gid ();
+ __gid32_t gid = cygsid(group_sid).get_gid ();
if (uidret)
*uidret = uid;
if (gidret)
@@ -1279,7 +1279,7 @@ get_nt_attribute (const char *file, int *attribute,
int
get_file_attribute (int use_ntsec, const char *file,
- int *attribute, __uid16_t *uidret, __gid16_t *gidret)
+ int *attribute, __uid16_t *uidret, __gid32_t *gidret)
{
int res;
@@ -1294,7 +1294,7 @@ get_file_attribute (int use_ntsec, const char *file,
if (uidret)
*uidret = getuid ();
if (gidret)
- *gidret = getgid ();
+ *gidret = getgid32 ();
if (!attribute)
return 0;
@@ -1350,7 +1350,7 @@ add_access_denied_ace (PACL acl, int offset, DWORD attributes,
}
PSECURITY_DESCRIPTOR
-alloc_sd (__uid16_t uid, __gid16_t gid, const char *logsrv, int attribute,
+alloc_sd (__uid16_t uid, __gid32_t gid, const char *logsrv, int attribute,
PSECURITY_DESCRIPTOR sd_ret, DWORD *sd_size_ret)
{
BOOL dummy;
@@ -1378,7 +1378,7 @@ alloc_sd (__uid16_t uid, __gid16_t gid, const char *logsrv, int attribute,
/* Get SID and name of new group. */
cygsid group_sid (NO_SID);
- struct __group16 *grp = getgrgid (gid);
+ struct __group32 *grp = getgrgid32 (gid);
if (grp)
{
if ((!grp || !group_sid.getfromgr (grp))
@@ -1619,7 +1619,7 @@ set_security_attribute (int attribute, PSECURITY_ATTRIBUTES psa,
}
static int
-set_nt_attribute (const char *file, __uid16_t uid, __gid16_t gid,
+set_nt_attribute (const char *file, __uid16_t uid, __gid32_t gid,
const char *logsrv, int attribute)
{
if (!wincap.has_security ())
@@ -1645,7 +1645,7 @@ set_nt_attribute (const char *file, __uid16_t uid, __gid16_t gid,
int
set_file_attribute (int use_ntsec, const char *file,
- __uid16_t uid, __gid16_t gid,
+ __uid16_t uid, __gid32_t gid,
int attribute, const char *logsrv)
{
int ret = 0;
diff --git a/winsup/cygwin/security.h b/winsup/cygwin/security.h
index 81cbd51e2..db3df2901 100644
--- a/winsup/cygwin/security.h
+++ b/winsup/cygwin/security.h
@@ -57,7 +57,7 @@ public:
inline PSID set () { return psid = (PSID) sbuf; }
BOOL getfrompw (const struct passwd *pw);
- BOOL getfromgr (const struct __group16 *gr);
+ BOOL getfromgr (const struct __group32 *gr);
int get_id (BOOL search_grp, int *type = NULL);
inline int get_uid () { return get_id (FALSE); }
@@ -161,14 +161,14 @@ extern BOOL allow_smbntsec;
and group lists so they are somehow security related. Besides that
I didn't find a better place to declare them. */
extern struct passwd *internal_getpwent (int);
-extern struct __group16 *internal_getgrent (int);
+extern struct __group32 *internal_getgrent (int);
/* File manipulation */
int __stdcall set_process_privileges ();
int __stdcall get_file_attribute (int, const char *, int *,
- __uid16_t * = NULL, __gid16_t * = NULL);
+ __uid16_t * = NULL, __gid32_t * = NULL);
int __stdcall set_file_attribute (int, const char *, int);
-int __stdcall set_file_attribute (int, const char *, __uid16_t, __gid16_t, int, const char *);
+int __stdcall set_file_attribute (int, const char *, __uid16_t, __gid32_t, int, const char *);
LONG __stdcall read_sd(const char *file, PSECURITY_DESCRIPTOR sd_buf, LPDWORD sd_size);
LONG __stdcall write_sd(const char *file, PSECURITY_DESCRIPTOR sd_buf, DWORD sd_size);
BOOL __stdcall add_access_allowed_ace (PACL acl, int offset, DWORD attributes, PSID sid, size_t &len_add, DWORD inherit);
@@ -190,7 +190,7 @@ void extract_nt_dom_user (const struct passwd *pw, char *domain, char *user);
BOOL get_logon_server_and_user_domain (char *logonserver, char *domain);
/* sec_helper.cc: Security helper functions. */
-BOOL __stdcall is_grp_member (__uid16_t uid, __gid16_t gid);
+BOOL __stdcall is_grp_member (__uid32_t uid, __gid32_t gid);
/* `lookup_name' should be called instead of LookupAccountName.
* logsrv may be NULL, in this case only the local system is used for lookup.
* The buffer for ret_sid (40 Bytes) has to be allocated by the caller! */
@@ -209,7 +209,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 (uid_t uid, gid_t gid, const char *logsrv, int attribute,
+PSECURITY_DESCRIPTOR alloc_sd (__uid16_t uid, __gid32_t gid, const char *logsrv, int attribute,
PSECURITY_DESCRIPTOR sd_ret, DWORD *sd_size_ret);
extern inline SECURITY_ATTRIBUTES *
diff --git a/winsup/cygwin/shm.cc b/winsup/cygwin/shm.cc
index ab808aecd..8a32efb66 100644
--- a/winsup/cygwin/shm.cc
+++ b/winsup/cygwin/shm.cc
@@ -442,7 +442,7 @@ shmctl (int shmid, int cmd, struct shmid_ds *buf)
return 0;
}
-/* FIXME: evaluate getuid() and getgid() against the requested mode. Then
+/* FIXME: evaluate getuid() and getgid32() against the requested mode. Then
* choose PAGE_READWRITE | PAGE_READONLY and FILE_MAP_WRITE | FILE_MAP_READ
* appropriately
*/
@@ -461,7 +461,7 @@ shmget (key_t key, size_t size, int shmflg)
/* create a sd for our open requests based on shmflag & 0x01ff */
InitializeSecurityDescriptor (psd,
SECURITY_DESCRIPTOR_REVISION);
- psd = alloc_sd (getuid (), getgid (), cygheap->user.logsrv (),
+ psd = alloc_sd (getuid (), getgid32 (), cygheap->user.logsrv (),
shmflg & 0x01ff, psd, &sd_size);
if (key == (key_t) - 1)
@@ -540,7 +540,7 @@ shmget (key_t key, size_t size, int shmflg)
/* fill out the node data */
shmtemp->shm_perm.cuid = getuid ();
shmtemp->shm_perm.uid = shmtemp->shm_perm.cuid;
- shmtemp->shm_perm.cgid = getgid ();
+ shmtemp->shm_perm.cgid = getgid32 ();
shmtemp->shm_perm.gid = shmtemp->shm_perm.cgid;
shmtemp->shm_perm.mode = shmflg & 0x01ff;
shmtemp->shm_lpid = 0;
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 1511e7642..afdc457e9 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -750,11 +750,11 @@ done:
* systems, it is only a stub that always returns zero.
*/
static int
-chown_worker (const char *name, unsigned fmode, __uid16_t uid, __gid16_t gid)
+chown_worker (const char *name, unsigned fmode, __uid16_t uid, __gid32_t gid)
{
int res;
__uid16_t old_uid;
- __gid16_t old_gid;
+ __gid32_t old_gid;
if (check_null_empty_str_errno (name))
return -1;
@@ -815,21 +815,35 @@ done:
}
extern "C" int
-chown (const char * name, __uid16_t uid, __gid16_t gid)
+chown32 (const char * name, __uid16_t uid, __gid32_t gid)
{
sigframe thisframe (mainthread);
return chown_worker (name, PC_SYM_FOLLOW, uid, gid);
}
extern "C" int
-lchown (const char * name, __uid16_t uid, __gid16_t gid)
+chown (const char * name, __uid16_t uid, __gid16_t gid)
+{
+ sigframe thisframe (mainthread);
+ return chown_worker (name, PC_SYM_FOLLOW, uid, (__gid32_t) gid);
+}
+
+extern "C" int
+lchown32 (const char * name, __uid16_t uid, __gid32_t gid)
{
sigframe thisframe (mainthread);
return chown_worker (name, PC_SYM_NOFOLLOW, uid, gid);
}
extern "C" int
-fchown (int fd, __uid16_t uid, __gid16_t gid)
+lchown (const char * name, __uid16_t uid, __gid16_t gid)
+{
+ sigframe thisframe (mainthread);
+ return chown_worker (name, PC_SYM_NOFOLLOW, uid, (__gid32_t) gid);
+}
+
+extern "C" int
+fchown32 (int fd, __uid16_t uid, __gid32_t gid)
{
sigframe thisframe (mainthread);
cygheap_fdget cfd (fd);
@@ -853,6 +867,12 @@ fchown (int fd, __uid16_t uid, __gid16_t gid)
return chown_worker (path, PC_SYM_FOLLOW, uid, gid);
}
+extern "C" int
+fchown (int fd, __uid16_t uid, __gid16_t gid)
+{
+ return fchown32 (fd, uid, (__gid32_t) gid);
+}
+
/* umask: POSIX 5.3.3.1 */
extern "C" mode_t
umask (mode_t mask)
@@ -895,7 +915,7 @@ chmod (const char *path, mode_t mode)
SetFileAttributes (win32_path, (DWORD) win32_path & ~FILE_ATTRIBUTE_READONLY);
__uid16_t uid;
- __gid16_t gid;
+ __gid32_t gid;
if (win32_path.isdir ())
mode |= S_IFDIR;
@@ -1912,16 +1932,6 @@ mkfifo (const char *_path, mode_t mode)
return -1;
}
-/* setgid: POSIX 4.2.2.1 */
-extern "C" int
-setgid (__gid16_t gid)
-{
- int ret = setegid (gid);
- if (!ret)
- cygheap->user.real_gid = myself->gid;
- return ret;
-}
-
/* setuid: POSIX 4.2.2.1 */
extern "C" int
setuid (__uid16_t uid)
@@ -1966,7 +1976,7 @@ seteuid (__uid16_t uid)
pw_new = getpwuid (uid);
if (!usersid.getfrompw (pw_new) ||
- (!pgrpsid.getfromgr (getgrgid (myself->gid))))
+ (!pgrpsid.getfromgr (getgrgid32 (myself->gid))))
{
set_errno (EINVAL);
return -1;
@@ -2137,7 +2147,7 @@ seteuid (__uid16_t uid)
/* setegid: from System V. */
extern "C" int
-setegid (__gid16_t gid)
+setegid32 (__gid32_t gid)
{
if ((!wincap.has_security ()) ||
(gid == ILLEGAL_GID))
@@ -2147,7 +2157,7 @@ setegid (__gid16_t gid)
cygsid gsid;
HANDLE ptok;
- if (!(gsid.getfromgr (getgrgid (gid))))
+ if (!(gsid.getfromgr (getgrgid32 (gid))))
{
set_errno (EINVAL);
return -1;
@@ -2184,6 +2194,31 @@ setegid (__gid16_t gid)
return 0;
}
+extern "C" int
+setegid (__gid16_t gid)
+{
+ return setegid32 ((__gid32_t) gid);
+}
+
+/* setgid: POSIX 4.2.2.1 */
+extern "C" int
+setgid32 (__gid32_t gid)
+{
+ int ret = setegid32 (gid);
+ if (!ret)
+ cygheap->user.real_gid = myself->gid;
+ return ret;
+}
+
+extern "C" int
+setgid (__gid16_t gid)
+{
+ int ret = setegid32 ((__gid32_t) gid);
+ if (!ret)
+ cygheap->user.real_gid = myself->gid;
+ return ret;
+}
+
/* chroot: privileged Unix system call. */
/* FIXME: Not privileged here. How should this be done? */
extern "C" int
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index 6a6b702c7..b851b384d 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -173,7 +173,7 @@ internal_getlogin (cygheap_user &user)
if (psid.getfrompw (pw) && EqualSid (user.sid (), psid))
{
user.set_name (pw->pw_name);
- struct __group16 *gr = getgrgid (pw->pw_gid);
+ struct __group32 *gr = getgrgid32 (pw->pw_gid);
if (gr)
if (!gsid.getfromgr (gr))
gsid = NO_SID;
@@ -288,6 +288,12 @@ getuid (void)
return cygheap->user.real_uid;
}
+extern "C" __gid32_t
+getgid32 (void)
+{
+ return cygheap->user.real_gid;
+}
+
extern "C" __gid16_t
getgid (void)
{
@@ -300,6 +306,12 @@ geteuid (void)
return myself->uid;
}
+extern "C" __gid32_t
+getegid32 (void)
+{
+ return myself->gid;
+}
+
extern "C" __gid16_t
getegid (void)
{
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 2d1fc1bc5..69d5938ae 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -148,7 +148,7 @@ extern "C" void __stdcall do_exit (int) __attribute__ ((noreturn));
void uinfo_init (void);
#define ILLEGAL_UID ((__uid16_t)-1)
-#define ILLEGAL_GID ((__gid16_t)-1)
+#define ILLEGAL_GID ((__gid32_t)-1)
#define ILLEGAL_SEEK ((__off64_t)-1)
/* various events */