]> arthur.barton.de Git - netatalk.git/commitdiff
dont and permissions with parent folder when creating new directories on upriv volumes.
authorFrank Lahm <franklahm@googlemail.com>
Wed, 9 Jun 2010 13:27:46 +0000 (15:27 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Wed, 9 Jun 2010 13:27:46 +0000 (15:27 +0200)
NEWS
etc/afpd/directory.c
etc/afpd/volume.c

diff --git a/NEWS b/NEWS
index 1010d63397f8937672ac3687ecd49785fc5a9b9f..64908a2f837bc46580f9349516b338eb722383d5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ Changes in 2.1.2
 * FIX: afpd: ExtendedAttributes in FreeBSD
 * FIX: afpd: sharing home folders corrupted the per volume umask.
 * UPD: afpd: umask for home folders is no longer taken from startup umask.
+* UPD: afpd: dont and permissions with parent folder when creating new
+       directories on "upriv" volumes.
  
 Changes in 2.1.1
 ================
index 6480ca7f65c83158d770194d2a5f7a3bdea973bb..0e13a162805ed81f3c3fbb0c55f94aedf16cf38f 100644 (file)
@@ -763,9 +763,24 @@ extenddir(struct vol *vol, struct dir *dir, struct path *path)
 /* -------------------------
    appledouble mkdir afp error code.
 */
-static int netatalk_mkdir(const char *name)
+static int netatalk_mkdir(const struct vol *vol, const char *name)
 {
-    if (ad_mkdir(name, DIRBITS | 0777) < 0) {
+    int ret;
+    struct stat st;
+
+    if (vol->v_flags & AFPVOL_UNIX_PRIV) {
+        if (lstat(".", &st) < 0)
+            return AFPERR_MISC;
+        int mode = (DIRBITS & (~S_ISGID & st.st_mode)) | (0777 & ~vol->v_umask);
+        LOG(log_maxdebug, logtype_afpd, "netatalk_mkdir(\"%s\") {parent mode: %04o, vol umask: %04o}",
+            name, st.st_mode, vol->v_umask);
+
+        ret = mkdir(name, mode);
+    } else {
+        ret = ad_mkdir(name, DIRBITS | 0777);
+    }
+
+    if (ret < 0) {
         switch ( errno ) {
         case ENOENT :
             return( AFPERR_NOOBJ );
@@ -856,7 +871,7 @@ static int copydir(const struct vol *vol, int dirfd, char *src, char *dst)
         return AFPERR_PARAM;
 
     /* try to create the destination directory */
-    if (AFP_OK != (err = netatalk_mkdir(dst)) ) {
+    if (AFP_OK != (err = netatalk_mkdir(vol, dst)) ) {
         closedir(dp);
         return err;
     }
@@ -2490,7 +2505,7 @@ int afp_createdir(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_
 
     upath = s_path->u_name;
 
-    if (AFP_OK != (err = netatalk_mkdir( upath))) {
+    if (AFP_OK != (err = netatalk_mkdir(vol, upath))) {
         return err;
     }
 
index b3821063ef277f0097d404d2bf9a8beac9f752ba..9a5a4dc771e036443c694b2d3428b8d50843261d 100644 (file)
@@ -1125,6 +1125,9 @@ static int readvolfile(AFPObj *obj, struct afp_volume_name *p1, char *p2, int us
     /* Enable some default options for all volumes */
     save_options[VOLOPT_FLAGS].i_value |= AFPVOL_CACHE;
     save_options[VOLOPT_EA_VFS].i_value = AFPVOL_EA_AUTO;
+    LOG(log_maxdebug, logtype_afpd, "readvolfile: seeding default umask: %04o",
+        obj->options.umask);
+    save_options[VOLOPT_UMASK].i_value = obj->options.umask;
 
     while ( myfgets( buf, sizeof( buf ), fp ) != NULL ) {
         initline( strlen( buf ), buf );