From: Frank Lahm Date: Tue, 20 Mar 2012 16:01:16 +0000 (+0100) Subject: Fix server options parser. X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=1fdb93aa3cdcb8e2f216fd54749915477661ff12 Fix server options parser. New server option "nosendfile" to disable sendfile() usage at runtime. --- diff --git a/etc/afpd/fork.c b/etc/afpd/fork.c index bb7c6880..62e620ef 100644 --- a/etc/afpd/fork.c +++ b/etc/afpd/fork.c @@ -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 diff --git a/include/atalk/globals.h b/include/atalk/globals.h index 345b2779..e1aca814 100644 --- a/include/atalk/globals.h +++ b/include/atalk/globals.h @@ -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) diff --git a/libatalk/util/netatalk_conf.c b/libatalk/util/netatalk_conf.c index 0c70abe2..18642c57 100644 --- a/libatalk/util/netatalk_conf.c +++ b/libatalk/util/netatalk_conf.c @@ -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, ", "); }