]> arthur.barton.de Git - netatalk.git/commitdiff
add a default perm option to volume, from Exanet.
authordidg <didg>
Thu, 2 Jun 2005 12:49:40 +0000 (12:49 +0000)
committerdidg <didg>
Thu, 2 Jun 2005 12:49:40 +0000 (12:49 +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..9d8c098dee0332ecb4941415c8ce3fdc16a2ec43 100644 (file)
@@ -59,6 +59,8 @@
 # maccharset           -> specifies the charset to be used as the mac client codepage
 #                         e.g. "MAC_ROMAN", "MAC_CYRILLIC"
 #
+# perm                -> default permission value OR with the client requested perm
+#
 # miscellaneous options [syntax: options:option1,option2]:
 # prodos              -> make compatible with appleII clients.
 # crlf                -> enable crlf translation for TEXT files.
index 9f3798503f121226b4bf7486348bff5b2ff64af5..fae4f508d1d7ce8ae562f1cad3e21c7b95099fce 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.c,v 1.71.2.4.2.15.2.5 2005-02-10 01:23:10 didg Exp $
+ * $Id: directory.c,v 1.71.2.4.2.15.2.6 2005-06-02 12:49:40 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -1650,7 +1650,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;
@@ -1704,7 +1704,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;
@@ -1732,12 +1732,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 {
@@ -1909,7 +1909,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 2f2ca1c66365ff2253b553192273c4b30d60a6d0..5ede4df63a2efc59e22ddbb686b5509bb89742d0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: filedir.c,v 1.45.2.2.2.14.2.2 2005-02-10 01:23:14 didg Exp $
+ * $Id: filedir.c,v 1.45.2.2.2.14.2.3 2005-06-02 12:49:41 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -748,7 +748,7 @@ int         ibuflen, *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);
                 setfilmode(vol->ad_path( upath, ADFLAGS_HF ), ad_hf_mode(admode), NULL);
index c319412da23ddd7d0fbddef11e8433435f0e6e2f..b55b530ed9cfc05decf739aa5e71886175b8c1a9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: unix.c,v 1.43.2.1.2.10.2.1 2005-05-26 11:49:55 didg Exp $
+ * $Id: unix.c,v 1.43.2.1.2.10.2.2 2005-06-02 12:49:41 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -402,6 +402,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 */
@@ -434,11 +436,12 @@ 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;
 {
 char *adouble = vol->ad_path( name, ADFLAGS_DIR );
 
     int dropbox = (vol->v_flags & AFPVOL_DROPBOX);
+    mode |= vol->v_perm;
 
     if (dir_rx_set(mode)) {
        /* extending right? dir first then .AppleDouble */
@@ -469,19 +472,22 @@ char *adouble = vol->ad_path( name, ADFLAGS_DIR );
 int setdirmode( vol, name, mode )
 const struct vol *vol;
 const char       *name;
-const mode_t mode;
+mode_t           mode;
 {
     char               buf[ MAXPATHLEN + 1];
     struct stat                st;
     char               *m;
     struct dirent      *dirp;
     DIR                        *dir;
+    mode_t              hf_mode;
     int                 osx = vol->v_adouble == AD_VERSION2_OSX;
-    int                 hf_mode = ad_hf_mode(mode);
     int                 dropbox = (vol->v_flags & AFPVOL_DROPBOX);
     char                *adouble = vol->ad_path( name, ADFLAGS_DIR );
     char                *adouble_p = ad_dir(adouble);
     
+    mode |= vol->v_perm;
+    hf_mode = ad_hf_mode(mode);
+
     if (dir_rx_set(mode)) {
        /* extending right? dir first then .AppleDouble */
        if ( stickydirmode(name, DIRBITS | mode, dropbox) < 0 )
index 56bacb6ee82bc12032010e4043090293d8c5eae4..603f1d0bca81f31d877ee7955326f79ac88957e6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: unix.h,v 1.12.2.1.2.6.2.2 2005-06-01 12:28:26 didg Exp $
+ * $Id: unix.h,v 1.12.2.1.2.6.2.3 2005-06-02 12:49:41 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((char *, mode_t , struct stat *));
index 1c9272518eac92ca66e2ee5c6265ba7497679050..a6d3cdb9e3ed2898c29e7db549c4981b7ef23f8d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.c,v 1.51.2.7.2.33.2.6 2005-05-26 11:49:55 didg Exp $
+ * $Id: volume.c,v 1.51.2.7.2.33.2.7 2005-06-02 12:49:41 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -115,11 +115,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)
 
@@ -478,7 +480,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, (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);
 
@@ -659,6 +663,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 4a69634fe394e31b976df3d71fe5fbc49bfc8e0d..35dcab17e6728ae65da29e4b92d599b4586a054e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.h,v 1.19.2.5.2.7.2.1 2005-02-10 01:23:16 didg Exp $
+ * $Id: volume.h,v 1.19.2.5.2.7.2.2 2005-06-02 12:49:41 didg Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -48,6 +48,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;