Mail Archives: cygwin-developers/1999/01/23/15:24:37

From: corinna DOT vinschen AT cityweb DOT de (Corinna Vinschen)
Subject: Re: Patch: UNIX-like permissions on objects
23 Jan 1999 15:24:37 -0800 :
Message-ID: <>
References: <01BE46C2 DOT 29B35190 AT sos>
Mime-Version: 1.0
To: Sergey Okhapkin <sos AT prospect DOT com DOT ru>, cygwin32-developers AT cygnus DOT com

Sergey Okhapkin wrote:
> Corinna Vinschen wrote:
> > But some applications behave strange now.
> > E.g. cvs: With this patch, it's impossible, to commit changes, because the user,
> > which creates the lock file, has suddenly no write permissions to this lock file
> > anymore. I don't understand why! Possibly, it's a bug, not to change the
> > SECURITY_DESCRIPTOR's to absolut format?
> Isn't it an "Administrators" group problem?

I don't know. Today, I couldn't reproduce the problem. The circumstances were
the same but the error didn't happen anymore.

The circumstances were:
user "admin" uid 1009, member of "Administratoren", gid 544.
Command: cvs commit -m "bla" foo.c
Error: sth like "Can't change lock file, permission denied." I don't remember
in detail.

I have to mention, that I kept hacking 'til 5am and the problem happens about 3am.
Maybe, the last changes solved it. God, I was so tired in the morning!

> > Moreover, I haven't found out, how to set the default file permissions in a
> > directory security descriptor. Who knows, how to do this?
> Get(Set)FileSecurity() doesn't work for directories???

Sure, but directories have two types of permissions: Their own permissions and 
the default file permissions! Any try, to set permissions via SetFileSecurity()
set the directory permissions, but the default file permissions are set to "unset".
This isn't a problem in a UNIX-like environment, but it bothers me, that I don't
know, how to do this!

Today, I have found, that chown has to call _set_file_attributes, too, to adapt
the file security. Otherwise, the settings are kept for the wrong (old) owner!
I have patched this and attached the patch, relativ to the tonight changes.
Three files are affected: winsup.h (prototype for `_set_file_attribute()'), (patch to `chown()') and, to allow uid and gid as
parameters to `_set_file_attribute()'.

> > Would you, Sergey, be so kind, to take a look into the code and eventually test it?
> Definitely yes, ASAP!

Thank you! If you have a question, you know my mail address. I'm really messy with
comments in my sources!


Index: winsup.h
RCS file: /src/cvsroot/winsup-981230/winsup.h,v
retrieving revision
diff -u -p -1 -r1.1.1.1 winsup.h
--- winsup.h    1998/12/30 23:01:58
+++ winsup.h    1999/01/23 20:46:42
@@ -355,2 +355,3 @@ BOOL get_file_attribute (const char *, i
 BOOL set_file_attribute (const char *, int);
+BOOL _set_file_attribute (const char *file, uid_t uid, gid_t gid,int attribute)
 void set_std_handle (int);
RCS file: /src/cvsroot/winsup-981230/,v
retrieving revision 1.5
diff -u -p -1 -r1.5
--- 1999/01/12 17:53:19     1.5
+++ 1999/01/23 20:53:07
@@ -926,2 +926,9 @@ retry:
                  syscall_printf ("0 = chown (%s,...)", name);
+                 int attrib;
+                 if (get_file_attribute (win32_path.get_win32 (), &attrib))
+                   _set_file_attribute (win32_path.get_win32 (),
+                                        uid, gid, attrib);
                  return 0;
RCS file: /src/cvsroot/winsup-981230/,v
retrieving revision 1.2
diff -u -p -1 -r1.2
--- 1999/01/23 21:01:59     1.2
+++ 1999/01/23 21:00:55
@@ -178,3 +178,3 @@ get_file_attribute (const char *file, in
-_set_file_attribute (const char *file, int attribute)
+_set_file_attribute (const char *file, uid_t uid, gid_t gid, int attribute)
@@ -188,3 +188,3 @@ _set_file_attribute (const char *file, i

-  struct passwd *pw = getpwuid (myself->uid);
+  struct passwd *pw = getpwuid (uid);
   strcpy (user, pw ? pw->pw_name : getlogin ());
@@ -226,3 +226,3 @@ _set_file_attribute (const char *file, i

-  struct group *grp = getgrgid (myself->gid);
+  struct group *grp = getgrgid (gid);
   PSID sidGroup = NULL;
@@ -343,3 +343,3 @@ set_file_attribute (const char *file, in
-  _set_file_attribute (file, attribute);
+  _set_file_attribute (file, myself->uid, myself->gid, attribute);
   return NTWriteEA (file, ".UNIXATTR", (char *) &attribute,

- Raw text -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019