]> arthur.barton.de Git - netatalk.git/commitdiff
support for function 0x7a
authordidg <didg>
Wed, 12 Mar 2003 15:07:00 +0000 (15:07 +0000)
committerdidg <didg>
Wed, 12 Mar 2003 15:07:00 +0000 (15:07 +0000)
add AFP3 login_ext for guest account
From Björn Fernhomberg, slighty modified by me

etc/afpd/afp_dsi.c
etc/afpd/afp_util.c
etc/afpd/auth.c
etc/afpd/auth.h
etc/uams/uams_guest.c
include/atalk/afp.h
include/atalk/dsi.h
libatalk/dsi/dsi_attn.c
libatalk/dsi/dsi_close.c
libatalk/dsi/dsi_stream.c
libatalk/dsi/dsi_tickle.c

index fc754c668715a721e3a1386767976129355bcadf..8d135e528430d5749fb5feb0b85305d1fcc722ff 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_dsi.c,v 1.26 2002-12-04 10:59:36 didg Exp $
+ * $Id: afp_dsi.c,v 1.27 2003-03-12 15:07:00 didg Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
@@ -244,6 +244,7 @@ void afp_over_dsi(AFPObj *obj)
     /* get stuck here until the end */
     while ((cmd = dsi_receive(dsi))) {
         child.tickle = 0;
+        dsi_sleep(dsi, 0); /* wake up */
 
         if (cmd == DSIFUNC_TICKLE) {
             /* so we don't get killed on the client side. */
index c76735213f48a35a1aec4ff0dad43d65042243ff..a80c83c799c6434fdbe5718f84c4715bd604217e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_util.c,v 1.2 2002-10-05 13:07:18 didg Exp $
+ * $Id: afp_util.c,v 1.3 2003-03-12 15:07:01 didg Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
@@ -76,11 +76,13 @@ const char *AfpNum2name(int num)
     case AFP_READ_EXT      : return "AFP_READ_EXT";         /*  60 */
     case AFP_WRITE_EXT     : return "AFP_WRITE_EXT";        /*  61 */
     case AFP_GETSESSTOKEN  : return "AFP_GETSESSTOKEN";     /*  64 */ 
+    case AFP_LOGIN_EXT     : return "AFP_LOGIN_EXT";        /*  63 */
     case AFP_DISCTOLDSESS  : return "AFP_DISCTOLDSESS";     /*  65 */
     case AFP_ENUMERATE_EXT : return "AFP_ENUMERATE_EXT";    /*  66 */
     case AFP_CATSEARCH_EXT : return "AFP_CATSEARCH_EXT";    /*  67 */
     /* version 3.1 */
     case AFP_ENUMERATE_EXT2: return "AFP_ENUMERATE_EXT2";   /*  68 */
+    case AFP_ZZZ  : return "AFP_ZZZ";      /* 122 */
                                                                                                                          
        case AFP_ADDICON       : return "AFP_ADDICON";          /* 192 */
        }                                                                                         
index da01ce610f323edbbdf6f68169f1cd48ec7e2658..3b3fdf23cbbe723e99b205329fd81a43e2ff5674 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: auth.c,v 1.41 2003-01-26 16:40:44 srittau Exp $
+ * $Id: auth.c,v 1.42 2003-03-12 15:07:02 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -307,9 +307,11 @@ static int login(AFPObj *obj, struct passwd *pwd, void (*logout)(void))
            enumerate_ext */
        uam_afpserver_action(AFP_CATSEARCH_EXT, UAM_AFPSERVER_POSTAUTH, afp_catsearch, NULL); 
        uam_afpserver_action(AFP_GETSESSTOKEN,  UAM_AFPSERVER_POSTAUTH, afp_getsession, NULL); 
-       uam_afpserver_action(AFP_DISCTOLDSESS,  UAM_AFPSERVER_POSTAUTH, afp_disconnect, NULL); 
        uam_afpserver_action(AFP_READ_EXT,      UAM_AFPSERVER_POSTAUTH, afp_read_ext, NULL); 
        uam_afpserver_action(AFP_WRITE_EXT,     UAM_AFPSERVER_POSTAUTH, afp_write_ext, NULL); 
+       uam_afpserver_action(AFP_DISCTOLDSESS,  UAM_AFPSERVER_POSTAUTH, afp_disconnect, NULL); 
+       uam_afpserver_action(AFP_ZZZ,  UAM_AFPSERVER_POSTAUTH, afp_zzz, NULL); 
+
        break;
     }
     obj->logout = logout;
@@ -322,6 +324,28 @@ static int login(AFPObj *obj, struct passwd *pwd, void (*logout)(void))
     return( AFP_OK );
 }
 
