]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/unix.c
remove gcc warnings and cleanup inline mess
[netatalk.git] / etc / afpd / unix.c
index 24623392381d173b2670690eac4708bd325f9bd5..58170528941c6f6f38ccfab6c28b511709c7b816 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: unix.c,v 1.43.2.1.2.10 2004-06-15 22:53:55 didg Exp $
+ * $Id: unix.c,v 1.43.2.1.2.10.2.4 2008-11-25 15:16:33 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -99,7 +99,7 @@ u_int32_t   *bsize;
     return( AFP_OK );
 }
 
-static __inline__ int utombits( bits )
+static int utombits( bits )
 mode_t bits;
 {
     int                mbits;
@@ -170,11 +170,13 @@ 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
  */
 void accessmode( path, ma, dir, st )
 char           *path;
 struct maccess *ma;
-struct dir     *dir;
+struct dir     *dir _U_;
 struct stat     *st;
 
 {
@@ -203,7 +205,7 @@ const gid_t gid;
     return( 0 );
 }
 
-static __inline__ mode_t mtoubits( bits )
+static mode_t mtoubits( bits )
 u_char bits;
 {
     mode_t     mode;
@@ -402,6 +404,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 */
@@ -415,14 +419,14 @@ mode_t mode;
 struct stat *st;
 {
 struct stat sb;
-mode_t mask = S_IRUSR |S_IWUSR | S_IRGRP | S_IWGRP |S_IROTH | S_IWOTH;
+mode_t mask = S_IRWXU | S_IRWXG | S_IRWXO;  /* rwx for owner group and other, by default */
 
     if (!st) {
         if (stat(name, &sb) != 0)
             return -1;
         st = &sb;
     }
-   mode &= mask;       /* keep only rw-rw-rw in mode */
+   
    mode |= st->st_mode & ~mask; /* keep other bits from previous mode */
    if ( chmod( name,  mode & ~default_options.umask ) < 0 && errno != EPERM ) {
        return -1;
@@ -434,11 +438,12 @@ mode_t mask = S_IRUSR |S_IWUSR | S_IRGRP | S_IWGRP |S_IROTH | S_IWOTH;
 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 +474,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 )