]> arthur.barton.de Git - netatalk.git/commitdiff
Fix server options parser.
authorFrank Lahm <franklahm@googlemail.com>
Tue, 20 Mar 2012 16:01:16 +0000 (17:01 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Tue, 20 Mar 2012 16:01:16 +0000 (17:01 +0100)
New server option "nosendfile" to disable sendfile() usage at runtime.

etc/afpd/fork.c
include/atalk/globals.h
libatalk/util/netatalk_conf.c

index bb7c6880194ecf8712d646dd4a12ebeaac6f07d1..62e620eff6b75609de17915a657120025f9bd796 100644 (file)
@@ -879,22 +879,24 @@ static int read_fork(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, si
         /* due to the nature of afp packets, we have to exit if we get
            an error. we can't do this with translation on. */
 #ifdef WITH_SENDFILE
-        int fd;
-
-        fd = ad_readfile_init(ofork->of_ad, eid, &offset, 0);
-
-        if (dsi_stream_read_file(dsi, fd, offset, dsi->datasize) < 0) {
-            if (errno == EINVAL || errno == ENOSYS)
-                goto afp_read_loop;
-            else {
-                LOG(log_error, logtype_afpd, "afp_read(%s): ad_readfile: %s", of_name(ofork), strerror(errno));
-                goto afp_read_exit;
+        if (!(obj->options.flags & OPTION_NOSENDFILE)) {
+            if (dsi_stream_read_file(dsi,
+                                     ad_readfile_init(ofork->of_ad, eid, &offset, 0),
+                                     offset,
+                                     dsi->datasize) < 0) {
+                switch (errno) {
+                case EINVAL:
+                case ENOSYS:
+                    goto afp_read_loop;
+                default:
+                    LOG(log_error, logtype_afpd, "afp_read(%s): ad_readfile: %s", of_name(ofork), strerror(errno));
+                    goto afp_read_exit;
+                }
             }
-        }
-
-        dsi_readdone(dsi);
-        goto afp_read_done;
 
+            dsi_readdone(dsi);
+            goto afp_read_done;
+        }
     afp_read_loop:
 #endif
 
index 345b2779b3cd71e0123e86f2bc0a8b1573498c4a..e1aca81491f28c871558862141267e37d03ec61e 100644 (file)
@@ -37,6 +37,7 @@
 #define OPTION_DEBUG         (1 << 0)
 #define OPTION_CLOSEVOL      (1 << 1)
 #define OPTION_SERVERNOTIF   (1 << 2)
+#define OPTION_NOSENDFILE    (1 << 3)
 #define OPTION_CUSTOMICON    (1 << 4)
 #define OPTION_ANNOUNCESSH   (1 << 6)
 #define OPTION_UUID          (1 << 7)
index 0c70abe2dc7c780f75ea3e4cf1aa02c0ba4615f6..18642c57149b5f3f6e5d166b86db697c52b881a5 100644 (file)
@@ -1377,29 +1377,31 @@ int afp_config_parse(AFPObj *AFPObj)
     if (q = iniparser_getstrdup(config, INISEC_GLOBAL, "server options", NULL)) {
         if (p = strtok(q, ", ")) {
             while (p) {
-                if (strcasecmp(p, "nozeroconf"))
+                if (strcasecmp(p, "nozeroconf") == 0)
                     options->flags |= OPTION_NOZEROCONF;
-                if (strcasecmp(p, "icon"))
+                if (strcasecmp(p, "icon") == 0)
                     options->flags |= OPTION_CUSTOMICON;
-                if (strcasecmp(p, "noicon"))
+                if (strcasecmp(p, "noicon") == 0)
                     options->flags &= ~OPTION_CUSTOMICON;
-                if (strcasecmp(p, "advertise_ssh"))
+                if (strcasecmp(p, "advertise_ssh") == 0)
                     options->flags |= OPTION_ANNOUNCESSH;
-                if (strcasecmp(p, "noacl2maccess"))
+                if (strcasecmp(p, "noacl2maccess") == 0)
                     options->flags &= ~OPTION_ACL2MACCESS;
-                if (strcasecmp(p, "keepsessions"))
+                if (strcasecmp(p, "keepsessions") == 0)
                     options->flags |= OPTION_KEEPSESSIONS;
-                if (strcasecmp(p, "closevol"))
+                if (strcasecmp(p, "closevol") == 0)
                     options->flags |= OPTION_CLOSEVOL;
-                if (strcasecmp(p, "client_polling"))
+                if (strcasecmp(p, "client_polling") == 0)
                     options->flags &= ~OPTION_SERVERNOTIF;
-                if (strcasecmp(p, "nosavepassword"))
+                if (strcasecmp(p, "nosendfile") == 0)
+                    options->flags |= OPTION_NOSENDFILE;
+                if (strcasecmp(p, "nosavepassword") == 0)
                     options->passwdbits |= PASSWD_NOSAVE;
-                if (strcasecmp(p, "savepassword"))
+                if (strcasecmp(p, "savepassword") == 0)
                     options->passwdbits &= ~PASSWD_NOSAVE;
-                if (strcasecmp(p, "nosetpassword"))
+                if (strcasecmp(p, "nosetpassword") == 0)
                     options->passwdbits &= ~PASSWD_SET;
-                if (strcasecmp(p, "setpassword"))
+                if (strcasecmp(p, "setpassword") == 0)
                     options->passwdbits |= PASSWD_SET;
                 p = strtok(NULL, ", ");
             }