]> arthur.barton.de Git - netatalk.git/commitdiff
add a default permission to volume options, from Exanet; slightly modified.
authordidg <didg>
Thu, 2 Jun 2005 12:32:17 +0000 (12:32 +0000)
committerdidg <didg>
Thu, 2 Jun 2005 12:32:17 +0000 (12:32 +0000)
config/AppleVolumes.default.tmpl
etc/afpd/directory.c
etc/afpd/filedir.c
etc/afpd/unix.c
etc/afpd/unix.h
etc/afpd/volume.c
etc/afpd/volume.h

index 6c073045cf8dac43dbfc76df652e889ac1fbf329..11aad1149bc982e0f6c5115ba2b0c1ccc640a060 100644 (file)
@@ -90,6 +90,7 @@
 #                        volume being mounted.
 # nostat              -> don't stat volume path when enumerating volumes list
 # upriv               -> use unix privilege.  
+# perm                -> default permission value OR with the client requested perm
 #
 #
 # dbpath:path         -> store the database stuff in the following path.
index 3211c4b31803e0b1f06f45964a4e70d8fe363589..2eccf90ceb290b287c97ed0feda4ad7f73af9815 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.c,v 1.80 2005-05-14 12:54:50 didg Exp $
+ * $Id: directory.c,v 1.81 2005-06-02 12:32:17 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -1961,7 +1961,7 @@ int setdirparams(const struct vol *vol,
     u_int16_t           bitmap = d_bitmap;
     u_char              finder_buf[32];
     u_int32_t          upriv;
-    mode_t              mpriv;          /* uninitialized, OK 310105 */
+    mode_t              mpriv = 0;        
     u_int16_t           upriv_bit = 0;
 
     bit = 0;
@@ -2015,7 +2015,7 @@ int setdirparams(const struct vol *vol,
             ma.ma_world = *buf++;
             ma.ma_group = *buf++;
             ma.ma_owner = *buf++;
-            mpriv = mtoumode( &ma );
+            mpriv = mtoumode( &ma ) | vol->v_perm;
             if (dir_rx_set(mpriv) && setdirmode( vol, upath, mpriv) < 0 ) {
                 err = set_dir_errors(path, "setdirmode", errno);
                 bitmap = 0;
@@ -2043,12 +2043,12 @@ int setdirparams(const struct vol *vol,
                 change_parent_mdate = 1;
                 memcpy( &upriv, buf, sizeof( upriv ));
                 buf += sizeof( upriv );
-                upriv = ntohl (upriv);
+                upriv = ntohl (upriv) | vol->v_perm;
                 if (dir_rx_set(upriv)) {
                     /* maybe we are trying to set perms back */
                     if ( setdirunixmode(vol, upath, upriv) < 0 ) {
                         bitmap = 0;
-                        err = set_dir_errors(path, "setdirmode", errno);
+                        err = set_dir_errors(path, "setdirunixmode", errno);
                     }
                 }
                 else {
@@ -2219,7 +2219,7 @@ int setdirparams(const struct vol *vol,
                 }
 
                 if ( upriv_bit && setdirunixmode(vol, upath, upriv) < 0 ) {
-                    err = set_dir_errors(path, "setdirmode", errno);
+                    err = set_dir_errors(path, "setdirunixmode", errno);
                     goto setdirparam_done;
                 }
                 break;
index 98e3f2cb612e6581d0072391a1630557dc10e4b1..8e03cbcc0403db67c45515e20ad9ff7730bea338 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: filedir.c,v 1.49 2005-05-14 12:54:53 didg Exp $
+ * $Id: filedir.c,v 1.50 2005-06-02 12:32:17 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -751,7 +751,7 @@ int ibuflen  _U_, *rbuflen;
 #endif /* DROPKLUDGE */
             /* if unix priv don't try to match perm with dest folder */
             if (!isdir && !vol_unix_priv(vol)) {
-                int  admode = ad_mode("", 0777);
+                int  admode = ad_mode("", 0777) | vol->v_perm;
 
                 setfilmode(upath, admode, NULL);
                 vol->vfs->rf_setfilmode(vol, upath, admode, NULL);
index 8f2b4cd4ae79ca8822670160b7ca6ab83e8f6c32..03be770315f9be3efeff822065fd156ea920b6f5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: unix.c,v 1.47 2005-05-25 18:19:33 didg Exp $
+ * $Id: unix.c,v 1.48 2005-06-02 12:32:18 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -403,6 +403,8 @@ mode_t mode;
         return -1;
     }
         
+    mode |= vol->v_perm;
+
     if (setfilmode( path->u_name, mode, &path->st) < 0)
         return -1;
     /* we need to set write perm if read set for resource fork */
@@ -435,10 +437,11 @@ mode_t mask = S_IRWXU | S_IRWXG | S_IRWXO;  /* rwx for owner group and other, by
 int setdirunixmode( vol, name, mode )
 const struct vol *vol;
 const char       *name;
-const mode_t     mode;
+mode_t           mode;
 {
 
     int dropbox = (vol->v_flags & AFPVOL_DROPBOX);
+    mode |= vol->v_perm;
 
     if (dir_rx_set(mode)) {
        /* extending right? dir first then .AppleDouble in rf_setdirmode */
@@ -459,15 +462,18 @@ const mode_t     mode;
 int setdirmode( vol, name, mode )
 const struct vol *vol;
 const char       *name;
-const mode_t mode;
+mode_t           mode;
 {
     struct stat                st;
     struct dirent      *dirp;
     DIR                        *dir;
+    mode_t              hf_mode;
     int                 osx = vol->v_adouble == AD_VERSION2_OSX;
-    mode_t              hf_mode = ad_hf_mode(mode);
     int                 dropbox = (vol->v_flags & AFPVOL_DROPBOX);
     
+    mode |= vol->v_perm;
+    hf_mode = ad_hf_mode(mode);
+
     if (dir_rx_set(mode)) {
        /* extending right? dir first */
        if ( stickydirmode(name, DIRBITS | mode, dropbox) < 0 )
index 63e19e80f4dcb67bb2bdcd7888b6ed7204174f85..d2e0a6fef04d56ed6c02e2ff3dc5f522e448fd21 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: unix.h,v 1.19 2005-06-01 13:03:29 didg Exp $
+ * $Id: unix.h,v 1.20 2005-06-02 12:32:18 didg Exp $
  */
 
 #ifndef AFPD_UNIX_H
@@ -217,8 +217,8 @@ extern struct afp_options default_options;
 
 extern int gmem            __P((const gid_t));
 extern int setdeskmode      __P((const mode_t));
-extern int setdirunixmode   __P((const struct vol *, const char *, const mode_t));
-extern int setdirmode       __P((const struct vol *, const char *, const mode_t));
+extern int setdirunixmode   __P((const struct vol *, const char *, mode_t));
+extern int setdirmode       __P((const struct vol *, const char *, mode_t));
 extern int setdeskowner     __P((const uid_t, const gid_t));
 extern int setdirowner      __P((const struct vol *, const char *, const uid_t, const gid_t));
 extern int setfilmode       __P((const char *, mode_t , struct stat *));
index 61238c77acd92fee4ef4c35457c4595917d534f7..bb12ff1998d0767d10b71a42420035a161f15d4b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.c,v 1.61 2005-05-25 18:30:50 didg Exp $
+ * $Id: volume.c,v 1.62 2005-06-02 12:32:18 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -116,11 +116,13 @@ m=u -> map both ways
 #define VOLOPT_FORCEUID  19  /* force uid for username x */
 #define VOLOPT_FORCEGID  20  /* force gid for group x */
 #define VOLOPT_UMASK     21
+#define VOLOPT_DFLTPERM  22
 #else 
 #define VOLOPT_UMASK     19
+#define VOLOPT_DFLTPERM  20
 #endif /* FORCE_UIDGID */
 
-#define VOLOPT_MAX       (VOLOPT_UMASK +1)
+#define VOLOPT_MAX       (VOLOPT_DFLTPERM +1)
 
 #define VOLOPT_NUM        (VOLOPT_MAX + 1)
 
@@ -489,7 +491,9 @@ static void volset(struct vol_option *options, struct vol_option *save,
         setoption(options, save, VOLOPT_DBPATH, val);
 
     } else if (optionok(tmp, "umask:", val)) {
-       options[VOLOPT_UMASK].i_value = (int)strtol(val +1, (char **)NULL, 8);
+       options[VOLOPT_UMASK].i_value = (int)strtol(val +1, NULL, 8);
+    } else if (optionok(tmp, "perm:", val)) {
+        options[VOLOPT_DFLTPERM].i_value = (int)strtol(val+1, NULL, 8);
     } else if (optionok(tmp, "mapchars:",val)) {
         setoption(options, save, VOLOPT_MAPCHARS, val);
 
@@ -642,6 +646,9 @@ static int creatvol(AFPObj *obj, struct passwd *pwd,
        if (options[VOLOPT_UMASK].i_value)
            volume->v_umask = (mode_t)options[VOLOPT_UMASK].i_value;
 
+       if (options[VOLOPT_DFLTPERM].i_value)
+           volume->v_perm = (mode_t)options[VOLOPT_DFLTPERM].i_value;
+
        if (options[VOLOPT_ADOUBLE].i_value)
            volume->v_adouble = options[VOLOPT_ADOUBLE].i_value;
        else 
index ecca0b8ea2aeae756d30d1fe3a783b5ab93cdf04..1d0d742f8275e6a479379d8e4ab9581e069f7af6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.h,v 1.22 2005-04-30 21:33:41 didg Exp $
+ * $Id: volume.h,v 1.23 2005-06-02 12:32:18 didg Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -52,6 +52,7 @@ struct vol {
     struct _cnid_db     *v_cdb;
     char                v_stamp[ADEDLEN_PRIVSYN];
     mode_t             v_umask;
+    mode_t             v_perm;             /* default permission value OR with requested perm*/
 
 #ifdef FORCE_UIDGID
     char               *v_forceuid;