]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/file.c
Changing UNIX privs doesn't require adouble access. Fixes #2863424
[netatalk.git] / etc / afpd / file.c
index a5f22bc0af127d003271b1f162444d16b781c722..38672a738a4129d4247658edd5cf5365d7728d60 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: file.c,v 1.106 2007-05-14 19:31:28 didg Exp $
+ * $Id: file.c,v 1.110 2009-09-21 12:35:05 franklahm Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -576,7 +576,6 @@ int ibuflen _U_, *rbuflen;
     char               *path, *upath;
     int                        creatf, did, openf, retvalue = AFP_OK;
     u_int16_t          vid;
-    int                 ret;
     struct path                *s_path;
     
 #ifdef DEBUG
@@ -613,8 +612,6 @@ int ibuflen _U_, *rbuflen;
     }
 
     upath = s_path->u_name;
-    if (0 != (ret = check_name(vol, upath))) 
-       return  ret;
     
     /* if upath is deleted we already in trouble anyway */
     if ((of = of_findname(s_path))) {
@@ -893,10 +890,17 @@ int setfilparams(struct vol *vol,
     /* second try with adouble open 
     */
     if ( ad_open_metadata( upath, vol_noadouble(vol), O_CREAT, adp) < 0) {
-        /* for some things, we don't need an adouble header */
-        if (f_bitmap & ~(1<<FILPBIT_MDATE)) {
+        LOG(log_debug, logtype_afpd, "setfilparams: ad_open_metadata error");
+        /*
+         * For some things, we don't need an adouble header:
+         * - change of modification date
+         * - UNIX privs (Bug-ID #2863424)
+         */
+        if ( (f_bitmap & ~(1<<FILPBIT_MDATE | 1<<FILPBIT_UNIXPR))) {
+            LOG(log_debug, logtype_afpd, "setfilparams: need adouble access");
             return vol_noadouble(vol) ? AFP_OK : AFPERR_ACCESS;
         }
+        LOG(log_debug, logtype_afpd, "setfilparams: no adouble perms, but only FILPBIT_MDATE and/or FILPBIT_UNIXPR");
         isad = 0;
     } else if ((ad_get_HF_flags( adp ) & O_CREAT) ) {
         ad_setname(adp, path->m_name);
@@ -1277,7 +1281,7 @@ int       ibuflen _U_, *rbuflen;
 }
 
 /* ----------------------- */
-static __inline__ int copy_all(const int dfd, const void *buf,
+static int copy_all(const int dfd, const void *buf,
                                size_t buflen)
 {
     ssize_t cc;
@@ -1861,8 +1865,10 @@ retry:
     }
 
     /* directories are bad */
-    if (S_ISDIR(path.st.st_mode))
-        return AFPERR_BADTYPE;
+    if (S_ISDIR(path.st.st_mode)) {
+        /* OS9 and OSX don't return the same error code  */
+        return (afp_version >=30)?AFPERR_NOID:AFPERR_BADTYPE;
+    }
 
     memcpy(&bitmap, ibuf, sizeof(bitmap));
     bitmap = ntohs( bitmap );