aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2001-03-19 11:02:41 +0000
committerCorinna Vinschen <corinna@vinschen.de>2001-03-19 11:02:41 +0000
commit30f326bf5ee75e4b1609796afadf9f99ccd290b4 (patch)
treec998ad7436d734b3e9fc34a2e463c975ab6694cb
parentc7ee75cd2e3e59d920c2539e70ce65358568f6fc (diff)
downloadnewlib-30f326bf5ee75e4b1609796afadf9f99ccd290b4.zip
newlib-30f326bf5ee75e4b1609796afadf9f99ccd290b4.tar.gz
newlib-30f326bf5ee75e4b1609796afadf9f99ccd290b4.tar.bz2
* syscalls.cc (check_posix_perm): New static function.
(fpathconf): Add _PC_POSIX_PERMISSIONS and _PC_POSIX_SECURITY support. (pathconf): Ditto. * include/cygwin/version.h: Bump API minor number to 37.
-rw-r--r--winsup/cygwin/ChangeLog8
-rw-r--r--winsup/cygwin/include/cygwin/version.h3
-rw-r--r--winsup/cygwin/syscalls.cc66
3 files changed, 74 insertions, 3 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 6c95644..9547c30 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,11 @@
+Sat Mar 17 18:30:00 2001 Corinna Vinschen <corinna@vinschen.de>
+
+ * syscalls.cc (check_posix_perm): New static function.
+ (fpathconf): Add _PC_POSIX_PERMISSIONS and _PC_POSIX_SECURITY
+ support.
+ (pathconf): Ditto.
+ * include/cygwin/version.h: Bump API minor number to 37.
+
2001-03-18 Egor Duda <deo@logos-m.ru>
* fhandler.h (fhandler_tty_slave): Declare new methods.
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index 60ffe1c..b9fdcc5 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -130,10 +130,11 @@ details. */
35: Export drand48, erand48, jrand48, lcong48, lrand48,
mrand48, nrand48, seed48, and srand48.
36: Added _cygwin_S_IEXEC, et al
+ 37: [f]pathconv support _PC_POSIX_PERMISSIONS and _PC_POSIX_SECURITY
*/
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 36
+#define CYGWIN_VERSION_API_MINOR 37
/* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 22a5cef..625d150 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -1428,6 +1428,40 @@ getpagesize ()
return (int) system_info.dwPageSize;
}
+static int
+check_posix_perm (const char *fname, int v)
+{
+ extern int allow_ntea, allow_ntsec, allow_smbntsec;
+
+ /* Windows 95/98/ME don't support file system security at all. */
+ if (os_being_run != winNT)
+ return 0;
+
+ /* ntea is ok for supporting permission bits but it doesn't support
+ full POSIX security settings. */
+ if (v == _PC_POSIX_PERMISSIONS && allow_ntea)
+ return 1;
+
+ if (!allow_ntsec)
+ return 0;
+
+ char *root = rootdir (strcpy ((char *)alloca (strlen (fname)), fname));
+
+ if (!allow_smbntsec
+ && ((root[0] == '\\' && root[1] == '\\')
+ || GetDriveType (root) == DRIVE_REMOTE))
+ return 0;
+
+ DWORD vsn, len, flags;
+ if (!GetVolumeInformation (root, NULL, 0, &vsn, &len, &flags, NULL, 16))
+ {
+ __seterrno ();
+ return 0;
+ }
+
+ return (flags & FS_PERSISTENT_ACLS) ? 1 : 0;
+}
+
/* FIXME: not all values are correct... */
extern "C" long int
fpathconf (int fd, int v)
@@ -1461,6 +1495,18 @@ fpathconf (int fd, int v)
set_errno (EBADF);
return -1;
}
+ case _PC_POSIX_PERMISSIONS:
+ case _PC_POSIX_SECURITY:
+ if (fdtab.not_open (fd))
+ set_errno (EBADF);
+ else
+ {
+ fhandler_base *fh = fdtab[fd];
+ if (fh->get_device () == FH_DISK)
+ return check_posix_perm (fh->get_win32_name (), v);
+ set_errno (EINVAL);
+ }
+ return -1;
default:
set_errno (EINVAL);
return -1;
@@ -1480,14 +1526,30 @@ pathconf (const char *file, int v)
return _POSIX_LINK_MAX;
case _PC_MAX_CANON:
case _PC_MAX_INPUT:
- return _POSIX_MAX_CANON;
+ return _POSIX_MAX_CANON;
case _PC_PIPE_BUF:
return 4096;
case _PC_CHOWN_RESTRICTED:
case _PC_NO_TRUNC:
return -1;
case _PC_VDISABLE:
- return -1;
+ return -1;
+ case _PC_POSIX_PERMISSIONS:
+ case _PC_POSIX_SECURITY:
+ {
+ path_conv full_path (file, PC_SYM_FOLLOW | PC_FULL);
+ if (full_path.error)
+ {
+ set_errno (full_path.error);
+ return -1;
+ }
+ if (full_path.is_device ())
+ {
+ set_errno (EINVAL);
+ return -1;
+ }
+ return check_posix_perm (full_path, v);
+ }
default:
set_errno (EINVAL);
return -1;