]> arthur.barton.de Git - netatalk.git/commitdiff
Permission kludge; 95% bug-free!
authoritlm019 <itlm019>
Wed, 23 Aug 2000 20:15:51 +0000 (20:15 +0000)
committeritlm019 <itlm019>
Wed, 23 Aug 2000 20:15:51 +0000 (20:15 +0000)
etc/afpd/file.c

index 0bb5ee3ec826729d581ee8be419604f780101f3e..63a4ce16595763e9e1c39aa178e44d24578e576b 100644 (file)
@@ -330,6 +330,7 @@ int afp_createfile(obj, ibuf, ibuflen, rbuf, rbuflen )
     int                        creatf, did, openf;
     u_int16_t          vid;
 
+    syslog(LOG_INFO, "afp_createfile");
     *rbuflen = 0;
     ibuf++;
     creatf = (unsigned char) *ibuf++;
@@ -416,16 +417,23 @@ you are a developer who wants to try it out and fix it. */
       syslog (LOG_ERR, "Error checking directory %s: %m", dir->d_name);
     else {
       uid=geteuid();
-      strcpy (adpath, "./.AppleDouble/");
-      strcat (adpath, path);
-      seteuid(0); /* Become root to change the owner of the file */
-      syslog (LOG_INFO, "Changing %s to uid=%d gid=%d", path, sb.st_uid, sb.st_gid);
-      if (chown(path, sb.st_uid, -1)==-1)
-        syslog (LOG_ERR, "Error changing permissions: %m");
-      if (chown(adpath, sb.st_uid, -1)==-1)
-        syslog (LOG_ERR, "Error changing AppleDouble permissions: %m");
-      syslog (LOG_INFO, "Changing afpd owner back to %d", uid);
-      seteuid(uid); /* Restore process ownership to normal */
+      if ( uid != sb.st_uid )
+      {
+       strcpy (adpath, "./.AppleDouble/");
+       strcat (adpath, path);
+       seteuid(0); /* Become root to change the owner of the file */
+       syslog (LOG_INFO, "Changing %s to uid=%d gid=%d", path, sb.st_uid, sb.st_gid);
+       if (chown(path, sb.st_uid, sb.st_gid)==-1)
+         syslog (LOG_ERR, "Error changing permissions: %m");
+        /* In order to write information to the file, the Mac client needs
+        to be able to read from it too, so read bits have to be turned on.
+        Directory permissions remain unchanged */
+        chmod(path,(sb.st_mode&0x0FFFF)| S_IRGRP| S_IROTH);
+       if (chown(adpath, sb.st_uid, sb.st_gid)==-1)
+         syslog (LOG_ERR, "Error changing AppleDouble permissions: %m");
+       syslog (LOG_INFO, "Changing afpd owner back to %d", uid);
+       seteuid(uid); /* Restore process ownership to normal */
+      }
     }
 
 #endif DROPKLUDGE
@@ -445,6 +453,7 @@ int afp_setfilparams(obj, ibuf, ibuflen, rbuf, rbuflen )
     int                did, rc;
     u_int16_t  vid, bitmap;
 
+    syslog (LOG_INFO, "afp_setfilparams");
     *rbuflen = 0;
     ibuf += 2;
 
@@ -735,6 +744,7 @@ int afp_copyfile(obj, ibuf, ibuflen, rbuf, rbuflen )
     int                plen, err;
     u_int16_t  svid, dvid;
 
+    syslog(LOG_INFO, "afp_copyfile");
     *rbuflen = 0;
     ibuf += 2;
 
@@ -1118,7 +1128,7 @@ int afp_createid(obj, ibuf, ibuflen, rbuf, rbuflen )
     cnid_t             did, id;
     u_short            vid;
     
-
+    syslog(LOG_INFO, "afp_createid");
     *rbuflen = 0;
     ibuf += 2;
 
@@ -1208,7 +1218,7 @@ int afp_resolveid(obj, ibuf, ibuflen, rbuf, rbuflen )
     cnid_t             id;
     u_int16_t          vid, bitmap;
     
-
+    syslog(LOG_INFO, "afp_resolveid");
     *rbuflen = 0;
     ibuf += 2;
 
@@ -1271,7 +1281,7 @@ int afp_deleteid(obj, ibuf, ibuflen, rbuf, rbuflen )
     cnid_t             id;
     u_short            vid;
     
-
+    syslog(LOG_INFO, "afp_deleteid");
     *rbuflen = 0;
     ibuf += 2;
 
@@ -1349,7 +1359,7 @@ int afp_exchangefiles(obj, ibuf, ibuflen, rbuf, rbuflen )
     cnid_t             sid, did;
     u_int16_t          vid;
     
-
+    syslog(LOG_INFO, "afp_exchangefiles");
     *rbuflen = 0;
     ibuf += 2;