]> arthur.barton.de Git - netatalk.git/commitdiff
- better error reporting, don't always return noobj.
authordidg <didg>
Wed, 8 Jan 2003 15:01:32 +0000 (15:01 +0000)
committerdidg <didg>
Wed, 8 Jan 2003 15:01:32 +0000 (15:01 +0000)
- remove unreachable code in cname.
- revert previous patch for permission.
- check pathname len in movecwd.

12 files changed:
etc/afpd/afs.c
etc/afpd/appl.c
etc/afpd/desktop.c
etc/afpd/directory.c
etc/afpd/directory.h
etc/afpd/file.c
etc/afpd/filedir.c
etc/afpd/fork.c
etc/afpd/globals.h
etc/afpd/unix.c
etc/afpd/volume.c
etc/afpd/volume.h

index 365fca87cbea7cb08bd95481cbe38be824480e6b..0308dde2659efb400be887598c3275776851c303 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afs.c,v 1.13 2002-10-11 14:18:24 didg Exp $
+ * $Id: afs.c,v 1.14 2003-01-08 15:01:32 didg Exp $
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
  */
@@ -94,12 +94,12 @@ int         ibuflen, *rbuflen;
     ibuf += sizeof( int );
     if (( dir = dirlookup( vol, did )) == NULL ) {
         *rbuflen = 0;
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
 
     if (( path = cname( vol, dir, &ibuf )) == NULL ) {
         *rbuflen = 0;
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
     if ( *path->m_name != '\0' ) {
         *rbuflen = 0;
@@ -187,16 +187,16 @@ int               ibuflen, *rbuflen;
     ibuf += sizeof( int );
     if (( dir = dirlookup( vol, did )) == NULL ) {
         *rbuflen = 0;
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
 
     if (( path = cname( vol, dir, &ibuf )) == NULL ) {
         *rbuflen = 0;
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
     if ( *path->m_name != '\0' ) {
         *rbuflen = 0;
-        return( AFPERR_BITMAP );
+        return afp_errno;
     }
 
     if ((int)ibuf & 1 ) {
index 2e6c0b714f22303c645cbde13144034d7434a217..f6bd37ac63040cb88055911fdda57176eb4edc30 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: appl.c,v 1.8 2002-10-11 14:18:25 didg Exp $
+ * $Id: appl.c,v 1.9 2003-01-08 15:01:33 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -188,7 +188,7 @@ int         ibuflen, *rbuflen;
     memcpy( &did, ibuf, sizeof( did ));
     ibuf += sizeof( did );
     if (( dir = dirlookup( vol, did )) == NULL ) {
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
 
     memcpy( creator, ibuf, sizeof( creator ));
@@ -198,7 +198,7 @@ int         ibuflen, *rbuflen;
     ibuf += sizeof( appltag );
 
     if (( path = cname( vol, dir, &ibuf )) == NULL ) {
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
     if ( *path->m_name == '\0' ) {
         return( AFPERR_BADTYPE );
@@ -274,14 +274,14 @@ int               ibuflen, *rbuflen;
     memcpy( &did, ibuf, sizeof( did ));
     ibuf += sizeof( did );
     if (( dir = dirlookup( vol, did )) == NULL ) {
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
 
     memcpy( creator, ibuf, sizeof( creator ));
     ibuf += sizeof( creator );
 
     if (( path = cname( vol, dir, &ibuf )) == NULL ) {
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
     if ( *path->m_name == '\0' ) {
         return( AFPERR_BADTYPE );
index 230fe718a72acaf9f28b74573bc55e0fb142789b..e26993bb4fb972e3e2fefb181a7ca39c2183a44b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: desktop.c,v 1.19 2002-10-11 14:18:26 didg Exp $
+ * $Id: desktop.c,v 1.20 2003-01-08 15:01:33 didg Exp $
  *
  * See COPYRIGHT.
  *
@@ -618,7 +618,7 @@ char *mtoupath(const struct vol *vol, char *mpath)
     char       *m, *u;
     int                 i = 0;
     int          changed = 0;
-    
+        
     if ( *mpath == '\0' ) {
         return( "." );
     }
@@ -630,7 +630,6 @@ char *mtoupath(const struct vol *vol, char *mpath)
         mpath = m;
     }
 #endif /* FILE_MANGLING */
-
     m = mpath;
     u = upath;
     while ( *m != '\0' ) {
@@ -642,7 +641,6 @@ char *mtoupath(const struct vol *vol, char *mpath)
 
         /* we have a code page. we only use the ascii range
          * if we have map ascii specified. */
-#if 1
         if (vol->v_mtoupage && ((*m & 0x80) ||
                                 vol->v_flags & AFPVOL_MAPASCII)) {
             *u = vol->v_mtoupage->map[(unsigned char) *m].value;
@@ -658,8 +656,7 @@ char *mtoupath(const struct vol *vol, char *mpath)
                 *u++ = hexdig[ ( *m & 0xf0 ) >> 4 ];
                 *u = hexdig[ *m & 0x0f ];
             }
-        } else
-#endif /* 1 */
+        } else {
 #if AD_VERSION == AD_VERSION1
             if ((((vol->v_flags & AFPVOL_NOHEX) == 0) &&
                     (!isascii(*m) || *m == '/')) ||
@@ -678,6 +675,7 @@ char *mtoupath(const struct vol *vol, char *mpath)
                 changed = 1;
             } else
                 *u = *m;
+        }
         u++;
         i++;
         m++;
@@ -699,6 +697,7 @@ char *utompath(const struct vol *vol, char *upath)
     static char  mpath[ MAXPATHLEN + 1];
     char        *m, *u;
     int          h;
+    int          changed = 0;
 
     /* do the hex conversion */
     u = upath;
@@ -709,6 +708,7 @@ char *utompath(const struct vol *vol, char *upath)
         if (vol->v_utompage && ((*u & 0x80) ||
                                 (vol->v_flags & AFPVOL_MAPASCII))) {
             *m = vol->v_utompage->map[(unsigned char) *u].value;
+            changed = 1;
         } else
 #endif /* 1 */
             if ( *u == ':' && *(u+1) != '\0' && islxdigit( *(u+1)) &&
@@ -718,6 +718,7 @@ char *utompath(const struct vol *vol, char *upath)
                 ++u;
                 h |= hextoint( *u );
                 *m = h;
+                changed = 1;
             } else
                 *m = *u;
 
@@ -731,16 +732,20 @@ char *utompath(const struct vol *vol, char *upath)
         m++;
     }
     *m = '\0';
+    m = mpath;
 
 #ifdef FILE_MANGLING
-    strcpy(mpath,mangle(vol, mpath));
+    m = mangle(vol, mpath);
+    if (m != mpath) {
+        changed = 1;
+    }
 #endif /* FILE_MANGLING */
 
 #ifdef DEBUG
     LOG(log_debug, logtype_afpd, "utompath: '%s':'%s'", upath, mpath);
 #endif /* DEBUG */
 
-    return( mpath );
+    return((changed)? m:upath );
 }
 
 int afp_addcomment(obj, ibuf, ibuflen, rbuf, rbuflen )
@@ -770,11 +775,11 @@ int               ibuflen, *rbuflen;
     memcpy( &did, ibuf, sizeof( did ));
     ibuf += sizeof( did );
     if (( dir = dirlookup( vol, did )) == NULL ) {
-        return( AFPERR_NOOBJ );
+       return afp_errno;
     }
 
     if (( path = cname( vol, dir, &ibuf )) == NULL ) {
-        return( AFPERR_NOOBJ );
+       return afp_errno;
     }
 
     if ((u_long)ibuf & 1 ) {
@@ -845,11 +850,11 @@ int               ibuflen, *rbuflen;
     memcpy( &did, ibuf, sizeof( did ));
     ibuf += sizeof( did );
     if (( dir = dirlookup( vol, did )) == NULL ) {
-        return( AFPERR_NOOBJ );
+       return afp_errno;
     }
 
     if (( s_path = cname( vol, dir, &ibuf )) == NULL ) {
-        return( AFPERR_NOOBJ );
+       return afp_errno;
     }
 
     upath = s_path->u_name;
@@ -911,11 +916,11 @@ int               ibuflen, *rbuflen;
     memcpy( &did, ibuf, sizeof( did ));
     ibuf += sizeof( did );
     if (( dir = dirlookup( vol, did )) == NULL ) {
-        return( AFPERR_NOOBJ );
+       return afp_errno;
     }
 
     if (( s_path = cname( vol, dir, &ibuf )) == NULL ) {
-        return( AFPERR_NOOBJ );
+       return afp_errno;
     }
 
     upath = s_path->u_name;
index f2d4b8e0f138cf62c82ff8531ce5211c8e850cb5..32c73ba1d590fd906e8e9e84cce8d4a2f9fd34cd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.c,v 1.54 2003-01-07 15:55:21 rlewczuk Exp $
+ * $Id: directory.c,v 1.55 2003-01-08 15:01:33 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -60,6 +60,7 @@ char *strchr (), *strrchr ();
 #include "unix.h"
 
 struct dir     *curdir;
+int             afp_errno;
 
 #define SENTINEL (&sentinel)
 static struct dir sentinel = { SENTINEL, SENTINEL, NULL, DIRTREE_COLOR_BLACK,
@@ -99,9 +100,10 @@ u_int32_t   did;
 
 
     /* check for 0 did */
-    if (!did)
+    if (!did) {
+        afp_errno = AFPERR_PARAM;
         return NULL;
-
+    }
     if ( did == DIRDID_ROOT_PARENT ) {
         if (!rootpar.d_did)
             rootpar.d_did = DIRDID_ROOT_PARENT;
@@ -110,6 +112,7 @@ u_int32_t   did;
     }
 
     dir = vol->v_root;
+    afp_errno = AFPERR_NOOBJ;
     while ( dir != SENTINEL ) {
         if (dir->d_did == did)
             return dir->d_m_name ? dir : NULL;
@@ -145,6 +148,7 @@ u_int32_t   did;
 
     id = did;
     if ((upath = cnid_resolve(vol->v_db, &id, buffer, buflen)) == NULL) {
+        afp_errno = AFPERR_NOOBJ;
         return NULL;
     }
     ptr = path + MAXPATHLEN;
@@ -159,13 +163,17 @@ u_int32_t did;
         if (ret != NULL) {
             break;
         }
-        if ((upath = cnid_resolve(vol->v_db, &id, buffer, buflen)) == NULL)
+        if ((upath = cnid_resolve(vol->v_db, &id, buffer, buflen)) == NULL) {
+            afp_errno = AFPERR_NOOBJ;
             return NULL;
+        }
         mpath = utompath(vol, upath);
         len = strlen(mpath) + 1;
         pathlen += len;
-        if (pathlen > 255)
+        if (pathlen > 255) {
+            afp_errno = AFPERR_PARAM;
             return NULL;
+        }
         strcpy(ptr - len, mpath);
         ptr -= len;
     }
@@ -436,7 +444,6 @@ struct dir  *dir;
  * process. It's fixable within afpd if fnctl_lock, doable with smb and
  * next to impossible for nfs and local filesystem access.
  */
 static void dir_invalidate( vol, dir )
 const struct vol *vol;
 struct dir *dir;
@@ -811,17 +818,16 @@ char      **cpath;
     static struct path ret;
 
     char               *data, *p;
-    char        *u;
     int                        extend = 0;
     int                        len;
-    int                        olen = 0;
     u_int32_t   hint;
     u_int16_t   len16;
     int         size = 0;
     char        sep;
                
     data = *cpath;
-    switch (*data) { /* path type */
+    afp_errno = AFPERR_NOOBJ;
+    switch (ret.m_type = *data) { /* path type */
     case 2:
        data++;
        len = (unsigned char) *data++;
@@ -844,12 +850,12 @@ char      **cpath;
         }
         /* else it's an error */
     default:
+        afp_errno = AFPERR_PARAM;
         return( NULL );
     
     }
     *cpath += len + size;
     *path = '\0';
-    u = NULL;
     ret.m_name = path;
     ret.st_errno = 0;
     ret.st_valid = 0;
@@ -857,36 +863,19 @@ char      **cpath;
         if ( len == 0 ) {
             if ( !extend && movecwd( vol, dir ) < 0 ) {
                /* it's tricky:
-                  movecwd failed some of dir path is not there anymore.
+                  movecwd failed some of dir path are not there anymore.
                   FIXME Is it true with other errors?
-                  if path == '\0' ==> the cpath parameter is that dir,
-                  and maybe we are trying to recreate it! So we can't 
-                  fail here.
-                  
+                  so we remove dir from the cache 
                */
                if (dir->d_did == DIRDID_ROOT_PARENT) 
-                       return NULL;
-               if (errno != ENOENT && errno != ENOTDIR)
+                   return NULL;
+               if (afp_errno == AFPERR_ACCESS)
                    return NULL;                
 
-               cdir = dir->d_parent;
                dir_invalidate(vol, dir);
-               if (*path != '\0' || u == NULL) {
-                       /* FIXME: if path != '\0' then extend != 0 ?
-                        * u == NUL ==> cpath is something like:
-                        * toto\0\0\0
-                       */
-                       return NULL;
-               }
-               if (movecwd(vol, cdir) < 0) {
-                       printf("can't change to parent\n");
-                       return NULL; /* give up the whole tree is out of synch*/
-               }
-                               /* restore the previous token */
-                       strncpy(path, u, olen);
-                       path[olen] = '\0';
+               return NULL;
             }
-            if (!ret.st_valid || *path == '\0') {
+            if (*path == '\0') {
                ret.u_name = ".";
             }               
             return &ret;
@@ -896,8 +885,6 @@ char        **cpath;
             data++;
             len--;
         }
-       u = NULL;
-
         while (*data == sep && len > 0 ) {
             if ( dir->d_parent == NULL ) {
                 return NULL;
@@ -909,10 +896,6 @@ char       **cpath;
 
         /* would this be faster with strlen + strncpy? */
         p = path;
-        if (len > 0) {
-               u = data;
-               olen = len;
-        }        
         while ( *data != sep && len > 0 ) {
             *p++ = *data++;
             len--;
@@ -947,7 +930,7 @@ char        **cpath;
                           we delete dir from the cache and abort.
                        */
                        if ( dir->d_did != DIRDID_ROOT_PARENT && 
-                             (errno == ENOENT || errno == ENOTDIR)) {
+                             (afp_errno != AFPERR_ACCESS)) {
                            dir_invalidate(vol, dir);
                        }
                         return NULL;
@@ -989,7 +972,7 @@ struct dir  *dir;
         return( 0 );
     }
     if ( dir->d_did == DIRDID_ROOT_PARENT) {
-        errno = 0;     /* errno is checked in file.c */
+        afp_errno = AFPERR_PARAM;
         return( -1 );
     }
 
@@ -997,19 +980,36 @@ struct dir        *dir;
     *p-- = '\0';
     *p = '.';
     for ( d = dir; d->d_parent != NULL && d != curdir; d = d->d_parent ) {
-        *--p = '/';
         u = d->d_u_name;
         n = strlen( u );
+        if (p -n -1 < path) {
+            afp_errno = AFPERR_PARAM;
+            return -1;
+        }
+        *--p = '/';
         p -= n;
         strncpy( p, u, n );
     }
     if ( d != curdir ) {
-        *--p = '/';
         n = strlen( vol->v_path );
+        if (p -n -1 < path) {
+            afp_errno = AFPERR_PARAM;
+            return -1;
+        }
+        *--p = '/';
         p -= n;
         strncpy( p, vol->v_path, n );
     }
     if ( chdir( p ) < 0 ) {
+        switch (errno) {
+        case EACCES:
+        case EPERM:
+            afp_errno = AFPERR_ACCESS;
+            break;
+        default:
+            afp_errno = AFPERR_NOOBJ;
+        
+        }
         return( -1 );
     }
     curdir = dir;
@@ -1284,7 +1284,7 @@ int               ibuflen, *rbuflen;
     ibuf += sizeof( int );
 
     if (( dir = dirlookup( vol, did )) == NULL ) {
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
 
     memcpy( &bitmap, ibuf, sizeof( bitmap ));
@@ -1292,7 +1292,7 @@ int               ibuflen, *rbuflen;
     ibuf += sizeof( bitmap );
 
     if (( path = cname( vol, dir, &ibuf )) == NULL ) {
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
 
     if ( *path->m_name != '\0' ) {
@@ -1319,6 +1319,7 @@ int               ibuflen, *rbuflen;
 */
 
 struct path Cur_Path = {
+    0,
     "",  /* mac name */
     ".", /* unix name */
     0,  /* stat is not set */
@@ -1658,14 +1659,7 @@ int              ibuflen, *rbuflen;
     }
 
     if (( s_path = cname( vol, dir, &ibuf )) == NULL ) {
-        switch( errno ) {
-        case EACCES:
-            return( AFPERR_ACCESS );
-        case EEXIST:                           /* FIXME this one is impossible? */
-            return( AFPERR_EXIST );
-        default:
-            return( AFPERR_NOOBJ );
-        }
+        return afp_errno;
     }
     /* FIXME check done elswhere? cname was able to move curdir to it! */
     if (*s_path->m_name == '\0')
@@ -1939,7 +1933,7 @@ int pathlen;
     }
 
     if ( movecwd( vol, curdir->d_parent ) < 0 ) {
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
 
     if ( rmdir(fdir->d_u_name) < 0 ) {
@@ -2167,16 +2161,11 @@ int             ibuflen, *rbuflen;
     ibuf += sizeof(did);
 
     if (( parentdir = dirlookup( vol, did )) == NULL ) {
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
 
     if (( path = cname( vol, parentdir, &ibuf )) == NULL ) {
-        switch( errno ) {
-        case EACCES:
-            return( AFPERR_ACCESS );
-        default:
-            return( AFPERR_NOOBJ );
-        }
+        return afp_errno;
     }
 
     if ( *path->m_name != '\0' ) {
index 80b732925c97449384ad00f2003cdf320501c549..4149687dd55998ce0869916a1b3edd915a2413c9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.h,v 1.7 2002-10-15 19:34:34 didg Exp $
+ * $Id: directory.h,v 1.8 2003-01-08 15:01:34 didg Exp $
  *
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
@@ -60,6 +60,7 @@ struct dir {
 };
 
 struct path {
+    int         m_type;
     char       *m_name;             /* mac name */
     char        *u_name;            /* unix name */
 
index 76072c9c77cb08f72915571bb8fe076371689209..f4172ee25494dfd3d7b3e5fb7a14bf00efe31576 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: file.c,v 1.69 2003-01-07 15:55:21 rlewczuk Exp $
+ * $Id: file.c,v 1.70 2003-01-08 15:01:34 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -106,19 +106,8 @@ void *get_finderinfo(const char *mpath, struct adouble *adp, void *data)
     return data;
 }
 
-/*
- * FIXME: PDINFO is UTF8 and doesn't need adp
+/* ---------------------
 */
-#define PARAM_NEED_ADP(b) ((b) & ((1 << FILPBIT_ATTR)  |\
-                                 (1 << FILPBIT_CDATE) |\
-                                 (1 << FILPBIT_MDATE) |\
-                                 (1 << FILPBIT_BDATE) |\
-                                 (1 << FILPBIT_FINFO) |\
-                                 (1 << FILPBIT_RFLEN) |\
-                                 (1 << FILPBIT_EXTRFLEN) |\
-                                 (1 << FILPBIT_PDINFO)))
-
-
 char *set_name(char *data, const char *name, u_int32_t utf8) 
 {
     u_int32_t           aint;
@@ -126,6 +115,9 @@ char *set_name(char *data, const char *name, u_int32_t utf8)
     aint = strlen( name );
 
     if (!utf8) {
+        if (afp_version >= 30) {
+            /* the name is in utf8 */
+        }
         if (aint > MACFILELEN)
             aint = MACFILELEN;
         *data++ = aint;
@@ -151,6 +143,19 @@ char *set_name(char *data, const char *name, u_int32_t utf8)
     return data;
 }
 
+/*
+ * FIXME: PDINFO is UTF8 and doesn't need adp
+*/
+#define PARAM_NEED_ADP(b) ((b) & ((1 << FILPBIT_ATTR)  |\
+                                 (1 << FILPBIT_CDATE) |\
+                                 (1 << FILPBIT_MDATE) |\
+                                 (1 << FILPBIT_BDATE) |\
+                                 (1 << FILPBIT_FINFO) |\
+                                 (1 << FILPBIT_RFLEN) |\
+                                 (1 << FILPBIT_EXTRFLEN) |\
+                                 (1 << FILPBIT_PDINFO)))
+
+
 /* -------------------------- */
 int getmetadata(struct vol *vol,
                  u_int16_t bitmap,
@@ -541,11 +546,11 @@ int               ibuflen, *rbuflen;
     ibuf += sizeof( did );
 
     if (( dir = dirlookup( vol, did )) == NULL ) {
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
 
     if (( s_path = cname( vol, dir, &ibuf )) == NULL ) {
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
 
     if ( *s_path->m_name == '\0' ) {
@@ -658,7 +663,7 @@ int         ibuflen, *rbuflen;
     ibuf += sizeof( bitmap );
 
     if (( s_path = cname( vol, dir, &ibuf )) == NULL ) {
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
 
     if ( *s_path->m_name == '\0' ) {
@@ -1054,7 +1059,7 @@ int               ibuflen, *rbuflen;
     memcpy(&sdid, ibuf, sizeof( sdid ));
     ibuf += sizeof( sdid );
     if (( dir = dirlookup( vol, sdid )) == NULL ) {
-        return( AFPERR_PARAM );
+        return afp_errno;
     }
 
     memcpy(&dvid, ibuf, sizeof( dvid ));
@@ -1063,7 +1068,7 @@ int               ibuflen, *rbuflen;
     ibuf += sizeof( ddid );
 
     if (( s_path = cname( vol, dir, &ibuf )) == NULL ) {
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
     if ( *s_path->m_name == '\0' ) {
         return( AFPERR_BADTYPE );
@@ -1093,11 +1098,11 @@ int             ibuflen, *rbuflen;
         return AFPERR_VLOCK;
 
     if (( dir = dirlookup( vol, ddid )) == NULL ) {
-        return( AFPERR_PARAM );
+        return afp_errno;
     }
 
     if (( s_path = cname( vol, dir, &ibuf )) == NULL ) {
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
     if ( *s_path->m_name != '\0' ) {
         return( AFPERR_BADTYPE ); /* not a directory. AFPERR_PARAM? */
index 57f39ccde67448b8266626449ab54c7bb17ad1b3..a34b6a6c1672d4fd4f93e89f8646956447d00d40 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: filedir.c,v 1.36 2002-10-25 11:26:49 didg Exp $
+ * $Id: filedir.c,v 1.37 2003-01-08 15:01:34 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -56,6 +56,7 @@ char *strchr (), *strrchr ();
 #include "filedir.h"
 #include "unix.h"
 
+#ifdef DROPKLUDGE
 int matchfile2dirperms(upath, vol, did)
 /* Since it's kinda' big; I decided against an
 inline function */
@@ -134,7 +135,7 @@ more information */
 #endif /* DEBUG */
     return ret;
 }
-
+#endif
 
 int afp_getfildirparams(obj, ibuf, ibuflen, rbuf, rbuflen )
 AFPObj      *obj;
@@ -166,7 +167,7 @@ int         ibuflen, *rbuflen;
     ibuf += sizeof( did );
 
     if (( dir = dirlookup( vol, did )) == NULL ) {
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
 
     memcpy( &fbitmap, ibuf, sizeof( fbitmap ));
@@ -177,13 +178,15 @@ int               ibuflen, *rbuflen;
     ibuf += sizeof( dbitmap );
 
     if (( s_path = cname( vol, dir, &ibuf )) == NULL) {
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
 
     st   = &s_path->st;
     if (!s_path->st_valid) {
         /* it's a dir and it should be there
-         * because we chdir in it in cname
+         * because we chdir in it in cname or
+         * it's curdir (maybe deleted, but then we can't know)
+         * 
          */
         of_stat(s_path);
     }
@@ -194,6 +197,11 @@ int                ibuflen, *rbuflen;
     buflen = 0;
     if (S_ISDIR(st->st_mode)) {
         if (dbitmap) {
+            if (*s_path->m_name != '\0') {
+                /* the dir wasn't in the cache and we weren't able to chdir in it.
+                */
+                return AFPERR_ACCESS;
+            }
             ret = getdirparams(vol, dbitmap, s_path, curdir,
                                  rbuf + 3 * sizeof( u_int16_t ), &buflen );
             if (ret != AFP_OK )
@@ -257,7 +265,7 @@ int         ibuflen, *rbuflen;
     ibuf += sizeof( did);
 
     if (( dir = dirlookup( vol, did )) == NULL ) {
-        return( AFPERR_NOOBJ );
+       return afp_errno;    
     }
 
     memcpy( &bitmap, ibuf, sizeof( bitmap ));
@@ -265,7 +273,7 @@ int         ibuflen, *rbuflen;
     ibuf += sizeof( bitmap );
 
     if (( path = cname( vol, dir, &ibuf )) == NULL ) {
-        return( AFPERR_NOOBJ );
+       return afp_errno;    
     }
 
     st   = &path->st;
@@ -467,12 +475,12 @@ int               ibuflen, *rbuflen;
     memcpy( &did, ibuf, sizeof( did ));
     ibuf += sizeof( did );
     if (( sdir = dirlookup( vol, did )) == NULL ) {
-        return( AFPERR_NOOBJ );
+       return afp_errno;    
     }
 
     /* source pathname */
     if (( path = cname( vol, sdir, &ibuf )) == NULL ) {
-        return( AFPERR_NOOBJ );
+       return afp_errno;    
     }
 
     sdir = curdir;
@@ -487,7 +495,7 @@ int         ibuflen, *rbuflen;
         }
         /* move to destination dir */
         if ( movecwd( vol, sdir->d_parent ) < 0 ) {
-            return( AFPERR_NOOBJ );
+            return afp_errno;
         }
         isdir = 1;
         strcpy(oldname, sdir->d_m_name);
@@ -547,11 +555,11 @@ int               ibuflen, *rbuflen;
     memcpy( &did, ibuf, sizeof( did ));
     ibuf += sizeof( int );
     if (( dir = dirlookup( vol, did )) == NULL ) {
-        return( AFPERR_NOOBJ );
+       return afp_errno;    
     }
 
     if (( s_path = cname( vol, dir, &ibuf )) == NULL ) {
-        return( AFPERR_NOOBJ );
+        return afp_errno;
     }
 
     upath = s_path->u_name;
index 77156a54cb29c4d3f23963dc270e396d10aa543b..34ef99c3d92f442a9812289917d071128ea421ea 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: fork.c,v 1.40 2002-11-14 17:13:45 srittau Exp $
+ * $Id: fork.c,v 1.41 2003-01-08 15:01:35 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -240,7 +240,7 @@ int         ibuflen, *rbuflen;
     ibuf += sizeof( int );
 
     if (( dir = dirlookup( vol, did )) == NULL ) {
-        return( AFPERR_NOOBJ );
+       return afp_errno;    
     }
 
     memcpy(&bitmap, ibuf, sizeof( bitmap ));
@@ -255,7 +255,7 @@ int         ibuflen, *rbuflen;
     }
 
     if (( s_path = cname( vol, dir, &ibuf )) == NULL ) {
-        return AFPERR_NOOBJ;
+       return afp_errno;    
     }
 
     if (*s_path->m_name == '\0') {
index 8da46105a57d4db2e08f414cfee32dd214940e43..5b5ad504dfcaf48a44f1c4537b75dd00ff0d7b5b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: globals.h,v 1.15 2002-12-07 02:39:57 rlewczuk Exp $
+ * $Id: globals.h,v 1.16 2003-01-08 15:01:36 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -89,6 +89,7 @@ typedef struct AFPObj {
 } AFPObj;
 
 extern int             afp_version;
+extern int             afp_errno;
 extern unsigned char   nologin;
 extern struct dir      *curdir;
 extern char            getwdbuf[];
index c8bb933aa7305a015987492bdb136bc7645d6aeb..fa0ee0a722f0a37abe731603cd03e25c486f27e6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: unix.c,v 1.40 2003-01-07 15:55:22 rlewczuk Exp $
+ * $Id: unix.c,v 1.41 2003-01-08 15:01:36 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -123,7 +123,6 @@ struct stat         *stat;
 struct maccess *ma;
 {
 mode_t mode;
-int    ok = 0;
 
     mode = stat->st_mode;
     ma->ma_world = utombits( mode );
@@ -134,32 +133,18 @@ int    ok = 0;
 
     ma->ma_owner = utombits( mode );
 
-    /* ma_user is a union of all permissions */
-    ma->ma_user = 0;
+    /* ma_user is a union of all permissions but we must follow
+     * unix perm
+    */
     if ( (uuid == stat->st_uid) || (uuid == 0)) {
-        ok = 1;
         ma->ma_user = ma->ma_owner | AR_UOWN;
     }
-    if ( gmem( stat->st_gid )) {
-        ok = 1;
-        ma->ma_user |= ma->ma_group;
-    } 
-    if (ok) {
-       /* We are the directory owner or we are in the group owner.
-        * If we don't have a perm we need to remove it from ma_world.
-        *
-        * eg if perms are rwx--Sr-x and I'm not the user owner but I'm in the group
-        * I DON'T have read and search access on the directory.
-       */
-       if (!(ma->ma_user & AR_UWRITE))
-          ma->ma_world &= ~AR_UWRITE;
-       if (!(ma->ma_user & AR_UREAD))
-          ma->ma_world &= ~AR_UREAD;
-       if (!(ma->ma_user & AR_USEARCH))
-          ma->ma_world &= ~AR_USEARCH;
-    }
-
-    ma->ma_user |= ma->ma_world;
+    else if ( gmem( stat->st_gid )) {
+        ma->ma_user = ma->ma_group;
+    }
+    else {
+        ma->ma_user = ma->ma_world;
+    }
 
     /*
      * There are certain things the mac won't try if you don't have
@@ -425,7 +410,7 @@ const int dropbox;
             continue;
         }
 
-        if (S_ISREG(st.st_mode)) {
+        if (!S_ISDIR(st.st_mode)) {
            if (setfilmode(dirp->d_name, mode, &st) < 0) {
                 LOG(log_error, logtype_afpd, "setdirmode: chmod %s: %s",
                     dirp->d_name, strerror(errno) );
@@ -467,7 +452,7 @@ const int dropbox;
             LOG(log_error, logtype_afpd, "setdirmode: stat %s: %s", buf, strerror(errno) );
             continue;
         }
-        if (S_ISREG(st.st_mode)) {
+        if (!S_ISDIR(st.st_mode)) {
            if (setfilmode(buf, ad_hf_mode(mode), &st) < 0) {
                /* FIXME what do we do then? */
            }
index 254b0301d738d8cfa1ac74bddb55b27c30901117..62d52267bcfc3f3443ca67556764af587e2467ed 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.c,v 1.44 2002-12-04 10:59:36 didg Exp $
+ * $Id: volume.c,v 1.45 2003-01-08 15:01:37 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -375,6 +375,8 @@ static void volset(struct vol_option *options, char *volname, int vlen,
                 options[VOLOPT_FLAGS].i_value |= AFPVOL_DROPBOX;
             else if (strcasecmp(p, "nofileid") == 0)
                 options[VOLOPT_FLAGS].i_value |= AFPVOL_NOFILEID;
+            else if (strcasecmp(p, "utf8") == 0)
+                options[VOLOPT_FLAGS].i_value |= AFPVOL_UTF8;
 
             p = strtok(NULL, ",");
         }
index 199500476e56d9dd43f7522f5d00e85664216daf..7af5634045fb716f921da8144cf656016b4c3261 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.h,v 1.16 2002-10-17 18:01:54 didg Exp $
+ * $Id: volume.h,v 1.17 2003-01-08 15:01:37 didg Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -11,6 +11,7 @@
 #include <sys/cdefs.h>
 #include <sys/types.h>
 #include <netatalk/endian.h>
+
 #include "globals.h"
 
 #define AFPVOL_NAMELEN   27
@@ -51,7 +52,7 @@ struct vol {
     int                 v_casefold;
     struct codepage     *v_mtoupage, *v_utompage, *v_badumap;
     int                 max_filename;
-
+    
     char                *v_password;
     char                *v_veto;
 #ifdef CNID_DB
@@ -93,6 +94,7 @@ this is going away. */
 #define AFPVOL_MAPASCII  (1 << 13)  /* map the ascii range as well */
 #define AFPVOL_DROPBOX   (1 << 14)  /* dropkludge dropbox support */
 #define AFPVOL_NOFILEID  (1 << 15)  /* don't advertise createid resolveid and deleteid calls */
+#define AFPVOL_UTF8      (1 << 16)  /* unix name are in UTF8 */
 
 /* FPGetSrvrParms options */
 #define AFPSRVR_CONFIGINFO     (1 << 0)