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:
-rw-r--r--winsup/cygwin/ChangeLog17
-rw-r--r--winsup/cygwin/child_info.h2
-rw-r--r--winsup/cygwin/cygheap.h8
-rw-r--r--winsup/cygwin/dcrt0.cc2
-rw-r--r--winsup/cygwin/dir.cc4
-rw-r--r--winsup/cygwin/fhandler.cc10
-rw-r--r--winsup/cygwin/fhandler.h48
-rw-r--r--winsup/cygwin/fhandler_clipboard.cc4
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc14
-rw-r--r--winsup/cygwin/fhandler_dsp.cc4
-rw-r--r--winsup/cygwin/fhandler_floppy.cc12
-rw-r--r--winsup/cygwin/fhandler_mem.cc10
-rw-r--r--winsup/cygwin/fhandler_random.cc4
-rw-r--r--winsup/cygwin/fhandler_tape.cc6
-rw-r--r--winsup/cygwin/fhandler_zero.cc4
-rw-r--r--winsup/cygwin/grp.cc26
-rw-r--r--winsup/cygwin/include/cygwin/acl.h26
-rw-r--r--winsup/cygwin/include/cygwin/grp.h3
-rw-r--r--winsup/cygwin/mmap.cc16
-rw-r--r--winsup/cygwin/passwd.cc8
-rw-r--r--winsup/cygwin/pinfo.cc2
-rw-r--r--winsup/cygwin/pinfo.h4
-rw-r--r--winsup/cygwin/pipe.cc4
-rw-r--r--winsup/cygwin/sec_acl.cc69
-rw-r--r--winsup/cygwin/sec_helper.cc12
-rw-r--r--winsup/cygwin/security.cc19
-rw-r--r--winsup/cygwin/security.h10
-rw-r--r--winsup/cygwin/spawn.cc2
-rw-r--r--winsup/cygwin/syscalls.cc50
-rw-r--r--winsup/cygwin/thread.h2
-rw-r--r--winsup/cygwin/uinfo.cc14
-rw-r--r--winsup/cygwin/winsup.h4
32 files changed, 231 insertions, 189 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 85a330298..72474afaa 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,22 @@
2002-02-10 Corinna Vinschen <corinna@vinschen.de>
+ * (child_info.h, cygheap.h, dcrt0.cc, dir.cc, fhandler.cc, fhandler.h,
+ fhandler_clipboard.cc, fhandler_disk_file.cc, fhandler_dsp.cc,
+ fhandler_floppy.cc, fhandler_mem.cc, fhandler_random.cc,
+ fhandler_tape.cc, fhandler_zero.cc, grp.cc, mmap.cc, passwd.cc,
+ pinfo.cc, pinfo.h, pipe.cc, sec_acl.cc, sec_helper.cc, security.cc,
+ security.h, spawn.cc, syscalls.cc, thread.h, uinfo.cc, winsup.h):
+ Change usage of uid_t to __uid16_t, gid_t to __gid16_t and
+ off_t to __off32_t throughout. Use INVALID_UID, INVALID_GID and
+ INVALID_SEEK instead casting -1 to the appropriate type.
+ * winsup.h: Define INVALID_UID, INVALID_GID and INVALID_SEEK.
+ * include/cygwin/acl.h: Define internal __aclent16_t and __aclent32_t
+ types. Don't declare acl functions when compiling Cygwin.
+ * include/cygwin/grp.h: Declare getgrgid() and getgrnam() with
+ correct types for internal usage.
+
+2002-02-10 Corinna Vinschen <corinna@vinschen.de>
+
Patch suggested by Pierre A. Humblet <Pierre.Humblet@ieee.org>:
* uinfo.cc (internal_getlogin): Try evaluating user by SID even if
ntsec is off.
diff --git a/winsup/cygwin/child_info.h b/winsup/cygwin/child_info.h
index 4b249a808..4006951eb 100644
--- a/winsup/cygwin/child_info.h
+++ b/winsup/cygwin/child_info.h
@@ -70,7 +70,7 @@ class fhandler_base;
class cygheap_exec_info
{
public:
- uid_t uid;
+ __uid16_t uid;
char *old_title;
int argc;
char **argv;
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index d3025b452..1f7fc031e 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -96,10 +96,10 @@ class cygheap_user
char *pdomain; /* Logon domain of the user */
PSID psid; /* buffer for user's SID */
public:
- uid_t orig_uid; /* Remains intact even after impersonation */
- uid_t orig_gid; /* Ditto */
- uid_t real_uid; /* Remains intact on seteuid, replaced by setuid */
- gid_t real_gid; /* Ditto */
+ __uid16_t orig_uid; /* Remains intact even after impersonation */
+ __uid16_t orig_gid; /* Ditto */
+ __uid16_t real_uid; /* Remains intact on seteuid, replaced by setuid */
+ __gid16_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/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index b7866dfba..4ca46e4d4 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -623,7 +623,7 @@ dll_crt0_1 ()
}
if (child_proc_info->subproc_ready)
ProtectHandle (child_proc_info->subproc_ready);
- if (myself->uid == USHRT_MAX)
+ if (myself->uid == ILLEGAL_UID)
cygheap->user.set_sid (NULL);
break;
}
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc
index 1134c45e0..e3fd896dc 100644
--- a/winsup/cygwin/dir.cc
+++ b/winsup/cygwin/dir.cc
@@ -119,7 +119,7 @@ readdir (DIR *dir)
}
/* telldir */
-extern "C" off_t
+extern "C" __off32_t
telldir (DIR *dir)
{
if (check_null_invalid_struct_errno (dir))
@@ -132,7 +132,7 @@ telldir (DIR *dir)
/* seekdir */
extern "C" void
-seekdir (DIR *dir, off_t loc)
+seekdir (DIR *dir, __off32_t loc)
{
if (check_null_invalid_struct_errno (dir))
return;
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index a36ef0b13..35ec5dd82 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -693,10 +693,10 @@ fhandler_base::write (const void *ptr, size_t len)
return res;
}
-off_t
-fhandler_base::lseek (off_t offset, int whence)
+__off32_t
+fhandler_base::lseek (__off32_t offset, int whence)
{
- off_t res;
+ __off32_t res;
/* Seeks on text files is tough, we rewind and read till we get to the
right place. */
@@ -1181,7 +1181,7 @@ fhandler_base::readdir (DIR *)
return NULL;
}
-off_t
+__off32_t
fhandler_base::telldir (DIR *)
{
set_errno (ENOTDIR);
@@ -1189,7 +1189,7 @@ fhandler_base::telldir (DIR *)
}
void
-fhandler_base::seekdir (DIR *, off_t)
+fhandler_base::seekdir (DIR *, __off32_t)
{
set_errno (ENOTDIR);
return;
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 1b814272d..e9080ea80 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -288,13 +288,13 @@ class fhandler_base
virtual char const * ttyname () { return get_name(); }
virtual int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
virtual int write (const void *ptr, size_t len);
- virtual off_t lseek (off_t offset, int whence);
+ virtual __off32_t lseek (__off32_t offset, int whence);
virtual int lock (int, struct flock *);
virtual void dump ();
virtual int dup (fhandler_base *child);
virtual HANDLE mmap (caddr_t *addr, size_t len, DWORD access,
- int flags, off_t off);
+ int flags, __off32_t off);
virtual int munmap (HANDLE h, caddr_t addr, size_t len);
virtual int msync (HANDLE h, caddr_t addr, size_t len, int flags);
virtual BOOL fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
@@ -347,8 +347,8 @@ class fhandler_base
virtual void set_eof () {}
virtual DIR *opendir (path_conv& pc);
virtual dirent *readdir (DIR *);
- virtual off_t telldir (DIR *);
- virtual void seekdir (DIR *, off_t);
+ virtual __off32_t telldir (DIR *);
+ virtual void seekdir (DIR *, __off32_t);
virtual void rewinddir (DIR *);
virtual int closedir (DIR *);
};
@@ -382,7 +382,7 @@ class fhandler_socket: public fhandler_base
int ioctl (unsigned int cmd, void *);
int fcntl (int cmd, void *);
- off_t lseek (off_t, int) { return 0; }
+ __off32_t lseek (__off32_t, int) { return 0; }
int close ();
void hclose (HANDLE) {close ();}
int dup (fhandler_base *child);
@@ -417,7 +417,7 @@ class fhandler_pipe: public fhandler_base
unsigned id;
public:
fhandler_pipe (DWORD devtype);
- off_t lseek (off_t offset, int whence);
+ __off32_t lseek (__off32_t offset, int whence);
select_record *select_read (select_record *s);
select_record *select_write (select_record *s);
select_record *select_except (select_record *s);
@@ -489,7 +489,7 @@ class fhandler_dev_floppy: public fhandler_dev_raw
virtual int open (path_conv *, int flags, mode_t mode = 0);
virtual int close (void);
- virtual off_t lseek (off_t offset, int whence);
+ virtual __off32_t lseek (__off32_t offset, int whence);
virtual int ioctl (unsigned int cmd, void *buf);
};
@@ -512,7 +512,7 @@ class fhandler_dev_tape: public fhandler_dev_raw
int open (path_conv *, int flags, mode_t mode = 0);
int close (void);
- off_t lseek (off_t offset, int whence);
+ __off32_t lseek (__off32_t offset, int whence);
int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (3)));
@@ -548,15 +548,15 @@ class fhandler_disk_file: public fhandler_base
int __stdcall fstat (struct stat *buf, path_conv *pc) __attribute__ ((regparm (3)));
int __stdcall fstat_helper (struct stat *buf) __attribute__ ((regparm (2)));
- HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, off_t off);
+ HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, __off32_t off);
int munmap (HANDLE h, caddr_t addr, size_t len);
int msync (HANDLE h, caddr_t addr, size_t len, int flags);
BOOL fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
DWORD size, void *address);
DIR *opendir (path_conv& pc);
struct dirent *readdir (DIR *);
- off_t telldir (DIR *);
- void seekdir (DIR *, off_t);
+ __off32_t telldir (DIR *);
+ void seekdir (DIR *, __off32_t);
void rewinddir (DIR *);
int closedir (DIR *);
};
@@ -572,8 +572,8 @@ class fhandler_cygdrive: public fhandler_disk_file
fhandler_cygdrive (int unit);
DIR *opendir (path_conv& pc);
struct dirent *readdir (DIR *);
- off_t telldir (DIR *);
- void seekdir (DIR *, off_t);
+ __off32_t telldir (DIR *);
+ void seekdir (DIR *, __off32_t);
void rewinddir (DIR *);
int closedir (DIR *);
int __stdcall fstat (struct stat *buf, path_conv *pc) __attribute__ ((regparm (3)));
@@ -606,7 +606,7 @@ class fhandler_serial: public fhandler_base
int tcflow (int);
int tcsetattr (int a, const struct termios *t);
int tcgetattr (struct termios *t);
- off_t lseek (off_t, int) { return 0; }
+ __off32_t lseek (__off32_t, int) { return 0; }
int tcflush (int);
void dump ();
int is_tty () { return 1; }
@@ -837,7 +837,7 @@ class fhandler_tty_slave: public fhandler_tty_common
int tcflush (int);
int ioctl (unsigned int cmd, void *);
- off_t lseek (off_t, int) { return 0; }
+ __off32_t lseek (__off32_t, int) { return 0; }
select_record *select_read (select_record *s);
int ready_for_read (int fd, DWORD howlong);
};
@@ -864,7 +864,7 @@ class fhandler_pty_master: public fhandler_tty_common
int tcflush (int);
int ioctl (unsigned int cmd, void *);
- off_t lseek (off_t, int) { return 0; }
+ __off32_t lseek (__off32_t, int) { return 0; }
char *ptsname ();
void set_close_on_exec (int val);
@@ -903,7 +903,7 @@ class fhandler_dev_zero: public fhandler_base
int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
- off_t lseek (off_t offset, int whence);
+ __off32_t lseek (__off32_t offset, int whence);
int close (void);
void dump ();
@@ -926,7 +926,7 @@ class fhandler_dev_random: public fhandler_base
int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
- off_t lseek (off_t offset, int whence);
+ __off32_t lseek (__off32_t offset, int whence);
int close (void);
int dup (fhandler_base *child);
@@ -947,12 +947,12 @@ class fhandler_dev_mem: public fhandler_base
int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t ulen);
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
- off_t lseek (off_t offset, int whence);
+ __off32_t lseek (__off32_t offset, int whence);
int close (void);
int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (3)));
int dup (fhandler_base *child);
- HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, off_t off);
+ HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, __off32_t off);
int munmap (HANDLE h, caddr_t addr, size_t len);
int msync (HANDLE h, caddr_t addr, size_t len, int flags);
BOOL fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
@@ -969,7 +969,7 @@ class fhandler_dev_clipboard: public fhandler_base
int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
- off_t lseek (off_t offset, int whence);
+ __off32_t lseek (__off32_t offset, int whence);
int close (void);
int dup (fhandler_base *child);
@@ -977,7 +977,7 @@ class fhandler_dev_clipboard: public fhandler_base
void dump ();
private:
- off_t pos;
+ __off32_t pos;
void *membuffer;
size_t msize;
bool eof;
@@ -995,7 +995,7 @@ class fhandler_windows: public fhandler_base
int write (const void *ptr, size_t len);
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
int ioctl (unsigned int cmd, void *);
- off_t lseek (off_t, int) { return 0; }
+ __off32_t lseek (__off32_t, int) { return 0; }
int close (void) { return 0; }
void set_close_on_exec (int val);
@@ -1021,7 +1021,7 @@ class fhandler_dev_dsp : public fhandler_base
int write (const void *ptr, size_t len);
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
int ioctl (unsigned int cmd, void *);
- off_t lseek (off_t, int);
+ __off32_t lseek (__off32_t, int);
int close (void);
int dup (fhandler_base * child);
void dump (void);
diff --git a/winsup/cygwin/fhandler_clipboard.cc b/winsup/cygwin/fhandler_clipboard.cc
index 69065865a..348434ba6 100644
--- a/winsup/cygwin/fhandler_clipboard.cc
+++ b/winsup/cygwin/fhandler_clipboard.cc
@@ -246,8 +246,8 @@ fhandler_dev_clipboard::read (void *ptr, size_t len)
}
}
-off_t
-fhandler_dev_clipboard::lseek (off_t offset, int whence)
+__off32_t
+fhandler_dev_clipboard::lseek (__off32_t offset, int whence)
{
/* On reads we check this at read time, not seek time.
* On writes we use this to decide how to write - empty and write, or open, copy, empty
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index 18887844e..4f14aad33 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -65,8 +65,8 @@ fhandler_disk_file::fstat (struct stat *buf, path_conv *pc)
{
int res = -1;
int oret;
- uid_t uid;
- gid_t gid;
+ __uid16_t uid;
+ __gid16_t gid;
int open_flags = O_RDONLY | O_BINARY | O_DIROPEN;
if (!pc)
@@ -455,7 +455,7 @@ fhandler_disk_file::lock (int cmd, struct flock *fl)
startpos = 0;
break;
case SEEK_CUR:
- if ((off_t) (startpos = lseek (0, SEEK_CUR)) == (off_t)-1)
+ if ((__off32_t) (startpos = lseek (0, SEEK_CUR)) == ILLEGAL_SEEK)
return -1;
break;
case SEEK_END:
@@ -714,14 +714,14 @@ fhandler_disk_file::readdir (DIR *dir)
return res;
}
-off_t
+__off32_t
fhandler_disk_file::telldir (DIR *dir)
{
return dir->__d_position;
}
void
-fhandler_disk_file::seekdir (DIR *dir, off_t loc)
+fhandler_disk_file::seekdir (DIR *dir, __off32_t loc)
{
rewinddir (dir);
while (loc > dir->__d_position)
@@ -818,14 +818,14 @@ fhandler_cygdrive::readdir (DIR *dir)
return dir->__d_dirent;
}
-off_t
+__off32_t
fhandler_cygdrive::telldir (DIR *dir)
{
return fhandler_disk_file::telldir (dir);
}
void
-fhandler_cygdrive::seekdir (DIR *dir, off_t loc)
+fhandler_cygdrive::seekdir (DIR *dir, __off32_t loc)
{
if (!iscygdrive_root ())
return fhandler_disk_file::seekdir (dir, loc);
diff --git a/winsup/cygwin/fhandler_dsp.cc b/winsup/cygwin/fhandler_dsp.cc
index e380b3e46..22c595caf 100644
--- a/winsup/cygwin/fhandler_dsp.cc
+++ b/winsup/cygwin/fhandler_dsp.cc
@@ -482,8 +482,8 @@ fhandler_dev_dsp::read (void *ptr, size_t len)
return len;
}
-off_t
-fhandler_dev_dsp::lseek (off_t offset, int whence)
+__off32_t
+fhandler_dev_dsp::lseek (__off32_t offset, int whence)
{
return 0;
}
diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc
index 193e75a37..1df9f93f3 100644
--- a/winsup/cygwin/fhandler_floppy.cc
+++ b/winsup/cygwin/fhandler_floppy.cc
@@ -77,16 +77,16 @@ fhandler_dev_floppy::close (void)
return fhandler_dev_raw::close ();
}
-off_t
-fhandler_dev_floppy::lseek (off_t offset, int whence)
+__off32_t
+fhandler_dev_floppy::lseek (__off32_t offset, int whence)
{
int ret;
char buf[512];
long long drive_size = 0;
long long lloffset = offset;
long long current_position;
- off_t sector_aligned_offset;
- off_t bytes_left;
+ __off32_t sector_aligned_offset;
+ __off32_t bytes_left;
DWORD low;
LONG high = 0;
@@ -158,12 +158,12 @@ fhandler_dev_floppy::lseek (off_t offset, int whence)
}
high = lloffset >> 32;
low = lloffset & 0xffffffff;
- if (high || (off_t) low < 0)
+ if (high || (__off32_t) low < 0)
{
set_errno (EFBIG);
return -1;
}
- offset = (off_t) low;
+ offset = (__off32_t) low;
/* FIXME: sector can possibly be not 512 bytes long */
sector_aligned_offset = (offset / 512) * 512;
diff --git a/winsup/cygwin/fhandler_mem.cc b/winsup/cygwin/fhandler_mem.cc
index 14cdac0be..67ff8e0eb 100644
--- a/winsup/cygwin/fhandler_mem.cc
+++ b/winsup/cygwin/fhandler_mem.cc
@@ -231,8 +231,8 @@ fhandler_dev_mem::close (void)
return fhandler_base::close ();
}
-off_t
-fhandler_dev_mem::lseek (off_t offset, int whence)
+__off32_t
+fhandler_dev_mem::lseek (__off32_t offset, int whence)
{
switch (whence)
{
@@ -251,13 +251,13 @@ fhandler_dev_mem::lseek (off_t offset, int whence)
default:
set_errno (EINVAL);
- return (off_t) -1;
+ return ILLEGAL_SEEK;
}
if (pos > mem_size)
{
set_errno (EINVAL);
- return (off_t) -1;
+ return ILLEGAL_SEEK;
}
return pos;
@@ -265,7 +265,7 @@ fhandler_dev_mem::lseek (off_t offset, int whence)
HANDLE
fhandler_dev_mem::mmap (caddr_t *addr, size_t len, DWORD access,
- int flags, off_t off)
+ int flags, __off32_t off)
{
if ((DWORD) off >= mem_size
|| (DWORD) len >= mem_size
diff --git a/winsup/cygwin/fhandler_random.cc b/winsup/cygwin/fhandler_random.cc
index 8f43b600c..e6381c7bb 100644
--- a/winsup/cygwin/fhandler_random.cc
+++ b/winsup/cygwin/fhandler_random.cc
@@ -132,8 +132,8 @@ fhandler_dev_random::read (void *ptr, size_t len)
return -1;
}
-off_t
-fhandler_dev_random::lseek (off_t, int)
+__off32_t
+fhandler_dev_random::lseek (__off32_t, int)
{
return 0;
}
diff --git a/winsup/cygwin/fhandler_tape.cc b/winsup/cygwin/fhandler_tape.cc
index 558dc0bad..9803c772a 100644
--- a/winsup/cygwin/fhandler_tape.cc
+++ b/winsup/cygwin/fhandler_tape.cc
@@ -164,8 +164,8 @@ fhandler_dev_tape::fstat (struct stat *buf, path_conv *pc)
return ret;
}
-off_t
-fhandler_dev_tape::lseek (off_t offset, int whence)
+__off32_t
+fhandler_dev_tape::lseek (__off32_t offset, int whence)
{
struct mtop op;
struct mtpos pos;
@@ -179,7 +179,7 @@ fhandler_dev_tape::lseek (off_t offset, int whence)
if (ioctl (MTIOCPOS, &pos))
{
- return (off_t) -1;
+ return ILLEGAL_SEEK;
}
switch (whence)
diff --git a/winsup/cygwin/fhandler_zero.cc b/winsup/cygwin/fhandler_zero.cc
index 93b4544f3..3e4458493 100644
--- a/winsup/cygwin/fhandler_zero.cc
+++ b/winsup/cygwin/fhandler_zero.cc
@@ -41,8 +41,8 @@ fhandler_dev_zero::read (void *ptr, size_t len)
return len;
}
-off_t
-fhandler_dev_zero::lseek (off_t, int)
+__off32_t
+fhandler_dev_zero::lseek (__off32_t, int)
{
return 0;
}
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index 93af7063e..fdb524c29 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -32,7 +32,7 @@ details. */
on the first call that needs information from it. */
static NO_COPY const char *etc_group = "/etc/group";
-static struct group *group_buf; /* group contents in memory */
+static struct __group16 *group_buf; /* group contents in memory */
static int curr_lines;
static int max_lines;
@@ -46,7 +46,7 @@ static int grp_pos = 0;
static pwdgrp_check group_state;
static int
-parse_grp (struct group &grp, const char *line)
+parse_grp (struct __group16 &grp, const char *line)
{
int len = strlen(line);
char *newline = (char *) malloc (len + 1);
@@ -111,7 +111,7 @@ add_grp_line (const char *line)
if (curr_lines == max_lines)
{
max_lines += 10;
- group_buf = (struct group *) realloc (group_buf, max_lines * sizeof (struct group));
+ group_buf = (struct __group16 *) realloc (group_buf, max_lines * sizeof (struct __group16));
}
if (parse_grp (group_buf[curr_lines], line))
curr_lines++;
@@ -208,10 +208,10 @@ read_etc_group ()
}
extern "C"
-struct group *
-getgrgid (gid_t gid)
+struct __group16 *
+getgrgid (__gid16_t gid)
{
- struct group * default_grp = NULL;
+ struct __group16 * default_grp = NULL;
if (group_state <= initializing)
read_etc_group();
@@ -227,7 +227,7 @@ getgrgid (gid_t gid)
}
extern "C"
-struct group *
+struct __group16 *
getgrnam (const char *name)
{
if (group_state <= initializing)
@@ -249,7 +249,7 @@ endgrent()
}
extern "C"
-struct group *
+struct __group16 *
getgrent()
{
if (group_state <= initializing)
@@ -269,7 +269,7 @@ setgrent ()
}
/* Internal function. ONLY USE THIS INTERNALLY, NEVER `getgrent'!!! */
-struct group *
+struct __group16 *
internal_getgrent (int pos)
{
if (group_state <= initializing)
@@ -281,12 +281,12 @@ internal_getgrent (int pos)
}
int
-getgroups (int gidsetsize, gid_t *grouplist, gid_t gid, const char *username)
+getgroups (int gidsetsize, __gid16_t *grouplist, __gid16_t gid, const char *username)
{
HANDLE hToken = NULL;
DWORD size;
int cnt = 0;
- struct group *gr;
+ struct __group16 *gr;
if (group_state <= initializing)
read_etc_group();
@@ -356,14 +356,14 @@ error:
extern "C"
int
-getgroups (int gidsetsize, gid_t *grouplist)
+getgroups (int gidsetsize, __gid16_t *grouplist)
{
return getgroups (gidsetsize, grouplist, myself->gid, cygheap->user.name ());
}
extern "C"
int
-initgroups (const char *, gid_t)
+initgroups (const char *, __gid16_t)
{
return 0;
}
diff --git a/winsup/cygwin/include/cygwin/acl.h b/winsup/cygwin/include/cygwin/acl.h
index 3248b2e68..15d4b5c6c 100644
--- a/winsup/cygwin/include/cygwin/acl.h
+++ b/winsup/cygwin/include/cygwin/acl.h
@@ -58,12 +58,27 @@ extern "C" {
#define MASK CLASS_OBJ
#define OTHER OTHER_OBJ
-typedef struct acl {
- int a_type; /* entry type */
- uid_t a_id; /* UID | GID */
- mode_t a_perm; /* permissions */
-} aclent_t;
+#ifdef __INSIDE_CYGWIN__
+typedef struct __acl16 {
+ int a_type; /* entry type */
+ __uid16_t a_id; /* UID | GID */
+ mode_t a_perm; /* permissions */
+} __aclent16_t;
+typedef struct __acl32 {
+ int a_type; /* entry type */
+ __uid32_t a_id; /* UID | GID */
+ mode_t a_perm; /* permissions */
+} __aclent32_t;
+#endif
+
+typedef struct __acl {
+ int a_type; /* entry type */
+ uid_t a_id; /* UID | GID */
+ mode_t a_perm; /* permissions */
+} __aclent_t;
+
+#ifndef __INSIDE_CYGWIN__
int _EXFUN(acl,(const char *path, int cmd, int nentries, aclent_t *aclbufp));
int _EXFUN(lacl,(const char *path, int cmd, int nentries, aclent_t *aclbufp));
int _EXFUN(facl,(int fd, int cmd, int nentries, aclent_t *aclbufp));
@@ -75,6 +90,7 @@ int _EXFUN(acltopbits,(aclent_t *aclbufp, int nentries, mode_t *pbitsp));
int _EXFUN(aclfrompbits,(aclent_t *aclbufp, int nentries, mode_t *pbitsp));
char *_EXFUN(acltotext,(aclent_t *aclbufp, int aclcnt));
aclent_t *_EXFUN(aclfromtext,(char *acltextp, int *aclcnt));
+#endif
#ifdef __cplusplus
}
diff --git a/winsup/cygwin/include/cygwin/grp.h b/winsup/cygwin/include/cygwin/grp.h
index 79b4bccff..3a58e2058 100644
--- a/winsup/cygwin/include/cygwin/grp.h
+++ b/winsup/cygwin/include/cygwin/grp.h
@@ -34,6 +34,9 @@ struct __group32
__gid32_t gr_gid;
char **gr_mem;
};
+
+struct __group16 * getgrgid (__gid16_t gid);
+struct __group16 * getgrnam (const char *name);
#endif
#ifdef __cplusplus
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index 884941ae4..e30d8fd37 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -256,7 +256,7 @@ public:
mmap_record *add_record (mmap_record r);
void erase (int i);
mmap_record *match (DWORD off, DWORD len);
- off_t match (caddr_t addr, DWORD len, off_t start);
+ __off32_t match (caddr_t addr, DWORD len, __off32_t start);
};
list::list ()
@@ -307,14 +307,14 @@ list::match (DWORD off, DWORD len)
}
/* Used in munmap() */
-off_t
-list::match (caddr_t addr, DWORD len, off_t start)
+__off32_t
+list::match (caddr_t addr, DWORD len, __off32_t start)
{
for (int i = start + 1; i < nrecs; ++i)
if (addr >= recs[i].get_address ()
&& addr + len <= recs[i].get_address () + recs[i].get_size ())
return i;
- return (off_t)-1;
+ return ILLEGAL_SEEK;
}
void
@@ -400,7 +400,7 @@ static map *mmapped_areas;
extern "C"
caddr_t
-mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
+mmap (caddr_t addr, size_t len, int prot, int flags, int fd, __off32_t off)
{
syscall_printf ("addr %x, len %d, prot %x, flags %x, fd %d, off %d",
addr, len, prot, flags, fd, off);
@@ -589,7 +589,7 @@ munmap (caddr_t addr, size_t len)
list *l = mmapped_areas->lists[it];
if (l)
{
- off_t li = -1;
+ __off32_t li = ILLEGAL_SEEK;
if ((li = l->match(addr, len, li)) >= 0)
{
mmap_record *rec = l->recs + li;
@@ -695,7 +695,7 @@ msync (caddr_t addr, size_t len, int flags)
*/
HANDLE
fhandler_base::mmap (caddr_t *addr, size_t len, DWORD access,
- int flags, off_t off)
+ int flags, __off32_t off)
{
set_errno (ENODEV);
return INVALID_HANDLE_VALUE;
@@ -726,7 +726,7 @@ fhandler_base::fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
/* Implementation for disk files. */
HANDLE
fhandler_disk_file::mmap (caddr_t *addr, size_t len, DWORD access,
- int flags, off_t off)
+ int flags, __off32_t off)
{
DWORD protect;
diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc
index c18ee1601..7fe2ade22 100644
--- a/winsup/cygwin/passwd.cc
+++ b/winsup/cygwin/passwd.cc
@@ -183,7 +183,7 @@ read_etc_passwd ()
/* Cygwin internal */
/* If this ever becomes non-reentrant, update all the getpw*_r functions */
static struct passwd *
-search_for (uid_t uid, const char *name)
+search_for (__uid16_t uid, const char *name)
{
struct passwd *res = 0;
struct passwd *default_pw = 0;
@@ -214,7 +214,7 @@ search_for (uid_t uid, const char *name)
}
extern "C" struct passwd *
-getpwuid (uid_t uid)
+getpwuid (__uid16_t uid)
{
if (passwd_state <= initializing)
read_etc_passwd ();
@@ -225,7 +225,7 @@ getpwuid (uid_t uid)
}
extern "C" int
-getpwuid_r (uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)
+getpwuid_r (__uid16_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)
{
*result = NULL;
@@ -337,7 +337,7 @@ getpwent (void)
}
extern "C" struct passwd *
-getpwduid (uid_t)
+getpwduid (__uid16_t)
{
return NULL;
}
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index fb6f2fd41..a766b8793 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -87,7 +87,7 @@ pinfo_init (char **envp, int envc)
myself->ppid = 1;
myself->pgid = myself->sid = myself->pid;
myself->ctty = -1;
- myself->uid = USHRT_MAX;
+ myself->uid = ILLEGAL_UID;
environ_init (NULL, 0); /* call after myself has been set up */
}
diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h
index 950f2c272..86f46d98a 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. */
- uid_t uid; /* User ID */
- gid_t gid; /* Group ID */
+ __uid16_t uid; /* User ID */
+ __gid16_t gid; /* Group ID */
pid_t pgid; /* Process group ID */
pid_t sid; /* Session ID */
int ctty; /* Control tty */
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index 6e5266d7c..aa0ba798e 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -31,8 +31,8 @@ fhandler_pipe::fhandler_pipe (DWORD devtype)
{
}
-off_t
-fhandler_pipe::lseek (off_t offset, int whence)
+__off32_t
+fhandler_pipe::lseek (__off32_t offset, int whence)
{
debug_printf ("(%d, %d)", offset, whence);
set_errno (ESPIPE);
diff --git a/winsup/cygwin/sec_acl.cc b/winsup/cygwin/sec_acl.cc
index 3a806d05e..7e4d22bce 100644
--- a/winsup/cygwin/sec_acl.cc
+++ b/winsup/cygwin/sec_acl.cc
@@ -34,8 +34,11 @@ details. */
#include "pinfo.h"
#include "cygheap.h"
+extern "C" int aclsort (int nentries, int, __aclent16_t *aclbufp);
+extern "C" int acl (const char *path, int cmd, int nentries, __aclent16_t *aclbufp);
+
static int
-searchace (aclent_t *aclp, int nentries, int type, int id = -1)
+searchace (__aclent16_t *aclp, int nentries, int type, int id = -1)
{
int i;
@@ -47,7 +50,7 @@ searchace (aclent_t *aclp, int nentries, int type, int id = -1)
}
static int
-setacl (const char *file, int nentries, aclent_t *aclbufp)
+setacl (const char *file, int nentries, __aclent16_t *aclbufp)
{
DWORD sd_size = 4096;
char sd_buf[4096];
@@ -106,7 +109,7 @@ setacl (const char *file, int nentries, aclent_t *aclbufp)
cygsid sid;
struct passwd *pw;
- struct group *gr;
+ struct __group16 *gr;
int pos;
if (!InitializeAcl (acl, 3072, ACL_REVISION))
@@ -213,7 +216,7 @@ setacl (const char *file, int nentries, aclent_t *aclbufp)
}
static void
-getace (aclent_t &acl, int type, int id, DWORD win_ace_mask, DWORD win_ace_type)
+getace (__aclent16_t &acl, int type, int id, DWORD win_ace_mask, DWORD win_ace_type)
{
acl.a_type = type;
acl.a_id = id;
@@ -238,7 +241,7 @@ getace (aclent_t &acl, int type, int id, DWORD win_ace_mask, DWORD win_ace_type)
}
static int
-getacl (const char *file, DWORD attr, int nentries, aclent_t *aclbufp)
+getacl (const char *file, DWORD attr, int nentries, __aclent16_t *aclbufp)
{
DWORD sd_size = 4096;
char sd_buf[4096];
@@ -254,8 +257,8 @@ getacl (const char *file, DWORD attr, int nentries, aclent_t *aclbufp)
PSID owner_sid;
PSID group_sid;
BOOL dummy;
- uid_t uid;
- gid_t gid;
+ __uid16_t uid;
+ __gid16_t gid;
if (!GetSecurityDescriptorOwner (psd, &owner_sid, &dummy))
{
@@ -273,8 +276,8 @@ getacl (const char *file, DWORD attr, int nentries, aclent_t *aclbufp)
}
gid = cygsid (group_sid).get_gid ();
- aclent_t lacl[MAX_ACL_ENTRIES];
- memset (&lacl, 0, MAX_ACL_ENTRIES * sizeof (aclent_t));
+ __aclent16_t lacl[MAX_ACL_ENTRIES];
+ memset (&lacl, 0, MAX_ACL_ENTRIES * sizeof (__aclent16_t));
lacl[0].a_type = USER_OBJ;
lacl[0].a_id = uid;
lacl[1].a_type = GROUP_OBJ;
@@ -298,7 +301,7 @@ getacl (const char *file, DWORD attr, int nentries, aclent_t *aclbufp)
for (pos = 0; pos < MIN_ACL_ENTRIES; ++pos)
lacl[pos].a_perm = S_IRWXU | S_IRWXG | S_IRWXO;
pos = nentries < MIN_ACL_ENTRIES ? nentries : MIN_ACL_ENTRIES;
- memcpy (aclbufp, lacl, pos * sizeof (aclent_t));
+ memcpy (aclbufp, lacl, pos * sizeof (__aclent16_t));
return pos;
}
@@ -389,7 +392,7 @@ getacl (const char *file, DWORD attr, int nentries, aclent_t *aclbufp)
if (pos > nentries)
pos = nentries;
if (aclbufp)
- memcpy (aclbufp, lacl, pos * sizeof (aclent_t));
+ memcpy (aclbufp, lacl, pos * sizeof (__aclent16_t));
aclsort (pos, 0, aclbufp);
syscall_printf ("%d = getacl (%s)", pos, file);
return pos;
@@ -398,7 +401,7 @@ getacl (const char *file, DWORD attr, int nentries, aclent_t *aclbufp)
int
acl_access (const char *path, int flags)
{
- aclent_t acls[MAX_ACL_ENTRIES];
+ __aclent16_t acls[MAX_ACL_ENTRIES];
int cnt;
if ((cnt = acl (path, GETACL, MAX_ACL_ENTRIES, acls)) < 1)
@@ -423,7 +426,7 @@ acl_access (const char *path, int flags)
cygsid owner;
cygsid group;
struct passwd *pw;
- struct group *gr = NULL;
+ struct __group16 *gr = NULL;
if ((pw = getpwuid (acls[i].a_id)) != NULL
&& owner.getfrompw (pw))
@@ -460,7 +463,7 @@ acl_access (const char *path, int flags)
static
int
-acl_worker (const char *path, int cmd, int nentries, aclent_t *aclbufp,
+acl_worker (const char *path, int cmd, int nentries, __aclent16_t *aclbufp,
int nofollow)
{
extern suffix_info stat_suffixes[];
@@ -487,7 +490,7 @@ acl_worker (const char *path, int cmd, int nentries, aclent_t *aclbufp,
else if ((nofollow && !lstat (path, &st))
|| (!nofollow && !stat (path, &st)))
{
- aclent_t lacl[4];
+ __aclent16_t lacl[4];
if (nentries > 0)
{
lacl[0].a_type = USER_OBJ;
@@ -523,7 +526,7 @@ acl_worker (const char *path, int cmd, int nentries, aclent_t *aclbufp,
if (nentries > 4)
nentries = 4;
if (aclbufp)
- memcpy (aclbufp, lacl, nentries * sizeof (aclent_t));
+ memcpy (aclbufp, lacl, nentries * sizeof (__aclent16_t));
ret = nentries;
}
break;
@@ -561,21 +564,21 @@ acl_worker (const char *path, int cmd, int nentries, aclent_t *aclbufp,
extern "C"
int
-acl (const char *path, int cmd, int nentries, aclent_t *aclbufp)
+acl (const char *path, int cmd, int nentries, __aclent16_t *aclbufp)
{
return acl_worker (path, cmd, nentries, aclbufp, 0);
}
extern "C"
int
-lacl (const char *path, int cmd, int nentries, aclent_t *aclbufp)
+lacl (const char *path, int cmd, int nentries, __aclent16_t *aclbufp)
{
return acl_worker (path, cmd, nentries, aclbufp, 1);
}
extern "C"
int
-facl (int fd, int cmd, int nentries, aclent_t *aclbufp)
+facl (int fd, int cmd, int nentries, __aclent16_t *aclbufp)
{
cygheap_fdget cfd (fd);
if (cfd < 0)
@@ -596,7 +599,7 @@ facl (int fd, int cmd, int nentries, aclent_t *aclbufp)
extern "C"
int
-aclcheck (aclent_t *aclbufp, int nentries, int *which)
+aclcheck (__aclent16_t *aclbufp, int nentries, int *which)
{
BOOL has_user_obj = FALSE;
BOOL has_group_obj = FALSE;
@@ -730,7 +733,7 @@ aclcheck (aclent_t *aclbufp, int nentries, int *which)
extern "C"
int acecmp (const void *a1, const void *a2)
{
-#define ace(i) ((const aclent_t *) a##i)
+#define ace(i) ((const __aclent16_t *) a##i)
int ret = ace(1)->a_type - ace(2)->a_type;
if (!ret)
ret = ace(1)->a_id - ace(2)->a_id;
@@ -740,7 +743,7 @@ int acecmp (const void *a1, const void *a2)
extern "C"
int
-aclsort (int nentries, int, aclent_t *aclbufp)
+aclsort (int nentries, int, __aclent16_t *aclbufp)
{
if (aclcheck (aclbufp, nentries, NULL))
return -1;
@@ -749,13 +752,13 @@ aclsort (int nentries, int, aclent_t *aclbufp)
set_errno (EINVAL);
return -1;
}
- qsort((void *) aclbufp, nentries, sizeof (aclent_t), acecmp);
+ qsort((void *) aclbufp, nentries, sizeof (__aclent16_t), acecmp);
return 0;
}
extern "C"
int
-acltomode (aclent_t *aclbufp, int nentries, mode_t *modep)
+acltomode (__aclent16_t *aclbufp, int nentries, mode_t *modep)
{
int pos;
@@ -790,7 +793,7 @@ acltomode (aclent_t *aclbufp, int nentries, mode_t *modep)
extern "C"
int
-aclfrommode(aclent_t *aclbufp, int nentries, mode_t *modep)
+aclfrommode(__aclent16_t *aclbufp, int nentries, mode_t *modep)
{
int pos;
@@ -830,14 +833,14 @@ aclfrommode(aclent_t *aclbufp, int nentries, mode_t *modep)
extern "C"
int
-acltopbits (aclent_t *aclbufp, int nentries, mode_t *pbitsp)
+acltopbits (__aclent16_t *aclbufp, int nentries, mode_t *pbitsp)
{
return acltomode (aclbufp, nentries, pbitsp);
}
extern "C"
int
-aclfrompbits (aclent_t *aclbufp, int nentries, mode_t *pbitsp)
+aclfrompbits (__aclent16_t *aclbufp, int nentries, mode_t *pbitsp)
{
return aclfrommode (aclbufp, nentries, pbitsp);
}
@@ -856,7 +859,7 @@ permtostr (mode_t perm)
extern "C"
char *
-acltotext (aclent_t *aclbufp, int aclcnt)
+acltotext (__aclent16_t *aclbufp, int aclcnt)
{
if (!aclbufp || aclcnt < 1 || aclcnt > MAX_ACL_ENTRIES
|| aclcheck (aclbufp, aclcnt, NULL))
@@ -932,7 +935,7 @@ permfromstr (char *perm)
}
extern "C"
-aclent_t *
+__aclent16_t *
aclfromtext (char *acltextp, int *)
{
if (!acltextp)
@@ -941,7 +944,7 @@ aclfromtext (char *acltextp, int *)
return NULL;
}
char buf[strlen (acltextp) + 1];
- aclent_t lacl[MAX_ACL_ENTRIES];
+ __aclent16_t lacl[MAX_ACL_ENTRIES];
memset (lacl, 0, sizeof lacl);
int pos = 0;
strcpy (buf, acltextp);
@@ -993,7 +996,7 @@ aclfromtext (char *acltextp, int *)
c += 5;
if (isalpha (*c))
{
- struct group *gr = getgrnam (c);
+ struct __group16 *gr = getgrnam (c);
if (!gr)
{
set_errno (EINVAL);
@@ -1038,9 +1041,9 @@ aclfromtext (char *acltextp, int *)
}
++pos;
}
- aclent_t *aclp = (aclent_t *) malloc (pos * sizeof (aclent_t));
+ __aclent16_t *aclp = (__aclent16_t *) malloc (pos * sizeof (__aclent16_t));
if (aclp)
- memcpy (aclp, lacl, pos * sizeof (aclent_t));
+ memcpy (aclp, lacl, pos * sizeof (__aclent16_t));
return aclp;
}
diff --git a/winsup/cygwin/sec_helper.cc b/winsup/cygwin/sec_helper.cc
index b618cf32d..33d909a32 100644
--- a/winsup/cygwin/sec_helper.cc
+++ b/winsup/cygwin/sec_helper.cc
@@ -129,7 +129,7 @@ cygsid::getfrompw (const struct passwd *pw)
}
BOOL
-cygsid::getfromgr (const struct group *gr)
+cygsid::getfromgr (const struct __group16 *gr)
{
char *sp = (gr && gr->gr_passwd) ? gr->gr_passwd : NULL;
return (*this = sp ?: "") != NULL;
@@ -176,7 +176,7 @@ cygsid::get_id (BOOL search_grp, int *type)
}
if (search_grp || type)
{
- struct group *gr;
+ struct __group16 *gr;
for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx)
{
if (sid.getfromgr (gr) && sid == psid)
@@ -226,7 +226,7 @@ cygsid::get_id (BOOL search_grp, int *type)
*type = GROUP;
if (id == -1)
{
- struct group *gr = getgrnam (account);
+ struct __group16 *gr = getgrnam (account);
if (gr)
id = gr->gr_gid;
}
@@ -251,13 +251,13 @@ cygsid::get_id (BOOL search_grp, int *type)
}
BOOL
-is_grp_member (uid_t uid, gid_t gid)
+is_grp_member (__uid16_t uid, __gid16_t gid)
{
- extern int getgroups (int, gid_t *, gid_t, const char *);
+ extern int getgroups (int, __gid16_t *, __gid16_t, const char *);
BOOL grp_member = TRUE;
struct passwd *pw = getpwuid (uid);
- gid_t grps[NGROUPS_MAX];
+ __gid16_t grps[NGROUPS_MAX];
int cnt = getgroups (NGROUPS_MAX, grps,
pw ? pw->pw_gid : myself->gid,
pw ? pw->pw_name : cygheap->user.name ());
diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc
index 82daa13f8..73ee73fd3 100644
--- a/winsup/cygwin/security.cc
+++ b/winsup/cygwin/security.cc
@@ -42,7 +42,6 @@ details. */
#include "ntdll.h"
#include "lm.h"
-
extern BOOL allow_ntea;
BOOL allow_ntsec;
/* allow_smbntsec is handled exclusively in path.cc (path_conv::check).
@@ -451,7 +450,7 @@ get_user_primary_group (WCHAR *wlogonserver, const char *user,
static int
get_supplementary_group_sidlist (const char *username, cygsidlist &grp_list)
{
- struct group *gr;
+ struct __group16 *gr;
int cnt = 0;
for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx)
@@ -1086,7 +1085,7 @@ write_sd(const char *file, PSECURITY_DESCRIPTOR sd_buf, DWORD sd_size)
static int
get_nt_attribute (const char *file, int *attribute,
- uid_t *uidret, gid_t *gidret)
+ __uid16_t *uidret, __gid16_t *gidret)
{
if (!wincap.has_security ())
return 0;
@@ -1124,8 +1123,8 @@ get_nt_attribute (const char *file, int *attribute,
return -1;
}
- uid_t uid = cygsid(owner_sid).get_uid ();
- gid_t gid = cygsid(group_sid).get_gid ();
+ __uid16_t uid = cygsid(owner_sid).get_uid ();
+ __gid16_t gid = cygsid(group_sid).get_gid ();
if (uidret)
*uidret = uid;
if (gidret)
@@ -1235,7 +1234,7 @@ get_nt_attribute (const char *file, int *attribute,
int
get_file_attribute (int use_ntsec, const char *file,
- int *attribute, uid_t *uidret, gid_t *gidret)
+ int *attribute, __uid16_t *uidret, __gid16_t *gidret)
{
int res;
@@ -1306,7 +1305,7 @@ add_access_denied_ace (PACL acl, int offset, DWORD attributes,
}
PSECURITY_DESCRIPTOR
-alloc_sd (uid_t uid, gid_t gid, const char *logsrv, int attribute,
+alloc_sd (__uid16_t uid, __gid16_t gid, const char *logsrv, int attribute,
PSECURITY_DESCRIPTOR sd_ret, DWORD *sd_size_ret)
{
BOOL dummy;
@@ -1334,7 +1333,7 @@ alloc_sd (uid_t uid, gid_t gid, const char *logsrv, int attribute,
/* Get SID and name of new group. */
cygsid group_sid (NO_SID);
- struct group *grp = getgrgid (gid);
+ struct __group16 *grp = getgrgid (gid);
if (grp)
{
if ((!grp || !group_sid.getfromgr (grp))
@@ -1575,7 +1574,7 @@ set_security_attribute (int attribute, PSECURITY_ATTRIBUTES psa,
}
static int
-set_nt_attribute (const char *file, uid_t uid, gid_t gid,
+set_nt_attribute (const char *file, __uid16_t uid, __gid16_t gid,
const char *logsrv, int attribute)
{
if (!wincap.has_security ())
@@ -1601,7 +1600,7 @@ set_nt_attribute (const char *file, uid_t uid, gid_t gid,
int
set_file_attribute (int use_ntsec, const char *file,
- uid_t uid, gid_t gid,
+ __uid16_t uid, __gid16_t gid,
int attribute, const char *logsrv)
{
int ret = 0;
diff --git a/winsup/cygwin/security.h b/winsup/cygwin/security.h
index 53c94c8f9..c4b59dc23 100644
--- a/winsup/cygwin/security.h
+++ b/winsup/cygwin/security.h
@@ -55,7 +55,7 @@ public:
inline PSID set () { return psid = (PSID) sbuf; }
BOOL getfrompw (const struct passwd *pw);
- BOOL getfromgr (const struct group *gr);
+ BOOL getfromgr (const struct __group16 *gr);
int get_id (BOOL search_grp, int *type = NULL);
inline int get_uid () { return get_id (FALSE); }
@@ -159,14 +159,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 group *internal_getgrent (int);
+extern struct __group16 *internal_getgrent (int);
/* File manipulation */
int __stdcall set_process_privileges ();
int __stdcall get_file_attribute (int, const char *, int *,
- uid_t * = NULL, gid_t * = NULL);
+ __uid16_t * = NULL, __gid16_t * = NULL);
int __stdcall set_file_attribute (int, const char *, int);
-int __stdcall set_file_attribute (int, const char *, uid_t, gid_t, int, const char *);
+int __stdcall set_file_attribute (int, const char *, __uid16_t, __gid16_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);
@@ -186,7 +186,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 (uid_t uid, gid_t gid);
+BOOL __stdcall is_grp_member (__uid16_t uid, __gid16_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! */
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 887e69b3e..1818d0ac7 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -682,7 +682,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
char wstname[1024];
char dskname[1024];
- ciresrv.moreinfo->uid = USHRT_MAX;
+ 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 a8b2eb2e3..743dcbcbe 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -527,10 +527,10 @@ _open (const char *unix_path, int flags, ...)
return res;
}
-extern "C" off_t
-_lseek (int fd, off_t pos, int dir)
+extern "C" __off32_t
+_lseek (int fd, __off32_t pos, int dir)
{
- off_t res;
+ __off32_t res;
sigframe thisframe (mainthread);
if (dir != SEEK_SET && dir != SEEK_CUR && dir != SEEK_END)
@@ -744,11 +744,11 @@ done:
* systems, it is only a stub that always returns zero.
*/
static int
-chown_worker (const char *name, unsigned fmode, uid_t uid, gid_t gid)
+chown_worker (const char *name, unsigned fmode, __uid16_t uid, __gid16_t gid)
{
int res;
- uid_t old_uid;
- gid_t old_gid;
+ __uid16_t old_uid;
+ __gid16_t old_gid;
if (check_null_empty_str_errno (name))
return -1;
@@ -785,9 +785,9 @@ chown_worker (const char *name, unsigned fmode, uid_t uid, gid_t gid)
&old_gid);
if (!res)
{
- if (uid == (uid_t) -1)
+ if (uid == ILLEGAL_UID)
uid = old_uid;
- if (gid == (gid_t) -1)
+ if (gid == ILLEGAL_GID)
gid = old_gid;
if (win32_path.isdir())
attrib |= S_IFDIR;
@@ -809,21 +809,21 @@ done:
}
extern "C" int
-chown (const char * name, uid_t uid, gid_t gid)
+chown (const char * name, __uid16_t uid, __gid16_t gid)
{
sigframe thisframe (mainthread);
return chown_worker (name, PC_SYM_FOLLOW, uid, gid);
}
extern "C" int
-lchown (const char * name, uid_t uid, gid_t gid)
+lchown (const char * name, __uid16_t uid, __gid16_t gid)
{
sigframe thisframe (mainthread);
return chown_worker (name, PC_SYM_NOFOLLOW, uid, gid);
}
extern "C" int
-fchown (int fd, uid_t uid, gid_t gid)
+fchown (int fd, __uid16_t uid, __gid16_t gid)
{
sigframe thisframe (mainthread);
cygheap_fdget cfd (fd);
@@ -888,8 +888,8 @@ chmod (const char *path, mode_t mode)
/* temporary erase read only bit, to be able to set file security */
SetFileAttributes (win32_path, (DWORD) win32_path & ~FILE_ATTRIBUTE_READONLY);
- uid_t uid;
- gid_t gid;
+ __uid16_t uid;
+ __gid16_t gid;
if (win32_path.isdir ())
mode |= S_IFDIR;
@@ -1609,7 +1609,7 @@ setmode (int fd, int mode)
/* ftruncate: P96 5.6.7.1 */
extern "C" int
-ftruncate (int fd, off_t length)
+ftruncate (int fd, __off32_t length)
{
sigframe thisframe (mainthread);
int res = -1;
@@ -1626,7 +1626,7 @@ ftruncate (int fd, off_t length)
if (cfd->get_handle ())
{
/* remember curr file pointer location */
- off_t prev_loc = cfd->lseek (0, SEEK_CUR);
+ __off32_t prev_loc = cfd->lseek (0, SEEK_CUR);
cfd->lseek (length, SEEK_SET);
if (!SetEndOfFile (h))
@@ -1646,7 +1646,7 @@ ftruncate (int fd, off_t length)
/* truncate: Provided by SVR4 and 4.3+BSD. Not part of POSIX.1 or XPG3 */
extern "C" int
-truncate (const char *pathname, off_t length)
+truncate (const char *pathname, __off32_t length)
{
sigframe thisframe (mainthread);
int fd;
@@ -1844,7 +1844,7 @@ mkfifo (const char *_path, mode_t mode)
/* setgid: POSIX 4.2.2.1 */
extern "C" int
-setgid (gid_t gid)
+setgid (__gid16_t gid)
{
int ret = setegid (gid);
if (!ret)
@@ -1854,7 +1854,7 @@ setgid (gid_t gid)
/* setuid: POSIX 4.2.2.1 */
extern "C" int
-setuid (uid_t uid)
+setuid (__uid16_t uid)
{
int ret = seteuid (uid);
if (!ret)
@@ -1867,7 +1867,7 @@ extern struct passwd *internal_getlogin (cygheap_user &user);
/* seteuid: standards? */
extern "C" int
-seteuid (uid_t uid)
+seteuid (__uid16_t uid)
{
sigframe thisframe (mainthread);
if (wincap.has_security ())
@@ -1880,7 +1880,7 @@ seteuid (uid_t uid)
DWORD dlen = INTERNET_MAX_HOST_NAME_LENGTH + 1;
SID_NAME_USE use;
- if (uid == (uid_t) -1 || uid == myself->uid)
+ if (uid == ILLEGAL_UID || uid == myself->uid)
{
debug_printf ("new euid == current euid, nothing happens");
return 0;
@@ -1935,7 +1935,7 @@ seteuid (uid_t uid)
BOOL current_token_is_internal_token = FALSE;
BOOL explicitely_created_token = FALSE;
- struct group *gr = getgrgid (myself->gid);
+ struct __group16 *gr = getgrgid (myself->gid);
debug_printf ("myself->gid: %d, gr: %d", myself->gid, gr);
usersid.getfrompw (pw_new);
@@ -2087,14 +2087,14 @@ seteuid (uid_t uid)
/* setegid: from System V. */
extern "C" int
-setegid (gid_t gid)
+setegid (__gid16_t gid)
{
sigframe thisframe (mainthread);
if (wincap.has_security ())
{
- if (gid != (gid_t) -1)
+ if (gid != ILLEGAL_GID)
{
- struct group *gr;
+ struct __group16 *gr;
if (!(gr = getgrgid (gid)))
{
@@ -2377,7 +2377,7 @@ logout (char *line)
{
struct utmp *ut;
struct utmp ut_buf[100];
- off_t pos = 0; /* Position in file */
+ __off32_t pos = 0; /* Position in file */
DWORD rd;
while (!res && ReadFile (ut_fd, ut_buf, sizeof ut_buf, &rd, NULL)
diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h
index 23aaa6860..7acfa26c5 100644
--- a/winsup/cygwin/thread.h
+++ b/winsup/cygwin/thread.h
@@ -54,7 +54,7 @@ struct _winsup_t
/*
Needed for the group functions
*/
- struct group _grp;
+ struct __group16 _grp;
char *_namearray[2];
int _grp_pos;
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index db2be6bf2..5fb2c0e14 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -174,7 +174,7 @@ internal_getlogin (cygheap_user &user)
if (psid.getfrompw (pw) && EqualSid (user.sid (), psid))
{
user.set_name (pw->pw_name);
- struct group *gr = getgrgid (pw->pw_gid);
+ struct __group16 *gr = getgrgid (pw->pw_gid);
if (gr)
if (!gsid.getfromgr (gr))
gsid = NO_SID;
@@ -249,9 +249,9 @@ uinfo_init ()
cygheap->user.token = INVALID_HANDLE_VALUE;
cygheap->user.impersonated = TRUE;
- /* If uid is USHRT_MAX, the process is started from a non cygwin
+ /* If uid is ILLEGAL_UID, the process is started from a non cygwin
process or the user context was changed in spawn.cc */
- if (myself->uid == USHRT_MAX)
+ if (myself->uid == ILLEGAL_UID)
if ((p = internal_getlogin (cygheap->user)) != NULL)
{
myself->uid = p->pw_uid;
@@ -283,25 +283,25 @@ getlogin (void)
return strcpy (this_username, cygheap->user.name ());
}
-extern "C" uid_t
+extern "C" __uid16_t
getuid (void)
{
return cygheap->user.real_uid;
}
-extern "C" gid_t
+extern "C" __gid16_t
getgid (void)
{
return cygheap->user.real_gid;
}
-extern "C" uid_t
+extern "C" __uid16_t
geteuid (void)
{
return myself->uid;
}
-extern "C" gid_t
+extern "C" __gid16_t
getegid (void)
{
return myself->gid;
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index dcf7bff27..bf7315413 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -145,6 +145,10 @@ extern "C" void __stdcall do_exit (int) __attribute__ ((noreturn));
/* UID/GID */
void uinfo_init (void);
+#define ILLEGAL_UID ((__uid16_t)-1)
+#define ILLEGAL_GID ((__gid16_t)-1)
+#define ILLEGAL_SEEK ((__off32_t)-1)
+
/* various events */
void events_init (void);
void events_terminate (void);