+/* ---------------------- */
+int afp_zzz (obj, ibuf, ibuflen, rbuf, rbuflen ) /* Function 122 */
+AFPObj       *obj;
+char         *ibuf, *rbuf;
+unsigned int ibuflen, *rbuflen;
+{
+    u_int32_t  retdata;
+
+    *rbuflen = 0;
+
+    retdata = 1;
+    *rbuflen = sizeof(retdata);
+    retdata = htonl(retdata);
+    memcpy(rbuf, &retdata, sizeof(retdata));
+    if (obj->proto == AFPPROTO_DSI) {
+        DSI *dsi = obj->handle;
+        dsi_sleep(dsi, 1);
+    }
+    rbuf += sizeof(retdata);
+    return AFP_OK;
+}
+   
 /* ---------------------- */
 int afp_getsession(obj, ibuf, ibuflen, rbuf, rbuflen )
 AFPObj       *obj;
@@ -362,6 +386,10 @@ unsigned int ibuflen, *rbuflen;
             /* memcpy (id, ibuf, idlen) */
         }
         break;
+    case 3: /* Jaguar */
+    case 4:
+       type = 0;
+       break;
     }
     *rbuflen = sizeof(type);
     type = htons(type);
@@ -406,7 +434,7 @@ int         ibuflen, *rbuflen;
     }   
     memcpy(&token, ibuf, tklen);
     /* killed old session, not easy */
-    return AFP_OK;
+    return AFPERR_SESSCLOS;   /* was AFP_OK */
 }
 
 /* ---------------------- */
@@ -562,7 +590,7 @@ unsigned int        ibuflen, *rbuflen;
     ibuflen -= len;    
 
     /* directory service name */
-    if (!ibuflen)
+    if (!ibuflen) 
         return send_reply(obj, AFPERR_PARAM);
     type = *ibuf;
     ibuf++;
@@ -578,9 +606,9 @@ unsigned int        ibuflen, *rbuflen;
         ibuflen--;
         break;
     case 3:
-        if (ibuflen <= sizeof(len16))
+        /* With "No User Authen" it is equal */
+        if (ibuflen < sizeof(len16)) 
             return send_reply(obj, AFPERR_PARAM);
-    
         memcpy(&len16, ibuf, sizeof(len16));
         ibuf += sizeof(len16);
         ibuflen -= sizeof(len16);
@@ -596,11 +624,8 @@ unsigned int       ibuflen, *rbuflen;
     ibuf += len;
     ibuflen -= len;
     
-    if (!ibuflen )
-        return send_reply(obj, AFPERR_PARAM);
-
     /* Pad */
