]> arthur.barton.de Git - netatalk.git/commitdiff
Merge from branch-2-1: umask on upriv volumes
authorFrank Lahm <franklahm@googlemail.com>
Wed, 9 Jun 2010 13:59:30 +0000 (15:59 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Wed, 9 Jun 2010 13:59:30 +0000 (15:59 +0200)
NEWS
etc/afpd/afp_dsi.c
etc/afpd/directory.c
etc/afpd/volume.c

diff --git a/NEWS b/NEWS
index 70235ff4cdea45306bb0084cd90a3cdecef9e48e..64908a2f837bc46580f9349516b338eb722383d5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,11 @@ Changes in 2.1.2
 * FIX: afpd: fix for possible crash in case more then one server is
        configured in afpd.conf.
 * 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 1b10187a42c0e3e9d63449911491f078733f1550..54e5c4b66ea594603ca3596c2abb04d2aa3ef3f2 100644 (file)
@@ -74,10 +74,14 @@ static void afp_dsi_close(AFPObj *obj)
      * as uid 0, that's the wrong user for volume's prexec_close scripts if any,
      * restore our login user
      */
-    if (seteuid( obj->uid ) < 0) {
-        LOG(log_error, logtype_afpd, "can't seteuid back %s", strerror(errno));
-        exit(EXITERR_SYS);
+    if (geteuid() != obj->uid) {
+        if (seteuid( obj->uid ) < 0) {
+            LOG(log_error, logtype_afpd, "can't seteuid(%u) back %s: uid: %u, euid: %u", 
+                obj->uid, strerror(errno), getuid(), geteuid());
+            exit(EXITERR_SYS);
+        }
     }
+
     close_all_vol();
     if (obj->logout)
         (*obj->logout)();
index 467bc62d89e936c2cf69988db42f66b27ea3fe36..03bb0146b123ba5ee3b26361c4bdc18679abb144 100644 (file)
@@ -85,9 +85,24 @@ struct path Cur_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 );
@@ -178,7 +193,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;
     }
@@ -2086,7 +2101,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 23901150bf1d31815a2548bac846f912523783b2..03bc2be29375ee6bc5b7ded62236848688144c3a 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
  */
@@ -1131,6 +1129,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 );
@@ -1171,10 +1172,6 @@ static int readvolfile(AFPObj *obj, struct afp_volume_name *p1, char *p2, int us
                 strcat( tmp, "/" );
                 strcat( tmp, p );
             }
-            /* Tag a user's home directory with their umask.  Note, this will
-             * be overwritten if the user actually specifies a umask: option
-             * for a '~' volume. */
-            save_options[VOLOPT_UMASK].i_value = obj->options.save_mask;
             /* fall through */
 
         case '/' :