]> arthur.barton.de Git - netatalk.git/commitdiff
more AFP 3.x stuff
authordidg <didg>
Sun, 13 Oct 2002 06:18:13 +0000 (06:18 +0000)
committerdidg <didg>
Sun, 13 Oct 2002 06:18:13 +0000 (06:18 +0000)
etc/afpd/directory.c
etc/afpd/file.c
etc/afpd/file.h
etc/afpd/filedir.c
etc/afpd/fork.c
etc/uams/uams_guest.c
etc/uams/uams_pam.c

index 496fb858c6442836765c9258b9048a9ef1d04fce..fdee2db3e358c64768924f6ad0530d05f1d80351 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.c,v 1.45 2002-10-12 18:20:48 didg Exp $
+ * $Id: directory.c,v 1.46 2002-10-13 06:18:13 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -816,6 +816,7 @@ char        **cpath;
     int                        len;
     int                        olen = 0;
     u_int32_t   hint;
+    u_int16_t   len16;
     int         size = 0;
     char        sep;
                
@@ -830,9 +831,12 @@ char       **cpath;
     case 3:
        if (afp_version >= 30) {
            data++;
-           hint = ntohl(*data);
-           data += 4;
-           len = ntohs(*data);
+           memcpy(&hint, data, sizeof(hint));
+           hint = ntohl(hint);
+           data += sizeof(hint);
+           
+           memcpy(&len16, data, sizeof(len16));
+           len = ntohs(len16);
            data += 2;
            size = 7;
            sep = '/';
@@ -885,7 +889,7 @@ char        **cpath;
             return &ret;
         }
 
-        if ( *data == '\0' ) {
+        if (!*data || *data == sep ) {
             data++;
             len--;
         }
@@ -1689,7 +1693,7 @@ int               ibuflen, *rbuflen;
     }
 
     memset(&ad, 0, sizeof(ad));
