summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/syscalls.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2004-04-14 16:36:26 +0000
committerCorinna Vinschen <corinna@vinschen.de>2004-04-14 16:36:26 +0000
commite3d1d51579d6128f36c08f3c7c488e5efbed7b72 (patch)
treeca3808240336f30b0c9094190da95071bd5eb20c /winsup/cygwin/syscalls.cc
parentddf9c4a7444970b5ad4c0ed4a82bdc7bd4964c15 (diff)
downloadcygnal-e3d1d51579d6128f36c08f3c7c488e5efbed7b72.tar.gz
cygnal-e3d1d51579d6128f36c08f3c7c488e5efbed7b72.tar.bz2
cygnal-e3d1d51579d6128f36c08f3c7c488e5efbed7b72.zip
* fhandler.cc (fhandler_base::open): Simplify access evaluation
expression. (fhandler_base::facl): New method. * fhandler.h: Declare facl method in fhandler_base, fhandler_disk_file and fhandler_virtual. * fhandler_disk_file.cc (fhandler_disk_file::facl): New method. * fhandler_virtual.cc (fhandler_virtual::facl): New method. * sec_acl.cc: Remove forward declaration for aclsort32 and acl32. (setacl): Remove static. Add and use handle parameter. (getacl): Ditto. (acl_worker): Reorganize to call fhandler's facl method eventually. (facl32): Ditto. * security.cc (get_nt_object_security): Remove static. * security.h: Add extern declarations for get_nt_object_security, aclsort32, acl32, getacl and setacl. Apply missing syscalls.cc patch and ChangeLog of previous check in. * syscalls.cc (chown_worker): Reorganize to call fhandler's fchown method eventually. (fchown): Ditto.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc64
1 files changed, 13 insertions, 51 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 237e5375c..5f1b58ecb 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -823,50 +823,20 @@ done:
static int
chown_worker (const char *name, unsigned fmode, __uid32_t uid, __gid32_t gid)
{
- int res;
-
- if (check_null_empty_str_errno (name))
- return -1;
-
if (!wincap.has_security ()) // real chown only works on NT
- res = 0; // return zero (and do nothing) under Windows 9x
- else
- {
- /* we need Win32 path names because of usage of Win32 API functions */
- path_conv win32_path (PC_NONULLEMPTY, name, fmode);
-
- if (win32_path.error)
- {
- set_errno (win32_path.error);
- res = -1;
- goto done;
- }
-
- /* FIXME: This makes chown on a device succeed always. Someday we'll want
- to actually allow chown to work properly on devices. */
- if (win32_path.is_auto_device () && !win32_path.issocket ())
- {
- res = 0;
- goto done;
- }
+ return 0; // return zero (and do nothing) under Windows 9x
- mode_t attrib = 0;
- if (win32_path.isdir ())
- attrib |= S_IFDIR;
- res = get_file_attribute (win32_path.has_acls (), NULL,
- win32_path.get_win32 (), &attrib);
- if (!res)
- res = set_file_attribute (win32_path.has_acls (), NULL, win32_path,
- uid, gid, attrib);
- if (res != 0 && (!win32_path.has_acls () || !allow_ntsec))
- {
- /* fake - if not supported, pretend we're like win95
- where it just works */
- res = 0;
- }
+ int res = -1;
+ fhandler_base *fh = build_fh_name (name, NULL, fmode | PC_FULL,
+ stat_suffixes);
+ if (fh->error ())
+ {
+ debug_printf ("got %d error from build_fh_name", fh->error ());
+ set_errno (fh->error ());
}
+ else
+ res = fh->fchown (uid, gid);
-done:
syscall_printf ("%d = %schown (%s,...)",
res, (fmode & PC_SYM_NOFOLLOW) ? "l" : "", name);
return res;
@@ -908,18 +878,10 @@ fchown32 (int fd, __uid32_t uid, __gid32_t gid)
return -1;
}
- const char *path = cfd->get_name ();
+ int res = cfd->fchown (uid, gid);
- if (path == NULL)
- {
- syscall_printf ("-1 = fchown (%d,...) (no name)", fd);
- set_errno (ENOSYS);
- return -1;
- }
-
- syscall_printf ("fchown (%d,...): calling chown_worker (%s,FOLLOW,...)",
- fd, path);
- return chown_worker (path, PC_SYM_FOLLOW, uid, gid);
+ syscall_printf ("%d = fchown (%s,...)", res, cfd->get_name ());
+ return res;
}
extern "C" int