-    if ((unsigned long) ibuf & 1) { /* pad character */
+    if (ibuflen && ((unsigned long) ibuf & 1)) { /* pad character */
         ibuf++;
         ibuflen--;
     }
index c1a40a61af8418e6e7fae119ac59664f5d16f3a3..cb6bd5077f58f2e09e2673c847cbea1d2d8be202 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: auth.h,v 1.4 2002-10-16 02:20:41 didg Exp $
+ * $Id: auth.h,v 1.5 2003-03-12 15:07:02 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -48,5 +48,6 @@ extern int    afp_logout __P((AFPObj *, char *, int, char *, int *));
 extern int      afp_getuserinfo __P((AFPObj *, char *, int, char *, int *));
 extern int      afp_getsession __P((AFPObj *, char *, unsigned int, char *, unsigned int *));
 extern int      afp_disconnect __P((AFPObj *, char *, int, char *, int *));
+extern int      afp_zzz __P((AFPObj *, char *, unsigned int, char *, unsigned int *));
 
 #endif /* auth.h */
index 9c08b72051b10e2fe24bfc08a15b8bc79cf62f8c..2b7697456eff3525c7aea3754269bddff904dab3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uams_guest.c,v 1.11 2002-10-13 06:18:14 didg Exp $
+ * $Id: uams_guest.c,v 1.12 2003-03-12 15:07:03 didg Exp $
  *
  * (c) 2001 (see COPYING)
  */
@@ -34,6 +34,7 @@ char *strchr (), *strrchr ();
 #include <atalk/afp.h>
 #include <atalk/uam.h>
 
+/* login and login_ext are almost the same */
 static int noauth_login(void *obj, struct passwd **uam_pwd,
                        char *ibuf, int ibuflen, 
                        char *rbuf, int *rbuflen)
@@ -70,6 +71,13 @@ static int noauth_login(void *obj, struct passwd **uam_pwd,
     return( AFP_OK );
 }
 
+static int noauth_login_ext(void *obj, char *uname, struct passwd **uam_pwd,
+                     char *ibuf, int ibuflen,
+                     char *rbuf, int *rbuflen)
+{
+        return ( noauth_login (obj, uam_pwd, ibuf, ibuflen, rbuf, rbuflen));
+}
+
 
 /* Printer NoAuthUAM Login */
 int noauth_printer(start, stop, username, out)
@@ -119,9 +127,10 @@ int noauth_printer(start, stop, username, out)
 
 static int uam_setup(const char *path)
 {
-  if (uam_register(UAM_SERVER_LOGIN, path, "No User Authent",
-              noauth_login, NULL, NULL) < 0)
-       return -1;
+  if (uam_register(UAM_SERVER_LOGIN_EXT, path, "No User Authent",
+                   noauth_login, NULL, NULL, noauth_login_ext) < 0)
+        return -1;
+
   if (uam_register(UAM_SERVER_PRINTAUTH, path, "NoAuthUAM",
                noauth_printer) < 0)
        return -1;
index 02abaa3c90085ab1c9abf8093275cae645a717b8..7cd08fc5430b7b4ec6350cc79fcb5aa70db42297 100644 (file)
@@ -198,5 +198,6 @@ typedef enum {
 
 /* version 3.1 */
 #define AFP_ENUMERATE_EXT2      68
+#define AFP_ZZZ                 122
 
 #endif
index f30a90ee27219b823368e8e29ea3b7d3751543f5..8bb49345ae860859c2b5dc9663e7b995221d64f5 100644 (file)
@@ -65,6 +65,7 @@ typedef struct DSI {
   int statuslen;
   unsigned int datalen, cmdlen;
   size_t read_count, write_count;
+  int asleep; /* client won't reply AFP 0x7a ? */
   /* inited = initialized?, child = a child?, noreply = send reply? */
   char child, inited, noreply;
   const char *program; 
@@ -138,6 +139,7 @@ extern int  dsi_cmdreply __P((DSI *, const int));
 extern int dsi_tickle __P((DSI *));
 extern void dsi_getstatus __P((DSI *));
 extern void dsi_close __P((DSI *));
+extern void dsi_sleep __P((DSI *, const int ));
 
 /* low-level stream commands -- in dsi_stream.c */
 extern size_t dsi_stream_write __P((DSI *, void *, const size_t));
index ae0883b6e0dcd2bd1304ef561bc12bbece12e25c..b22db8d652563b1091337f4522035f347449dfc4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: dsi_attn.c,v 1.4 2002-12-04 10:59:37 didg Exp $
+ * $Id: dsi_attn.c,v 1.5 2003-03-12 15:07:05 didg Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * All rights reserved. See COPYRIGHT.
@@ -35,6 +35,9 @@ int dsi_attention(DSI *dsi, AFPUserBytes flags)
   u_int32_t len, nlen;
   u_int16_t id;
 
+  if (dsi->asleep)
+      return 1;
+      
   id = htons(dsi_serverID(dsi));
   flags = htons(flags);
   len = MIN(sizeof(flags), dsi->attn_quantum);
index e833db896aa1ddf73bbfaa73efc7e183b7726fb6..23c9cf46ce9898faf04b5b0a3dd19fe891d300b3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: dsi_close.c,v 1.3 2001-06-29 14:14:46 rufustfirefly Exp $
+ * $Id: dsi_close.c,v 1.4 2003-03-12 15:07:06 didg Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * All rights reserved. See COPYRIGHT.
 void dsi_close(DSI *dsi)
 {
   /* server generated. need to set all the fields. */
-  dsi->header.dsi_flags = DSIFL_REQUEST;
-  dsi->header.dsi_command = DSIFUNC_CLOSE;
-  dsi->header.dsi_requestID = htons(dsi_serverID(dsi));
-  dsi->header.dsi_code = dsi->header.dsi_reserved = htonl(0);
-  dsi->cmdlen = 0; 
-
-  dsi_send(dsi);
-  dsi->proto_close(dsi);
+  if (!dsi->asleep) {
+      dsi->header.dsi_flags = DSIFL_REQUEST;
+      dsi->header.dsi_command = DSIFUNC_CLOSE;
+      dsi->header.dsi_requestID = htons(dsi_serverID(dsi));
+      dsi->header.dsi_code = dsi->header.dsi_reserved = htonl(0);
+      dsi->cmdlen = 0; 
+      dsi_send(dsi);
+      dsi->proto_close(dsi);
+  }
   free(dsi);
 }
index f2d76cd40b74365e8bd4b2d4a1adf355b21d59dc..b177b579dde077b1ea17e87a95236cf049f203d0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: dsi_stream.c,v 1.10 2003-01-12 14:40:05 didg Exp $
+ * $Id: dsi_stream.c,v 1.11 2003-03-12 15:07:06 didg Exp $
  *
  * Copyright (c) 1998 Adrian Sun (asun@zoology.washington.edu)
  * All rights reserved. See COPYRIGHT.
@@ -87,6 +87,10 @@ size_t dsi_stream_read(DSI *dsi, void *data, const size_t length)
   return stored;
 }
 
+void dsi_sleep(DSI *dsi, const int state)
+{
+    dsi->asleep = state;
+}
 
 /* write data. 0 on failure. this assumes that dsi_len will never
  * cause an overflow in the data buffer. */
index 6be41e486e23fb7d93ee83eb2f17aa40a95ff242..6f1e095d533ad1707f083e41e0617f40af08375e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: dsi_tickle.c,v 1.4 2002-12-04 10:59:37 didg Exp $
+ * $Id: dsi_tickle.c,v 1.5 2003-03-12 15:07:07 didg Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * All rights reserved. See COPYRIGHT.
@@ -27,6 +27,9 @@ int dsi_tickle(DSI *dsi)
   u_int16_t id;
   int ret;
   
+  if (dsi->asleep)
+      return 1;
+
   id = htons(dsi_serverID(dsi));
 
   memset(block, 0, sizeof(block));