]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/file.c
"veto files" patch (Edmund Lam)
[netatalk.git] / etc / afpd / file.c
index 8de41ace41e06353d337308c88cf63a66d155087..a2afbab4c90fa0448d0ff60138b053e6501bbba0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: file.c,v 1.25 2001-08-14 14:00:10 rufustfirefly Exp $
+ * $Id: file.c,v 1.28 2001-09-04 13:52:45 rufustfirefly Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -80,14 +80,10 @@ const u_char ufinderi[] = {
     0, 0, 0, 0, 0, 0, 0, 0
 };
 
-int getfilparams(vol, bitmap, path, dir, st, buf, buflen )
-    struct vol  *vol;
-    u_int16_t  bitmap;
-    char       *path;
-    struct dir *dir;
-    struct stat        *st;
-    char       *buf;
-    int                *buflen;
+int getfilparams(struct vol *vol,
+                u_int16_t bitmap,
+                char *path, struct dir *dir, struct stat *st,
+                char *buf, int *buflen )
 {
 #ifndef USE_LASTDID
     struct stat                hst, lst, *lstp;
@@ -98,7 +94,8 @@ int getfilparams(vol, bitmap, path, dir, st, buf, buflen )
     struct ofork        *of;
     struct extmap      *em;
     char               *data, *nameoff = NULL, *upath;
-    int                        bit = 0, isad = 1, aint;
+    int                        bit = 0, isad = 1;
+    u_int32_t          aint;
     u_int16_t          ashort;
     u_char              achar, fdType[4];
 
@@ -117,7 +114,7 @@ int getfilparams(vol, bitmap, path, dir, st, buf, buflen )
     if ( ad_open( upath, ADFLAGS_HF, O_RDONLY, 0, adp) < 0 ) {
        isad = 0;
     } else if ( fstat( ad_hfileno( adp ), &hst ) < 0 ) {
-           syslog( LOG_ERR, "getfilparams fstat: %m" );
+           syslog( LOG_ERR, "getfilparams fstat: %s", strerror(errno) );
     }
 
     data = buf;
@@ -203,25 +200,16 @@ int getfilparams(vol, bitmap, path, dir, st, buf, buflen )
 
        case FILPBIT_FNUM :
                aint = 0;
-#ifdef CNID_DB
-               /* find out if we have a fixed did already */
-               aint = cnid_lookup(vol->v_db, st, dir->d_did, upath,
-                                                   strlen(upath));
-#endif /* CNID_DB */
-
-         /* look in AD v2 header */
-           if (aint == 0)
-               {
 #if AD_VERSION > AD_VERSION1
-          if (isad)
+        /* look in AD v2 header */
+        if (isad)
                        memcpy(&aint, ad_entry(adp, ADEID_DID), sizeof(aint));
 #endif /* AD_VERSION > AD_VERSION1 */
 
 #ifdef CNID_DB
-             aint = cnid_add(vol->v_db, st, dir->d_did, upath,
+        aint = cnid_add(vol->v_db, st, dir->d_did, upath,
                                                        strlen(upath), aint);
 #endif /* CNID_DB */
-               }
 
                if (aint == 0) {
            /*
@@ -418,6 +406,10 @@ int afp_createfile(obj, ibuf, ibuflen, rbuf, rbuflen )
     if (!validupath(vol, upath))
       return AFPERR_EXIST;
 
+    /* check for vetoed filenames */
+    if (veto_file(vol->v_veto, upath))
+        return AFPERR_EXIST;
+
     if ((of = of_findname(vol, curdir, path))) {
       adp = of->of_ad;
     } else {
@@ -557,10 +549,8 @@ int afp_setfilparams(obj, ibuf, ibuflen, rbuf, rbuflen )
 }
 
 
-int setfilparams(vol, path, bitmap, buf )
-    struct vol  *vol;
-    char       *path, *buf;
-    u_int16_t  bitmap;
+int setfilparams(struct vol *vol,
+                char *path, u_int16_t bitmap, char *buf )
 {
     struct adouble     ad, *adp;
     struct ofork        *of;
@@ -1344,19 +1334,17 @@ int afp_createid(obj, ibuf, ibuflen, rbuf, rbuflen )
 
 #if AD_VERSION > AD_VERSION1
     memset(&ad, 0, sizeof(ad));
-    if (ad_open( upath, ADFLAGS_HF, O_RDONLY, 0, &ad ) < 0)
-      id = 0;
-    else {
+    if (ad_open( upath, ADFLAGS_HF, O_RDONLY, 0, &ad ) >= 0) {
       memcpy(&id, ad_entry(&ad, ADEID_DID), sizeof(id));
       ad_close(&ad, ADFLAGS_HF);
     }
+#endif /* AD_VERSION > AD_VERSION1 */
 
     if (id = cnid_add(vol->v_db, &st, did, upath, len, id)) {
       memcpy(rbuf, &id, sizeof(id));
       *rbuflen = sizeof(id);
       return AFP_OK;
     }
-#endif /* AD_VERSION > AD_VERSION1 */
 
 #ifdef DEBUG
     syslog(LOG_INFO, "ending afp_createid...:");