]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/dsi/dsi_stream.c
Merge master
[netatalk.git] / libatalk / dsi / dsi_stream.c
index 5c99ac2c363a084a70bffc741fcb8934ccb29844..4b92d2259ed7f5ea13a734909ed4c523ef90473d 100644 (file)
@@ -28,7 +28,6 @@
 
 #include <atalk/logger.h>
 #include <atalk/dsi.h>
-#include <netatalk/endian.h>
 #include <atalk/util.h>
 
 #define min(a,b)  ((a) < (b) ? (a) : (b))
@@ -237,11 +236,17 @@ static void unblock_sig(DSI *dsi)
  *
  * 1. close the socket
  * 2. set the DSI_DISCONNECTED flag
+ *
+ * @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 (geteuid() == 0)
+        return -1;
     return 0;
 }
 
@@ -377,12 +382,14 @@ size_t dsi_stream_read(DSI *dsi, void *data, const size_t length)
   while (stored < length) {
       len = buf_read(dsi, (u_int8_t *) data + stored, length - stored);
       if (len == -1 && (errno == EINTR || errno == EAGAIN)) {
-          LOG(log_debug, logtype_dsi, "dsi_stream_read: select read loop");
+          LOG(log_maxdebug, logtype_dsi, "dsi_stream_read: select read loop");
           continue;
       } else if (len > 0) {
           stored += len;
       } else { /* eof or error */
           /* don't log EOF error if it's just after connect (OSX 10.3 probe) */
+          if (errno == ECONNRESET)
+              dsi->flags |= DSI_GOT_ECONNRESET;
           if (len || stored || dsi->read_count) {
               if (! (dsi->flags & DSI_DISCONNECTED)) {
                   LOG(log_error, logtype_dsi, "dsi_stream_read: len:%d, %s",