]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/unix.c
Initial checkin of ACLs patch
[netatalk.git] / etc / afpd / unix.c
index 8f2b4cd4ae79ca8822670160b7ca6ab83e8f6c32..1ad282f227f08f0049a0ed9d233b9e5e5975e58a 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.52 2009-02-02 11:55:01 franklahm Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -45,6 +45,11 @@ char *strchr (), *strrchr ();
 #include "unix.h"
 #include "fork.h"
 
+#ifdef HAVE_NFSv4_ACLS
+extern void acltoownermode(char *path, struct stat *st,uid_t uid, struct maccess *ma);
+#endif
+
+
 /*
  * Get the free space on a partition.
  */
@@ -99,7 +104,7 @@ u_int32_t   *bsize;
     return( AFP_OK );
 }
 
-static __inline__ int utombits( bits )
+static int utombits( bits )
 mode_t bits;
 {
     int                mbits;
@@ -169,7 +174,6 @@ mode_t mode;
  *
  * Note: the previous method, using access(), does not work correctly
  * over NFS.
- * FIXME what about ACL?
  *
  * dir parameter is used by AFS
  */
@@ -189,6 +193,10 @@ struct stat     sb;
         st = &sb;
     }
     utommode( st, ma );
+#ifdef HAVE_NFSv4_ACLS
+    /* 10.5 Finder looks at OS 9 mode, so we must do some mapping */
+    acltoownermode( path, st, uuid, ma);
+#endif
 }
 
 int gmem( gid )
@@ -204,7 +212,7 @@ const gid_t gid;
     return( 0 );
 }
 
-static __inline__ mode_t mtoubits( bits )
+static mode_t mtoubits( bits )
 u_char bits;
 {
     mode_t     mode;
@@ -270,7 +278,7 @@ const int dropbox;
 
 #ifdef DROPKLUDGE
     /* Turn on the sticky bit if this is a drop box, also turn off the setgid bit */
-    if (dropbox) {
+    if ((dropbox & AFPVOL_DROPBOX)) {
         int uid;
 
         if ( ( (mode & S_IWOTH) && !(mode & S_IROTH)) ||
@@ -297,7 +305,9 @@ const int 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) & ~default_options.umask ) < 0) && errno != EPERM)  {
+    if ( (chmod( name, (DIRBITS | mode) & ~default_options.umask ) < 0) && errno != EPERM && 
+               !(errno == ENOENT && (dropbox & AFPVOL_NOADOUBLE)) )  
+    {
         LOG(log_error, logtype_afpd, "stickydirmode: chmod \"%s\": %s", fullpathname(name), strerror(errno) );
         retval = -1;
     }
@@ -403,6 +413,8 @@ mode_t mode;
         return -1;
     }
         
+    mode |= vol->v_fperm;
+
     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 +447,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_dperm;
 
     if (dir_rx_set(mode)) {
        /* extending right? dir first then .AppleDouble in rf_setdirmode */
@@ -459,15 +472,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_dperm;
+    hf_mode = ad_hf_mode(mode);
+
     if (dir_rx_set(mode)) {
        /* extending right? dir first */
        if ( stickydirmode(name, DIRBITS | mode, dropbox) < 0 )