]> arthur.barton.de Git - netatalk.git/commitdiff
seteuid() back after seteuid(0)
authorFrank Lahm <franklahm@googlemail.com>
Tue, 25 Oct 2011 11:11:56 +0000 (13:11 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Tue, 25 Oct 2011 11:11:56 +0000 (13:11 +0200)
NEWS
libatalk/util/volinfo.c

diff --git a/NEWS b/NEWS
index 951eefc2c98e2110f57a2ab3c23519042b04d9fc..326f35b98ce455294674563849a037823c7859aa 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ Changes in 2.2.2
 * FIX: afpd: ACL access checking
 * FIX: afpd: Fix an error when duplicating files that lacked an AppleDouble file
        which lead to a possible Finder crash
+* FIX: afpd: Read-only filesystems lead to afpd processes running as root
 * FIX: dbd: Better checking for duplicated or bogus CNIDs from AppleDouble files
 * FIX: Fix compilation error when AppleTalk support is disabled
 
index 6ccd47c4d57cd08e79e02d7579efe91c2bca78a3..c6cb1f21b454b1045e13ae5abe87608e337388ff 100644 (file)
@@ -497,13 +497,19 @@ int savevolinfo(const struct vol *vol, const char *Cnid_srv, const char *Cnid_po
     }
 
     if ((fd = open(item, O_RDWR | O_CREAT , 0666)) <0 ) {
-        LOG(log_error, logtype_afpd,"Error opening %s: %s", item, strerror(errno));
+        LOG(log_debug, logtype_default,"Error opening %s: %s", item, strerror(errno));
+        if (process_uid) {
+            if (seteuid(process_uid) == -1) {
+                LOG(log_error, logtype_default, "can't seteuid back %s", strerror(errno));
+                exit(EXITERR_SYS);
+            }
+        }
         return (-1);
     }
 
     if (process_uid) {
         if (seteuid(process_uid) == -1) {
-            LOG(log_error, logtype_logger, "can't seteuid back %s", strerror(errno));
+            LOG(log_error, logtype_default, "can't seteuid back %s", strerror(errno));
             exit(EXITERR_SYS);
         }
     }
@@ -519,7 +525,7 @@ int savevolinfo(const struct vol *vol, const char *Cnid_srv, const char *Cnid_po
             /* ignore, other process already writing the file */
             return 0;
         } else {
-            LOG(log_error, logtype_cnid, "savevoloptions: cannot get lock: %s", strerror(errno));
+            LOG(log_error, logtype_default, "savevoloptions: cannot get lock: %s", strerror(errno));
             return (-1);
         }
     }
@@ -605,9 +611,9 @@ int savevolinfo(const struct vol *vol, const char *Cnid_srv, const char *Cnid_po
     strlcat(buf, item, sizeof(buf));
 
     if (strlen(buf) >= sizeof(buf)-1)
-        LOG(log_debug, logtype_afpd,"Error writing .volinfo file: buffer too small, %s", buf);
+        LOG(log_debug, logtype_default, "Error writing .volinfo file: buffer too small, %s", buf);
    if (write( fd, buf, strlen(buf)) < 0 || ftruncate(fd, strlen(buf)) < 0 ) {
-       LOG(log_debug, logtype_afpd,"Error writing .volinfo file: %s", strerror(errno));
+       LOG(log_debug, logtype_default, "Error writing .volinfo file: %s", strerror(errno));
    }
 
    lock.l_type = F_UNLCK;