]> arthur.barton.de Git - netatalk.git/commitdiff
patch from Edmund Lam to allow perms masks
authorrufustfirefly <rufustfirefly>
Tue, 23 Oct 2001 13:44:35 +0000 (13:44 +0000)
committerrufustfirefly <rufustfirefly>
Tue, 23 Oct 2001 13:44:35 +0000 (13:44 +0000)
ChangeLog
etc/afpd/afp_options.c
etc/afpd/filedir.c
etc/afpd/filedir.h
etc/afpd/globals.h
etc/afpd/main.c
etc/afpd/unix.c
etc/afpd/unix.h

index 587a5f9287e477af0c4098b2a2f95eb2e0737471..3f6281ef1a21207545b53e61e401af43ee4a8ae1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-10-23  jeff b  <jeff@univrel.pr.uconn.edu>
+
+       * etc/afpd/{{afpd_options,filedir,main,unix}.c,
+       {filedir,globals,unix}.h}: patch from Edmund Lam to allow
+       perms masks
+
 2001-10-21  joe c <marcus@marcuscom.com>
 
        * libatalk/cnid*.c: Big patch to improve transaction throughput
index 7e6689795a4f4bb346ea45311d8247aa16894b1e..706edea359e50debc5f1b8ce8c4ab2220c393584 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * $Id: afp_options.c,v 1.12 2001-09-19 03:08:40 jmarcus Exp $
+ * $Id: afp_options.c,v 1.13 2001-10-23 13:44:37 rufustfirefly Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
@@ -61,7 +61,7 @@ char *strchr (), *strrchr ();
 #define MIN(a, b)  ((a) < (b) ? (a) : (b))
 #endif /* MIN */
 
-#define OPTIONS "dn:f:s:uc:g:P:ptDS:TL:F:U:Iv"
+#define OPTIONS "dn:f:s:uc:g:P:ptDS:TL:F:U:Ivm:"
 #define LENGTH 512
 
 /* return an option. this uses an internal array, so it's necessary
@@ -142,6 +142,7 @@ void afp_options_init(struct afp_options *options)
   options->passwdfile = _PATH_AFPDPWFILE;
   options->tickleval = 30;
   options->authprintdir = NULL;
+  options->umask = 0;
 #ifdef ADMIN_GRP
   options->admingid = 0;
 #endif /* ADMIN_GRP */
@@ -283,6 +284,7 @@ int afp_options_parse(int ac, char **av, struct afp_options *options)
   extern int optind;
   
   char *p;
+  char *tmp;   /* Used for error checking the result of strtol */
   int c, err = 0;
 
   if (gethostname(options->hostname, sizeof(options->hostname )) < 0 ) {
@@ -359,6 +361,17 @@ int afp_options_parse(int ac, char **av, struct afp_options *options)
        case 'I':
            options->flags |= OPTION_CUSTOMICON;
                break;
+       case 'm':
+           options->umask = strtol(optarg, &tmp, 8);
+           if ((options->umask < 0) || (options->umask > 0777)) {
+               fprintf(stderr, "%s: out of range umask setting provided\n", p);
+               err++;
+           }
+           if (tmp[0] != '\0') {
+               fprintf(stderr, "%s: invalid characters in umask setting provided\n", p);
+               err++;
+           }
+           break;
        default :
            err++;
        }
index aa21ac07a4437189598c4740971d7a655e690c17..c8c801180739cffa29eebe9e7364603492df38d3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: filedir.c,v 1.14 2001-09-06 20:00:59 rufustfirefly Exp $
+ * $Id: filedir.c,v 1.15 2001-10-23 13:44:37 rufustfirefly Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -100,7 +100,7 @@ int matchfile2dirperms(upath, vol, did)
                    upath, strerror(errno));
             return (AFPERR_ACCESS);
           }
-          if (chmod(upath,(st.st_mode&0x0FFFF)| S_IRGRP| S_IROTH) < 0)
+          if (chmod(upath,(st.st_mode&0777&~default_options.umask)| S_IRGRP| S_IROTH) < 0)
           {
             syslog (LOG_ERR, 
              "matchfile2dirperms:  Error adding file read permissions: %s",
@@ -120,7 +120,7 @@ int matchfile2dirperms(upath, vol, did)
              adpath, strerror(errno));
             return (AFPERR_ACCESS);
          }