-    if (ad_open( "", vol_noadouble(vol)|ADFLAGS_HF|ADFLAGS_DIR,
+    if (ad_open( ".", vol_noadouble(vol)|ADFLAGS_HF|ADFLAGS_DIR,
                  O_RDWR|O_CREAT, 0666, &ad ) < 0)  {
         if (vol_noadouble(vol))
             goto createdir_done;
index b9a5507fda2b2108a5facf03a36c84da340a7578..f5b3bb3d44626f7eca41261d15651d49babf620f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: file.c,v 1.64 2002-10-12 04:02:46 didg Exp $
+ * $Id: file.c,v 1.65 2002-10-13 06:18:13 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -355,6 +355,7 @@ int getmetadata(struct vol *vol,
         case FILPBIT_PDINFO :
             if (afp_version >= 30) { /* UTF8 name */
                 utf8 = kTextEncodingUTF8;
+                nameoff = data;
                 data += sizeof( u_int16_t );
             }
             else {
@@ -969,6 +970,49 @@ rename_retry:
     return( AFP_OK );
 }
 
+int copy_path_name(char *newname, char *ibuf)
+{
+char        type = *ibuf;
+size_t      plen = 0;
+u_int16_t   len16;
+u_int32_t   hint;
+
+    if ( type != 2 || (afp_version >= 30 && type != 3) ) {
+        return -1;
+    }
+    ibuf++;
+    switch (type) {
+    case 2:
+        if (( plen = (unsigned char)*ibuf++ ) != 0 ) {
+            strncpy( newname, ibuf, plen );
+            newname[ plen ] = '\0';
+            if (strlen(newname) != plen) {
+                /* there's \0 in newname, e.g. it's a pathname not
+                 * only a filename. 
+                */
+               return -1;
+            }
+        }
+        break;
+    case 3:
+        memcpy(&hint, ibuf, sizeof(hint));
+        ibuf += sizeof(hint);
+           
+        memcpy(&len16, ibuf, sizeof(len16));
+        ibuf += sizeof(len16);
+        plen = ntohs(len16);
+        if (plen) {
+            strncpy( newname, ibuf, plen );
+            newname[ plen ] = '\0';
+            if (strchr(newname,'/')) {
+               return -1;
+            }
+        }
+        break;
+    }
+    return plen;
+}
+
 /* -----------------------------------
 */
 int afp_copyfile(obj, ibuf, ibuflen, rbuf, rbuflen )
@@ -981,7 +1025,6 @@ int                ibuflen, *rbuflen;
     char       *newname, *p, *upath;
     struct path *s_path;
     u_int32_t  sdid, ddid;
-    size_t      plen;
     int         err, retvalue = AFP_OK;
     u_int16_t  svid, dvid;
 
@@ -1051,19 +1094,10 @@ int             ibuflen, *rbuflen;
     }
 
     /* one of the handful of places that knows about the path type */
-    if ( *ibuf++ != 2 ) {
+    if (copy_path_name(newname, ibuf) < 0) {
         return( AFPERR_PARAM );
     }
-    if (( plen = (unsigned char)*ibuf++ ) != 0 ) {
-        strncpy( newname, ibuf, plen );
-        newname[ plen ] = '\0';
-        if (strlen(newname) != plen) {
-            /* there's \0 in newname, e.g. it's a pathname not
-             * only a filename. 
-            */
-            return( AFPERR_PARAM );
-        }
-    }
+
     upath = mtoupath(vol, newname);
     if ( (err = copyfile(p, upath , newname, vol_noadouble(vol))) < 0 ) {
         return err;
index b3b8babcf887234fc00128140af8cc50561c0e62..cc5b9835c49621794e45f2119f4cc01dcea3b06b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: file.h,v 1.13 2002-10-12 04:02:46 didg Exp $
+ * $Id: file.h,v 1.14 2002-10-13 06:18:13 didg Exp $
  *
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
@@ -50,7 +50,7 @@ extern const u_char   ufinderi[];
 #define FILPBIT_DFLEN   9
 #define FILPBIT_RFLEN   10
 #define FILPBIT_EXTDFLEN 11
-#define FILPBIT_PDINFO   13    /* ProDOS Info */
+#define FILPBIT_PDINFO   13    /* ProDOS Info/ UTF8 name */
 #define FILPBIT_EXTRFLEN 14
 
 /* attribute bits. (d) = directory attribute bit as well. */
@@ -88,6 +88,7 @@ extern int copyfile     __P((char *, char *, char *, const int));
 extern int deletefile   __P((char *, int));
 
 extern void *get_finderinfo __P((const char *, struct adouble *, void *));
+extern int  copy_path_name __P((char *, char *i));
 
 /* FP functions */
 extern int      afp_exchangefiles __P((AFPObj *, char *, int, char *, int *));
index 3913b9e809fea7a765ec6e6d65d118024285226e..22c38870103ed08d57a08abc9db90767956bf4fa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: filedir.c,v 1.33 2002-10-11 14:18:31 didg Exp $
+ * $Id: filedir.c,v 1.34 2002-10-13 06:18:13 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -444,7 +444,7 @@ int         ibuflen, *rbuflen;
     char        *oldname, *newname;
     struct path *path;
     u_int32_t  did;
-    size_t      plen;
+    int         plen;
     u_int16_t  vid;
     int         isdir = 0;
     int         rc;
@@ -494,18 +494,11 @@ int               ibuflen, *rbuflen;
     }
 
     /* another place where we know about the path type */
-    if ( *ibuf++ != 2 ) {
+    if ((plen = copy_path_name(newname, ibuf)) < 0) {
         return( AFPERR_PARAM );
     }
 
-    if (( plen = (unsigned char)*ibuf++ ) != 0 ) {
-        strncpy( newname, ibuf, plen );
-        newname[ plen ] = '\0';
-        if (strlen(newname) != plen) {
-            return( AFPERR_PARAM );
-        }
-    }
-    else {
+    if (!plen) {
         return AFP_OK; /* newname == oldname same dir */
     }
     
@@ -632,7 +625,7 @@ int         ibuflen, *rbuflen;
     char       *oldname, *newname;
     struct path *path;
     int                did;
-    size_t      plen;
+    int         plen;
     u_int16_t  vid;
     int         rc;
 #ifdef DROPKLUDGE
@@ -693,21 +686,14 @@ int               ibuflen, *rbuflen;
     }
 
     /* one more place where we know about path type */
-    if ( *ibuf++ != 2 ) {
+    if ((plen = copy_path_name(newname, ibuf)) < 0) {
         return( AFPERR_PARAM );
     }
 
-    if (( plen = (unsigned char)*ibuf++ ) != 0 ) {
-        strncpy( newname, ibuf, plen );
-        newname[ plen ] = '\0';
-        if (strlen(newname) != plen) {
-            return( AFPERR_PARAM );
-        }
-    }
-    else {
+    if (!plen) {
         strcpy(newname, oldname);
     }
-    
+
     rc = moveandrename(vol, sdir, oldname, newname, isdir);
 
     if ( rc == AFP_OK ) {
index 8330220f379ca5d4207c85ba4a37e45aa5ef4c57..d1f58587a1339470950013a2cf89241bb441869d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: fork.c,v 1.38 2002-10-11 14:18:32 didg Exp $
+ * $Id: fork.c,v 1.39 2002-10-13 06:18:14 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -591,6 +591,7 @@ int     is64;
     if (is64) {
         temp = htonl(offset >> 32);
         memcpy(rbuf, &temp, sizeof( temp ));
+        rbuf += sizeof(temp);
         ret = sizeof( temp );
         offset &= 0xffffffff;
     }
@@ -1361,7 +1362,9 @@ int                 ibuflen, *rbuflen;
     return write_fork(obj, ibuf, ibuflen, rbuf, rbuflen, 0);
 }
 
-/* ---------------------------- */
+/* ---------------------------- 
+ * FIXME need to deal with SIGXFSZ signal
+*/
 int afp_write_ext(obj, ibuf, ibuflen, rbuf, rbuflen)
 AFPObj              *obj;
 char                *ibuf, *rbuf;
index 9521e362c29c18dbbb3714ba1395ea42ee746a71..9c08b72051b10e2fe24bfc08a15b8bc79cf62f8c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uams_guest.c,v 1.10 2002-09-29 23:30:20 sibaz Exp $
+ * $Id: uams_guest.c,v 1.11 2002-10-13 06:18:14 didg Exp $
  *
  * (c) 2001 (see COPYING)
  */
@@ -8,6 +8,7 @@
 #include "config.h"
 #endif /* HAVE_CONFIG_H */
 
+#ifndef ATACC
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
@@ -139,3 +140,4 @@ UAM_MODULE_EXPORT struct uam_export uams_guest = {
   UAM_MODULE_VERSION,
   uam_setup, uam_cleanup
 };
+#endif
index 15bc3e449517dde1333658f54fce37e8af9c63cb..b56fbffd10ff6795d8d0e470d9cc65218509204b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uams_pam.c,v 1.12 2002-09-29 23:30:20 sibaz Exp $
+ * $Id: uams_pam.c,v 1.13 2002-10-13 06:18:14 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) 
@@ -10,6 +10,7 @@
 #include "config.h"
 #endif /* HAVE_CONFIG_H */
 
+#ifndef ATACC
 #include <stdio.h>
 #include <stdlib.h>
 #ifdef HAVE_UNISTD_H
@@ -419,3 +420,4 @@ UAM_MODULE_EXPORT struct uam_export uams_pam = {
   UAM_MODULE_VERSION,
   uam_setup, uam_cleanup
 };
+#endif