]> arthur.barton.de Git - netatalk.git/commitdiff
signature parameter: more simple syntax
authorHAT <hat@fa2.so-net.ne.jp>
Thu, 22 Mar 2012 18:13:35 +0000 (03:13 +0900)
committerHAT <hat@fa2.so-net.ne.jp>
Thu, 22 Mar 2012 18:13:35 +0000 (03:13 +0900)
etc/afpd/status.c
libatalk/util/netatalk_conf.c

index f39e1ed48e3f49ad837ed3064b706b8c4d717947..86ea243ae6ed675b0a559b7eaa3fc2c92da46004 100644 (file)
@@ -643,10 +643,9 @@ void status_init(AFPObj *obj, DSI *dsi)
 /* If not found in conf file, genarate and append in conf file.       */
 /* If conf file don't exist, create and genarate.                     */
 /* If cannot open conf file, use one-time signature.                  */
-/* If signature = user:xxxxx, use it.                                  */
+/* If signature = xxxxx, use it.                                      */
 
 void set_signature(struct afp_options *options) {
-    char *usersign;
     int fd, i;
     struct stat tmpstat;
     char *servername_conf;
@@ -657,38 +656,26 @@ void set_signature(struct afp_options *options) {
     char *server_tmp;
     
     server_tmp = options->hostname;
-    if (strcmp(options->signatureopt, "auto") == 0) {
+    len = strlen(options->signatureopt);
+    if (len == 0) {
         goto server_signature_auto;   /* default */
-    } else if (strcmp(options->signatureopt, "host") == 0) {
-        LOG(log_warning, logtype_afpd, "WARNING: option \"-signature host\" is obsoleted. Switching back to auto.", options->signatureopt);
-        goto server_signature_auto;   /* same as auto */
-    } else if (strncmp(options->signatureopt, "user", 4) == 0) {
-        goto server_signature_user;   /*  user string */
+    } else if (len < 3) {
+        LOG(log_warning, logtype_afpd, "WARNING: signature string %s is very short !", options->signatureopt);
+        goto server_signature_user;
+    } else if (len > 16) {
+        LOG(log_warning, logtype_afpd, "WARNING: signature string %s is very long !", options->signatureopt);
+        len = 16;
+        goto server_signature_user;
     } else {
-        LOG(log_error, logtype_afpd, "ERROR: option \"-signature %s\" is not valid. Switching back to auto.", options->signatureopt);
-        goto server_signature_auto;   /* switch back to auto*/
+        LOG(log_info, logtype_afpd, "signature string is %s.", options->signatureopt);
+        goto server_signature_user;
     }
     
 server_signature_user:
     
-    /* Signature type is user string */
-    len = strlen(options->signatureopt);
-    if (len <= 5) {
-        LOG(log_warning, logtype_afpd, "WARNING: option \"-signature %s\" is not valid. Switching back to auto.", options->signatureopt);
-        goto server_signature_auto;
-    }
-    usersign = options->signatureopt + 5;
-    len = len - 5;
-    if (len > 16) {
-        LOG(log_warning, logtype_afpd, "WARNING: signature user string %s is very long !",  usersign);
-        len = 16;
-    } else if (len >= 3) {
-        LOG(log_info, logtype_afpd, "signature user string is %s.", usersign);
-    } else {
-        LOG(log_warning, logtype_afpd, "WARNING: signature user string %s is very short !",  usersign);
-    }
+    /* Signature is defined in afp.conf */
     memset(options->signature, 0, 16);
-    memcpy(options->signature, usersign, len);
+    memcpy(options->signature, options->signatureopt, len);
     goto server_signature_done;
     
 server_signature_auto:
@@ -783,7 +770,7 @@ server_signature_random:
         fprintf(fp, "# ServerSignature is unique identifier used to prevent logging on to\n");
         fprintf(fp, "# the same server twice.\n");
         fprintf(fp, "# \n");
-        fprintf(fp, "# If setting \"signature = user:xxxxx\" in afp.conf, this file is not used.\n\n");
+        fprintf(fp, "# If setting \"signature = xxxxx\" in afp.conf, this file is not used.\n\n");
     }
     
     if (fp) {
@@ -799,8 +786,7 @@ server_signature_done:
     
     /* retrun */
     LOG(log_info, logtype_afpd,
-        " \"%s\"'s signature is  %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
-        server_tmp,
+        "signature is %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
         (options->signature)[ 0], (options->signature)[ 1],
         (options->signature)[ 2], (options->signature)[ 3],
         (options->signature)[ 4], (options->signature)[ 5],
index b5a60dac29a10fbd52b4e688dc11cda6e4c670b8..c2388d5e78fa36f8642162debfbfd64ced2ce81c 100644 (file)
@@ -1417,7 +1417,7 @@ int afp_config_parse(AFPObj *AFPObj)
     options->uampath        = iniparser_getstrdup(config, INISEC_GLOBAL, "uam path",       _PATH_AFPDUAMPATH);
     options->uamlist        = iniparser_getstrdup(config, INISEC_GLOBAL, "uam list",       "uams_dhx.so uams_dhx2.so");
     options->port           = iniparser_getstrdup(config, INISEC_GLOBAL, "afp port",       "548");
-    options->signatureopt   = iniparser_getstrdup(config, INISEC_GLOBAL, "signature",      "auto");
+    options->signatureopt   = iniparser_getstrdup(config, INISEC_GLOBAL, "signature",      "");
     options->k5service      = iniparser_getstrdup(config, INISEC_GLOBAL, "k5 service",     NULL);
     options->k5realm        = iniparser_getstrdup(config, INISEC_GLOBAL, "k5 realm",       NULL);
     options->listen         = iniparser_getstrdup(config, INISEC_GLOBAL, "afp listen",     NULL);