-          if (chmod(adpath, (st.st_mode&0x0FFFF)| S_IRGRP| S_IROTH) < 0)
+          if (chmod(adpath, (st.st_mode&0777&~default_options.umask)| S_IRGRP| S_IROTH) < 0)
           {
             syslog (LOG_ERR, 
              "matchfile2dirperms:  Error adding AD file read permissions: %s",
index 92d5fd89a6c356a0f057d014de644b4f2aa8c239..a0061c28487e5d06b7545f3102f6ef31483d9e58 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: filedir.h,v 1.4 2001-09-05 13:30:16 rufustfirefly Exp $
+ * $Id: filedir.h,v 1.5 2001-10-23 13:44:37 rufustfirefly Exp $
  */
 
 #ifndef AFPD_FILEDIR_H
@@ -10,6 +10,8 @@
 #include "globals.h"
 #include "volume.h"
 
+extern struct afp_options default_options;
+
 extern char            *ctoupath __P((const struct vol *, struct dir *, 
                                       char *));
 extern int             veto_file __P((const char *veto_str, const char *path));
index 48b161e5d57a3211370fc3f81d46e2fb83084b21..e254547ccff03b49d51e2c60331a001162cf2414 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: globals.h,v 1.5 2001-06-20 18:33:04 rufustfirefly Exp $
+ * $Id: globals.h,v 1.6 2001-10-23 13:44:37 rufustfirefly Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -50,6 +50,7 @@ struct afp_options {
   char *guest, *loginmesg, *keyfile, *passwdfile;
   char *uamlist;
   char *authprintdir;
+  mode_t umask;
 #ifdef ADMIN_GRP
   gid_t admingid;
 #endif /* ADMIN_GRP */
index 65a6162e63398be46b26e5ed2b4686fcce3b72c1..b71c45a27db2e3e9610d9b761e3cf20f7042d8e9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: main.c,v 1.11 2001-08-15 01:37:34 srittau Exp $
+ * $Id: main.c,v 1.12 2001-10-23 13:44:37 rufustfirefly Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -154,11 +154,13 @@ int main( ac, av )
     set_auth_parameters( ac, av );
 #endif /* TRU64 */
 
-    umask( 0 );                /* so inherited file permissions work right */
+    umask( 022 );      /* so inherited file permissions work right */
 
     afp_options_init(&default_options);
     if (!afp_options_parse(ac, av, &default_options))
       exit(1);
+
+    umask( default_options.umask );
     
     switch(server_lock("afpd", default_options.pidfile, 
                       default_options.flags & OPTION_DEBUG)) {
index de2c452dbadc860c3df9d5c360d99b959bcad97a..6546ef5229a55d8705d6519263d46a13540c69db 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: unix.c,v 1.23 2001-10-10 16:05:37 srittau Exp $
+ * $Id: unix.c,v 1.24 2001-10-23 13:44:37 rufustfirefly Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -247,7 +247,7 @@ inline int stickydirmode(name, mode, dropbox)
         if ( seteuid(0) < 0) {
           syslog( LOG_ERR, "stickydirmode: unable to seteuid root: %m");
         }
-        if ( retval=chmod( name, ( DIRBITS | mode | S_ISVTX) ) < 0) {
+        if ( retval=chmod( name, ( (DIRBITS | mode | S_ISVTX) & 0777 & ~default_options.umask) ) < 0) {
            syslog( LOG_ERR, "stickydirmode: chmod \"%s\": %m", name );
            return(AFPERR_ACCESS);
         } else {
@@ -264,7 +264,7 @@ inline int stickydirmode(name, mode, dropbox)
        *  Ignore EPERM errors:  We may be dealing with a directory that is
        *  group writable, in which case chmod will fail.
        */
-       if ( chmod( name, DIRBITS | mode ) < 0 && errno != EPERM)  {
+       if ( (chmod( name, (DIRBITS | mode) & 0777 & ~default_options.umask ) < 0) && errno != EPERM)  {
           syslog( LOG_ERR, "stickydirmode: chmod \"%s\": %s",
                  name, strerror(errno) );
          retval = -1;
@@ -323,11 +323,11 @@ int setdeskmode( mode )
            }       
 
            if (S_ISDIR(st.st_mode)) {
-             if ( chmod( modbuf,  DIRBITS | mode ) < 0 && errno != EPERM ) {
+             if ( chmod( modbuf,  (DIRBITS | mode) & 0777 & ~default_options.umask ) < 0 && errno != EPERM ) {
                syslog( LOG_ERR, "setdeskmode: chmod %s: %s",
                        modbuf, strerror(errno) );
              }
-           } else if ( chmod( modbuf,  mode ) < 0 && errno != EPERM ) {
+           } else if ( chmod( modbuf,  mode & 0777 & ~default_options.umask ) < 0 && errno != EPERM ) {
                syslog( LOG_ERR, "setdeskmode: chmod %s: %s",
                        modbuf, strerror(errno) );
            }
@@ -335,7 +335,7 @@ int setdeskmode( mode )
        }
        closedir( sub );
        /* XXX: need to preserve special modes */
-       if ( chmod( deskp->d_name,  DIRBITS | mode ) < 0 && errno != EPERM ) {
+       if ( chmod( deskp->d_name,  (DIRBITS | mode) & 0777 & ~default_options.umask ) < 0 && errno != EPERM ) {
            syslog( LOG_ERR, "setdeskmode: chmod %s: %s",
                    deskp->d_name, strerror(errno) );
        }
@@ -346,7 +346,7 @@ int setdeskmode( mode )
        return -1;
     }
     /* XXX: need to preserve special modes */
-    if ( chmod( ".AppleDesktop",  DIRBITS | mode ) < 0 && errno != EPERM ) {
+    if ( chmod( ".AppleDesktop",  (DIRBITS | mode) & 0777 & ~default_options.umask ) < 0 && errno != EPERM ) {
        syslog( LOG_ERR, "setdeskmode: chmod .AppleDesktop: %s", strerror(errno) );
     }
     return( 0 );
index 19dba748d9f943b9db9c2e4fb1d6b9b09de498d5..fedf135707346e4da1f21c574f14f43ca0f36efc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: unix.h,v 1.7 2001-06-20 18:33:04 rufustfirefly Exp $
+ * $Id: unix.h,v 1.8 2001-10-23 13:44:37 rufustfirefly Exp $
  */
 
 #ifndef AFPD_UNIX_H
@@ -91,6 +91,8 @@ extern int uquota_getvolspace __P((const struct vol *, VolSpace *, VolSpace *,
                                   const u_int32_t));
 #endif /* NO_QUOTA_SUPPORT */
 
+extern struct afp_options default_options;
+
 extern int gmem         __P((const gid_t));
 extern int setdeskmode  __P((const mode_t));
 extern int setdirmode   __P((const mode_t, const int, const int));