]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/volume.c
New option parsing
[netatalk.git] / etc / afpd / volume.c
index 716387925373fb38e0c7d69515318e39505a63b1..d15e9a4640a869d6baa1012796f37b3d03264ebd 100644 (file)
@@ -237,7 +237,7 @@ static char *volxlate(AFPObj *obj,
         } else if (is_var(p, "$c")) {
             if (afpmaster && xlatevolname)
                 return NULL;
-            DSI *dsi = obj->handle;
+            DSI *dsi = obj->dsi;
             len = sprintf(dest, "%s:%u",
                           getip_string((struct sockaddr *)&dsi->client),
                           getip_port((struct sockaddr *)&dsi->client));
@@ -264,7 +264,7 @@ static char *volxlate(AFPObj *obj,
         } else if (is_var(p, "$i")) {
             if (afpmaster && xlatevolname)
                 return NULL;
-            DSI *dsi = obj->handle;
+            DSI *dsi = obj->dsi;
             q = getip_string((struct sockaddr *)&dsi->client);
         } else if (is_var(p, "$s")) {
             if (obj->Obj)
@@ -405,15 +405,7 @@ static void volset(struct vol_option *options, struct vol_option *save,
             return;
 
         while (p) {
-            if (strcasecmp(p, "prodos") == 0)
-                options[VOLOPT_FLAGS].i_value |= AFPVOL_A2VOL;
-            else if (strcasecmp(p, "mswindows") == 0) {
-                options[VOLOPT_FLAGS].i_value |= AFPVOL_MSWINDOWS | AFPVOL_USEDOTS;
-            } else if (strcasecmp(p, "crlf") == 0)
-                options[VOLOPT_FLAGS].i_value |= AFPVOL_CRLF;
-            else if (strcasecmp(p, "noadouble") == 0)
-                options[VOLOPT_FLAGS].i_value |= AFPVOL_NOADOUBLE;
-            else if (strcasecmp(p, "ro") == 0)
+            if (strcasecmp(p, "ro") == 0)
                 options[VOLOPT_FLAGS].i_value |= AFPVOL_RO;
             else if (strcasecmp(p, "nohex") == 0)
                 options[VOLOPT_FLAGS].i_value |= AFPVOL_NOHEX;
@@ -421,10 +413,6 @@ static void volset(struct vol_option *options, struct vol_option *save,
                 options[VOLOPT_FLAGS].i_value |= AFPVOL_USEDOTS;
             else if (strcasecmp(p, "invisibledots") == 0)
                 options[VOLOPT_FLAGS].i_value |= AFPVOL_USEDOTS | AFPVOL_INV_DOTS;
-            else if (strcasecmp(p, "limitsize") == 0)
-                options[VOLOPT_FLAGS].i_value |= AFPVOL_LIMITSIZE;
-            else if (strcasecmp(p, "nofileid") == 0)
-                options[VOLOPT_FLAGS].i_value |= AFPVOL_NOFILEID;
             else if (strcasecmp(p, "nostat") == 0)
                 options[VOLOPT_FLAGS].i_value |= AFPVOL_NOSTAT;
             else if (strcasecmp(p, "preexec_close") == 0)
@@ -439,8 +427,6 @@ static void volset(struct vol_option *options, struct vol_option *save,
                 options[VOLOPT_FLAGS].i_value |= AFPVOL_CASEINSEN;
             else if (strcasecmp(p, "illegalseq") == 0)
                 options[VOLOPT_FLAGS].i_value |= AFPVOL_EILSEQ;
-            else if (strcasecmp(p, "nocnidcache") == 0)
-                options[VOLOPT_FLAGS].i_value &= ~AFPVOL_CACHE;
             else if (strcasecmp(p, "tm") == 0)
                 options[VOLOPT_FLAGS].i_value |= AFPVOL_TM;
             else if (strcasecmp(p, "searchdb") == 0)
@@ -449,6 +435,8 @@ static void volset(struct vol_option *options, struct vol_option *save,
                 options[VOLOPT_FLAGS].i_value |= AFPVOL_NONETIDS;
             else if (strcasecmp(p, "noacls") == 0)
                 options[VOLOPT_FLAGS].i_value &= ~AFPVOL_ACLS;
+            else if (strcasecmp(p, "nov2toeaconv") == 0)
+                options[VOLOPT_FLAGS].i_value |= AFPVOL_NOV2TOEACONV;
             p = strtok(NULL, ",");
         }
 
@@ -696,14 +684,10 @@ static int creatvol(AFPObj *obj, struct passwd *pwd,
         volume->v_ad_options = 0;
         if ((volume->v_flags & AFPVOL_NODEV))
             volume->v_ad_options |= ADVOL_NODEV;
-        if ((volume->v_flags & AFPVOL_CACHE))
-            volume->v_ad_options |= ADVOL_CACHE;
         if ((volume->v_flags & AFPVOL_UNIX_PRIV))
             volume->v_ad_options |= ADVOL_UNIXPRIV;
         if ((volume->v_flags & AFPVOL_INV_DOTS))
             volume->v_ad_options |= ADVOL_INVDOTS;
-        if ((volume->v_flags & AFPVOL_NOADOUBLE))
-            volume->v_ad_options |= ADVOL_NOADOUBLE;
 
         if (options[VOLOPT_PASSWORD].c_value)
             volume->v_password = strdup(options[VOLOPT_PASSWORD].c_value);
@@ -896,7 +880,7 @@ static int hostaccessvol(int type, const char *volname, const char *args, const
 {
     int mask_int;
     char buf[MAXPATHLEN + 1], *p, *b;
-    DSI *dsi = obj->handle;
+    DSI *dsi = obj->dsi;
     struct sockaddr_storage client;
 
     if (!args)
@@ -1149,7 +1133,6 @@ static int readvolfile(AFPObj *obj, struct afp_volume_name *p1, char *p2, int us
     memset(default_options, 0, sizeof(default_options));
 
     /* Enable some default options for all volumes */
-    default_options[VOLOPT_FLAGS].i_value |= AFPVOL_CACHE;
 #ifdef HAVE_ACLS
     default_options[VOLOPT_FLAGS].i_value |= AFPVOL_ACLS;
 #endif
@@ -1516,9 +1499,7 @@ static int getvolspace(struct vol *vol,
 
     spaceflag = AFPVOL_GVSMASK & vol->v_flags;
     /* report up to 2GB if afp version is < 2.2 (4GB if not) */
-    maxsize = (vol->v_flags & AFPVOL_A2VOL) ? 0x01fffe00 :
-        (((afp_version < 22) || (vol->v_flags & AFPVOL_LIMITSIZE))
-         ? 0x7fffffffL : 0xffffffffL);
+    maxsize = (afp_version < 22) ? 0x7fffffffL : 0xffffffffL;
 
 #ifdef AFS
     if ( spaceflag == AFPVOL_NONE || spaceflag == AFPVOL_AFSGVS ) {
@@ -1619,6 +1600,9 @@ static int getvolparams( uint16_t bitmap, struct vol *vol, struct stat *st, char
      * For MacOS8.x support we need to create the
      * .Parent file here if it doesn't exist. */
 
+    /* Convert adouble:v2 to adouble:ea on the fly */
+    (void)ad_convert(vol->v_path, st, vol);
+
     ad_init(&ad, vol);
     if (ad_open(&ad, vol->v_path, ADFLAGS_HF | ADFLAGS_DIR | ADFLAGS_RDWR | ADFLAGS_CREATE, 0666) != 0 ) {
         isad = 0;
@@ -1677,10 +1661,8 @@ static int getvolparams( uint16_t bitmap, struct vol *vol, struct stat *st, char
             }
             /* prior 2.1 only VOLPBIT_ATTR_RO is defined */
             if (afp_version > 20) {
-                if (0 == (vol->v_flags & AFPVOL_NOFILEID) && vol->v_cdb != NULL &&
-                    (vol->v_cdb->flags & CNID_FLAG_PERSISTENT)) {
+                if (vol->v_cdb != NULL && (vol->v_cdb->flags & CNID_FLAG_PERSISTENT))
                     ashort |= VOLPBIT_ATTR_FILEID;
-                }
                 ashort |= VOLPBIT_ATTR_CATSEARCH;
 
                 if (afp_version >= 30) {
@@ -1951,13 +1933,6 @@ int afp_getsrvrparms(AFPObj *obj, char *ibuf _U_, size_t ibuflen _U_, char *rbuf
         /* set password bit if there's a volume password */
         *data = (volume->v_password) ? AFPSRVR_PASSWD : 0;
 
-        /* Apple 2 clients running ProDOS-8 expect one volume to have
-           bit 0 of this byte set.  They will not recognize anything
-           on the server unless this is the case.  I have not
-           completely worked this out, but it's related to booting
-           from the server.  Support for that function is a ways
-           off.. <shirsch@ibm.net> */
-        *data |= (volume->v_flags & AFPVOL_A2VOL) ? AFPSRVR_CONFIGINFO : 0;
         *data++ |= 0; /* UNIX PRIVS BIT ..., OSX doesn't seem to use it, so we don't either */
         *data++ = len;
         memcpy(data, namebuf, len );
@@ -2077,7 +2052,6 @@ static int volume_openDB(struct vol *volume)
                        "Check server messages for details!");
             kill(getpid(), SIGUSR2);
             /* deactivate cnid caching/storing in AppleDouble files */
-            volume->v_flags &= ~AFPVOL_CACHE;
         }
 #endif
     }
@@ -2520,7 +2494,7 @@ int  pollvoltime(AFPObj *obj)
         if ( (vol->v_flags & AFPVOL_OPEN)  && vol->v_mtime + 30 < tv.tv_sec) {
             if ( !stat( vol->v_path, &st ) && vol->v_mtime != st.st_mtime ) {
                 vol->v_mtime = st.st_mtime;
-                if (!obj->attention(obj->handle, AFPATTN_NOTIFY | AFPATTN_VOLCHANGED))
+                if (!obj->attention(obj->dsi, AFPATTN_NOTIFY | AFPATTN_VOLCHANGED))
                     return -1;
                 return 1;
             }
@@ -2551,7 +2525,7 @@ void setvoltime(AFPObj *obj, struct vol *vol)
          * AFP 3.2 and above clients seem to be ok without so many notification
          */
         if (afp_version < 32 && obj->options.server_notif) {
-            obj->attention(obj->handle, AFPATTN_NOTIFY | AFPATTN_VOLCHANGED);
+            obj->attention(obj->dsi, AFPATTN_NOTIFY | AFPATTN_VOLCHANGED);
         }
     }
 }
@@ -2619,33 +2593,6 @@ int afp_setvolparams(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf
     return( AFP_OK );
 }
 
-/* ------------------------- */
-int wincheck(const struct vol *vol, const char *path)
-{
-    int len;
-
-    if (!(vol->v_flags & AFPVOL_MSWINDOWS))
-        return 1;
-
-    /* empty paths are not allowed */
-    if ((len = strlen(path)) == 0)
-        return 0;
-
-    /* leading or trailing whitespaces are not allowed, carriage returns
-     * and probably other whitespace is okay, tabs are not allowed
-     */
-    if ((path[0] == ' ') || (path[len-1] == ' '))
-        return 0;
-
-    /* certain characters are not allowed */
-    if (strpbrk(path, MSWINDOWS_BADCHARS))
-        return 0;
-
-    /* everything else is okay */
-    return 1;
-}
-
-
 /*
  * precreate a folder
  * this is only intended for folders in the volume root