]> arthur.barton.de Git - netatalk.git/commitdiff
Fix extended sleep
authorFrank Lahm <franklahm@googlemail.com>
Fri, 1 Apr 2011 18:14:03 +0000 (20:14 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Fri, 1 Apr 2011 18:14:03 +0000 (20:14 +0200)
etc/afpd/auth.c

index 5226f7b379cdd3c2b8012292de6da1fc8be84d6f..94f7601db62334f34d29738709e7ed0071fe0854 100644 (file)
@@ -436,12 +436,14 @@ static int login(AFPObj *obj, struct passwd *pwd, void (*logout)(void), int expi
 }
 
 /* ---------------------- */
-int afp_zzz(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbuflen)
+int afp_zzz(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
 {
     uint32_t data;
     DSI *dsi = (DSI *)AFPobj->handle;
 
     *rbuflen = 0;
+    ibuf += 2;
+    ibuflen -= 2;
 
     if (ibuflen < 4)
         return AFPERR_MISC;
@@ -470,19 +472,22 @@ int afp_zzz(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbu
             LOG(log_note, logtype_afpd, "afp_zzz: entering normal sleep");
         }
     }
-    /*
-     * According to AFP 3.3 spec we should not return anything,
-     * but eg 10.5.8 server still returns the numbers of hours
-     * the server is keeping the sessino (ie max sleeptime).
-     */
-    data = obj->options.sleep / 120; /* hours */
-    if (!data) {
-        data = 1;
+
+    if (dsi->flags & DSI_SLEEPING) {
+        /*
+         * According to AFP 3.3 spec we should not return anything,
+         * but eg 10.5.8 server still returns the numbers of hours
+         * the server is keeping the sessino (ie max sleeptime).
+         */
+        data = obj->options.sleep / 120; /* hours */
+        if (!data) {
+            data = 1;
+        }
+        *rbuflen = sizeof(data);
+        data = htonl(data);
+        memcpy(rbuf, &data, sizeof(data));
+        rbuf += sizeof(data);
     }
-    *rbuflen = sizeof(data);
-    data = htonl(data);
-    memcpy(rbuf, &data, sizeof(data));
-    rbuf += sizeof(data);
 
     return AFP_OK;
 }