aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2000-05-24 20:09:43 +0000
committerCorinna Vinschen <corinna@vinschen.de>2000-05-24 20:09:43 +0000
commit154110f5d3dc537e4a2154fbf4d3de0b173821d2 (patch)
tree6c5d55b5598533a7ddd412f6c3d34b6cd72bfd10
parente6dfde6f82dc1a477e8cbfad83548da8a31c1f2c (diff)
downloadnewlib-154110f5d3dc537e4a2154fbf4d3de0b173821d2.zip
newlib-154110f5d3dc537e4a2154fbf4d3de0b173821d2.tar.gz
newlib-154110f5d3dc537e4a2154fbf4d3de0b173821d2.tar.bz2
* dir.cc (writable_directory): Comment out previous code,
return always 1 for now. (mkdir): Call set_file_attribute explicitely with S_IFDIR mode bit. * syscalls.cc (chown_worker): Ditto. (chmod): Ditto. * security.cc (get_nt_attribute): Fix error in debug output. Never set FILE_DELETE_CHILD for files. Construct appropriate inherit attribute according to file type.
-rw-r--r--winsup/cygwin/ChangeLog11
-rw-r--r--winsup/cygwin/dir.cc6
-rw-r--r--winsup/cygwin/security.cc17
-rw-r--r--winsup/cygwin/syscalls.cc7
4 files changed, 34 insertions, 7 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 2029f40..cb0156d 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,14 @@
+Wed May 24 21:59:00 2000 Corinna Vinschen <corinna@vinschen.de>
+
+ * dir.cc (writable_directory): Comment out previous code,
+ return always 1 for now.
+ (mkdir): Call set_file_attribute explicitely with S_IFDIR mode bit.
+ * syscalls.cc (chown_worker): Ditto.
+ (chmod): Ditto.
+ * security.cc (get_nt_attribute): Fix error in debug output.
+ Never set FILE_DELETE_CHILD for files.
+ Construct appropriate inherit attribute according to file type.
+
2000-05-23 DJ Delorie <dj@cygnus.com>
* syscalls.cc (_cygwin_istext_for_stdio): New, for newlib
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc
index f3a869c..741be84 100644
--- a/winsup/cygwin/dir.cc
+++ b/winsup/cygwin/dir.cc
@@ -23,6 +23,7 @@ details. */
int __stdcall
writable_directory (const char *file)
{
+#if 0
char dir[strlen (file) + 1];
strcpy (dir, file);
@@ -44,6 +45,9 @@ writable_directory (const char *file)
int acc = access (usedir, W_OK);
return acc == 0;
+#else
+ return 1;
+#endif
}
/* opendir: POSIX 5.1.2.1 */
@@ -297,7 +301,7 @@ mkdir (const char *dir, mode_t mode)
if (CreateDirectoryA (real_dir.get_win32 (), 0))
{
set_file_attribute (real_dir.has_acls (), real_dir.get_win32 (),
- (mode & 0777) & ~myself->umask);
+ S_IFDIR | ((mode & 0777) & ~myself->umask));
res = 0;
}
else
diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc
index bfec8a1..8537a6d 100644
--- a/winsup/cygwin/security.cc
+++ b/winsup/cygwin/security.cc
@@ -605,7 +605,7 @@ get_nt_attribute (const char *file, int *attribute,
if (! attribute)
{
- syscall_printf ("file: %s uid %d, gid %d", uid, gid);
+ syscall_printf ("file: %s uid %d, gid %d", file, uid, gid);
return 0;
}
@@ -834,6 +834,8 @@ alloc_sd (uid_t uid, gid_t gid, const char *logsrv, int attribute,
// be (un)set in each ACE.
if (! (attribute & S_IXOTH))
attribute &= ~S_ISVTX;
+ if (! (attribute & S_IFDIR))
+ attribute |= S_ISVTX;
// From here fill ACL
size_t acl_len = sizeof (ACL);
@@ -887,23 +889,26 @@ alloc_sd (uid_t uid, gid_t gid, const char *logsrv, int attribute,
DWORD group_deny = ~group_allow & other_allow;
group_deny &= ~(STANDARD_RIGHTS_READ | FILE_READ_ATTRIBUTES | FILE_READ_EA);
+ // Construct appropriate inherit attribute
+ DWORD inherit = (attribute & S_IFDIR) ? INHERIT_ALL : DONT_INHERIT;
+
// Set deny ACE for owner
if (owner_deny
&& ! add_access_denied_ace (acl, ace_off++, owner_deny,
- owner_sid, acl_len, INHERIT_ALL))
+ owner_sid, acl_len, inherit))
return NULL;
// Set allow ACE for owner
if (! add_access_allowed_ace (acl, ace_off++, owner_allow,
- owner_sid, acl_len, INHERIT_ALL))
+ owner_sid, acl_len, inherit))
return NULL;
// Set deny ACE for group
if (group_deny
&& ! add_access_denied_ace (acl, ace_off++, group_deny,
- group_sid, acl_len, INHERIT_ALL))
+ group_sid, acl_len, inherit))
return NULL;
// Set allow ACE for group
if (! add_access_allowed_ace (acl, ace_off++, group_allow,
- group_sid, acl_len, INHERIT_ALL))
+ group_sid, acl_len, inherit))
return NULL;
// Get owner and group from current security descriptor
@@ -948,7 +953,7 @@ alloc_sd (uid_t uid, gid_t gid, const char *logsrv, int attribute,
// Set allow ACE for everyone
if (! add_access_allowed_ace (acl, ace_off++, other_allow,
- get_world_sid (), acl_len, INHERIT_ALL))
+ get_world_sid (), acl_len, inherit))
return NULL;
// Set AclSize to computed value
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index cf743d0..d2eeab0 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -701,6 +701,8 @@ chown_worker (const char *name, symlink_follow fmode, uid_t uid, gid_t gid)
uid = old_uid;
if (gid == (gid_t) -1)
gid = old_gid;
+ if (win32_path.file_attributes () & FILE_ATTRIBUTE_DIRECTORY)
+ attrib |= S_IFDIR;
res = set_file_attribute (win32_path.has_acls (),
win32_path.get_win32 (),
uid, gid, attrib,
@@ -805,9 +807,14 @@ chmod (const char *path, mode_t mode)
uid_t uid;
gid_t gid;
+
+ if (win32_path.file_attributes () & FILE_ATTRIBUTE_DIRECTORY)
+ mode |= S_IFDIR;
get_file_attribute (win32_path.has_acls (),
win32_path.get_win32 (),
NULL, &uid, &gid);
+ if (win32_path.file_attributes () & FILE_ATTRIBUTE_DIRECTORY)
+ mode |= S_IFDIR;
if (! set_file_attribute (win32_path.has_acls (),
win32_path.get_win32 (),
uid, gid,