]> arthur.barton.de Git - netatalk.git/commitdiff
Add another check to prevent running as root in disconnected state
authorFrank Lahm <franklahm@googlemail.com>
Tue, 24 May 2011 10:58:27 +0000 (12:58 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Tue, 24 May 2011 10:58:27 +0000 (12:58 +0200)
libatalk/dsi/dsi_stream.c

index f6d5f8b6f84c5c1125cff44f521e3ed0ed75ec07..394b707a044dd58827bfefd1e13274c77d6bf565 100644 (file)
@@ -238,13 +238,15 @@ static void unblock_sig(DSI *dsi)
  * 1. close the socket
  * 2. set the DSI_DISCONNECTED flag
  *
- * @return -1 if ppid is 1 which means afpd master died, otherwise 0
+ * @returns  0 if successfully entered disconnected state
+ *          -1 if ppid is 1 which means afpd master died
+ *             or euid == 0 ie where still running as root (unauthenticated session)
  */
 int dsi_disconnect(DSI *dsi)
 {
     dsi->proto_close(dsi);          /* 1 */
     dsi->flags |= DSI_DISCONNECTED; /* 2 */
-    if (getppid() == 1)
+    if (getppid() == 1 || geteuid() == 0)
         return -1;
     return 0;
 }