]> arthur.barton.de Git - netatalk.git/commitdiff
File ownership kludge, not yet complete.
authoritlm019 <itlm019>
Wed, 16 Aug 2000 23:31:29 +0000 (23:31 +0000)
committeritlm019 <itlm019>
Wed, 16 Aug 2000 23:31:29 +0000 (23:31 +0000)
etc/afpd/file.c

index 8b2a112a0bb173737b959acb18a0cd0bc1c38b22..86efa9d0562816908de1b7fc3ff3f5c827dd1305 100644 (file)
@@ -317,12 +317,15 @@ int afp_createfile(obj, ibuf, ibuflen, rbuf, rbuflen )
     int                ibuflen, *rbuflen;
 {
     struct stat         st;
+#ifdef DROPKLUDGE
+    struct stat                sb;
+#endif DROPKLUDGE
     struct adouble     ad, *adp;
     struct vol         *vol;
     struct dir         *dir;
     struct ofork        *of;
     char               *path, *upath;
-    int                        creatf, did, openf;
+    int                        creatf, did, openf, uid;
     u_int16_t          vid;
 
     *rbuflen = 0;
@@ -402,6 +405,25 @@ int afp_createfile(obj, ibuf, ibuflen, rbuf, rbuflen )
 
 createfile_done:
     setvoltime(obj, vol );
+
+#ifdef DROPKLUDGE
+
+/* The below code is an experimental, untested, incomplete kludge which 
+provides better dropbox support.  It should NOT be turned on yet unless
+you are a developer who wants to try it out and fix it. */
+    if (stat(dir->d_name, &sb) == -1)
+      syslog (LOG_ERR, "Error checking directory: %m");
+    else {
+      uid=getuid();
+      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);
+      chown(path, sb.st_uid, sb.st_gid);
+      syslog (LOG_INFO, "Changing afpd owner back to %d", uid);
+      seteuid(uid); /* Restore ownership to normal */
+    }
+
+#endif DROPKLUDGE
+
     return AFP_OK;
 }