#include <atalk/dsi.h>
#include <atalk/uuid.h>
#include <atalk/netatalk_conf.h>
+#include <atalk/bstrlib.h>
#define VOLPASSLEN 8
#ifndef UUID_PRINTABLE_STRING_LENGTH
* check access list
*
* this function wants something of the following form:
- * "@group,name,name2,@group2,name3"
+ * "@group,name,name2,@group2,name3" or "@group name name2 @group2 name3"
* A NULL argument allows everybody to have access.
* We return three things:
* -1: no list
return -1;
strlcpy(buf, args, sizeof(buf));
- if ((p = strtok(buf, ",")) == NULL) /* nothing, return okay */
+ if ((p = strtok(buf, ", ")) == NULL) /* nothing, return okay */
return -1;
while (p) {
return 1;
} else if (strcasecmp(p, name) == 0) /* it's a user name */
return 1;
- p = strtok(NULL, ",");
+ p = strtok(NULL, ", ");
}
return 0;
return -1;
strlcpy(buf, args, sizeof(buf));
- if ((p = strtok_r(buf, ",", &b)) == NULL) /* nothing, return okay */
+ if ((p = strtok_r(buf, ", ", &b)) == NULL) /* nothing, return okay */
return -1;
while (p) {
/* next address */
freeaddrinfo(ai);
- p = strtok_r(NULL, ",", &b);
+ p = strtok_r(NULL, ", ", &b);
}
return 0;
* deny -> either no list (-1), or not in list (0)
*/
if (pwd) {
- if (accessvol(obj, getoption(obj->iniconfig, section, "deny", preset), pwd->pw_name) == 1)
+ if (accessvol(obj, getoption(obj->iniconfig, section, "invalid users", preset), pwd->pw_name) == 1)
goto EC_CLEANUP;
- if (accessvol(obj, getoption(obj->iniconfig, section, "allow", preset), pwd->pw_name) == 0)
+ if (accessvol(obj, getoption(obj->iniconfig, section, "valid users", preset), pwd->pw_name) == 0)
goto EC_CLEANUP;
- if (hostaccessvol(obj, section, getoption(obj->iniconfig, section, "denied_hosts", preset)) == 1)
+ if (hostaccessvol(obj, section, getoption(obj->iniconfig, section, "hosts deny", preset)) == 1)
goto EC_CLEANUP;
- if (hostaccessvol(obj, section, getoption(obj->iniconfig, section, "allowed_hosts", preset)) == 0)
+ if (hostaccessvol(obj, section, getoption(obj->iniconfig, section, "hosts allow", preset)) == 0)
goto EC_CLEANUP;
}
if (val = getoption(obj->iniconfig, section, "password", preset))
EC_NULL( volume->v_password = strdup(val) );
- if (val = getoption(obj->iniconfig, section, "veto", preset))
+ if (val = getoption(obj->iniconfig, section, "veto files", preset))
EC_NULL( volume->v_veto = strdup(val) );
- if (val = getoption(obj->iniconfig, section, "volcharset", preset))
+ /* vol charset is in [V] strictly. */
+ /* However, this can be set in both of [G] and [V] for intuitiveness */
+ if (val = getoption(obj->iniconfig, section, "vol charset", preset))
EC_NULL( volume->v_volcodepage = strdup(val) );
else
- EC_NULL( volume->v_volcodepage = strdup("UTF8") );
+ EC_NULL( volume->v_volcodepage = strdup(obj->options.volcodepage) );
- if (val = getoption(obj->iniconfig, section, "maccharset", preset))
+ /* mac charset is in both of [G] and [V] */
+ if (val = getoption(obj->iniconfig, section, "mac charset", preset))
EC_NULL( volume->v_maccodepage = strdup(val) );
else
EC_NULL( volume->v_maccodepage = strdup(obj->options.maccodepage) );
- if (val = getoption(obj->iniconfig, section, "dbpath", preset))
- EC_NULL( volume->v_dbpath = volxlate(obj, NULL, MAXPATHLEN, val, pwd, path, name) );
+ bstring dbpath;
+ EC_NULL_LOG( val = iniparser_getstring(obj->iniconfig, INISEC_GLOBAL, "vol dbpath", _PATH_STATEDIR "CNID/") );
+ EC_NULL_LOG( dbpath = bformat("%s/%s/", val, name) );
+ volume->v_dbpath = strdup(bdata(dbpath));
+ bdestroy(dbpath);
- if (val = getoption(obj->iniconfig, section, "cnidscheme", preset))
+ if (val = getoption(obj->iniconfig, section, "cnid scheme", preset))
EC_NULL( volume->v_cnidscheme = strdup(val) );
else
volume->v_cnidscheme = strdup(DEFAULT_CNID_SCHEME);
if (val = getoption(obj->iniconfig, section, "umask", preset))
volume->v_umask = (int)strtol(val, NULL, 8);
- if (val = getoption(obj->iniconfig, section, "dperm", preset))
+ if (val = getoption(obj->iniconfig, section, "directory perm", preset))
volume->v_dperm = (int)strtol(val, NULL, 8);
- if (val = getoption(obj->iniconfig, section, "fperm", preset))
+ if (val = getoption(obj->iniconfig, section, "file perm", preset))
volume->v_fperm = (int)strtol(val, NULL, 8);
if (val = getoption(obj->iniconfig, section, "perm", preset))
volume->v_perm = (int)strtol(val, NULL, 8);
- if (val = getoption(obj->iniconfig, section, "volsizelimit", preset))
+ if (val = getoption(obj->iniconfig, section, "vol size limit", preset))
volume->v_limitsize = (uint32_t)strtoul(val, NULL, 10);
if (val = getoption(obj->iniconfig, section, "preexec", preset))
if (val = getoption(obj->iniconfig, section, "postexec", preset))
EC_NULL( volume->v_postexec = volxlate(obj, NULL, MAXPATHLEN, val, pwd, path, name) );
- if (val = getoption(obj->iniconfig, section, "root_preexec", preset))
+ if (val = getoption(obj->iniconfig, section, "root preexec", preset))
EC_NULL( volume->v_root_preexec = volxlate(obj, NULL, MAXPATHLEN, val, pwd, path, name) );
- if (val = getoption(obj->iniconfig, section, "root_postexec", preset))
+ if (val = getoption(obj->iniconfig, section, "root postexec", preset))
EC_NULL( volume->v_root_postexec = volxlate(obj, NULL, MAXPATHLEN, val, pwd, path, name) );
- if (val = getoption(obj->iniconfig, section, "adouble", preset)) {
+ if (val = getoption(obj->iniconfig, section, "appledouble", preset)) {
if (strcmp(val, "v2") == 0)
volume->v_adouble = AD_VERSION2;
else if (strcmp(val, "ea") == 0)
volume->v_adouble = AD_VERSION;
}
- if (val = getoption(obj->iniconfig, section, "cnidserver", preset)) {
+ if (val = getoption(obj->iniconfig, section, "cnid server", preset)) {
EC_NULL( p = strdup(val) );
volume->v_cnidserver = p;
if (q = strrchr(val, ':')) {
volume->v_casefold = AFPVOL_ULOWERMUPPER;
}
- if (val = getoption(obj->iniconfig, section, "options", preset)) {
+ if (val = getoption(obj->iniconfig, section, "vol options", preset)) {
q = strdup(val);
if (p = strtok(q, ", ")) {
while (p) {
/* do variable substitution for volume name */
if (STRCMP(secname, ==, INISEC_HOMES)) {
- if (p = iniparser_getstring(obj->iniconfig, INISEC_HOMES, "name", "$u's home"))
+ if (p = iniparser_getstring(obj->iniconfig, INISEC_HOMES, "home name", "$u's home"))
strlcpy(tmp, p, MAXPATHLEN);
else
strlcpy(tmp, p, MAXPATHLEN);
int load_charset(struct vol *vol)
{
if ((vol->v_maccharset = add_charset(vol->v_maccodepage)) == (charset_t)-1) {
- LOG(log_error, logtype_default, "Setting Mac codepage '%s' failed", vol->v_maccodepage);
+ LOG(log_error, logtype_default, "Setting mac charset '%s' failed", vol->v_maccodepage);
return -1;
}
if ((vol->v_volcharset = add_charset(vol->v_volcodepage)) == (charset_t)-1) {
- LOG(log_error, logtype_default, "Setting volume codepage '%s' failed", vol->v_volcodepage);
+ LOG(log_error, logtype_default, "Setting vol charset '%s' failed", vol->v_volcodepage);
return -1;
}
path, user, pw->pw_dir, volpath);
/* do variable substitution for volume name */
- p = iniparser_getstring(obj->iniconfig, INISEC_HOMES, "name", "$u's home");
+ p = iniparser_getstring(obj->iniconfig, INISEC_HOMES, "home name", "$u's home");
strlcpy(tmpbuf, p, AFPVOL_U8MNAMELEN);
EC_NULL_LOG( volxlate(obj, volname, sizeof(volname) - 1, tmpbuf, pw, volpath, NULL) );
AFPObj->afp_version = 11;
options->configfile = AFPObj->cmdlineconfigfile ? strdup(AFPObj->cmdlineconfigfile) : strdup(_PATH_CONFDIR "afp.conf");
- options->sigconffile = strdup(_PATH_CONFDIR "afp_signature.conf");
- options->uuidconf = strdup(_PATH_CONFDIR "afp_voluuid.conf");
+ options->sigconffile = strdup(_PATH_STATEDIR "afp_signature.conf");
+ options->uuidconf = strdup(_PATH_STATEDIR "afp_voluuid.conf");
options->flags = OPTION_ACL2MACCESS | OPTION_UUID | OPTION_SERVERNOTIF | AFPObj->cmdlineflags;
if ((config = iniparser_load(AFPObj->options.configfile)) == NULL)
AFPObj->iniconfig = config;
/* [Global] */
- options->logconfig = iniparser_getstrdup(config, INISEC_GLOBAL, "loglevel", "default:note");
- options->logfile = iniparser_getstrdup(config, INISEC_GLOBAL, "logfile", NULL);
+ options->logconfig = iniparser_getstrdup(config, INISEC_GLOBAL, "log level", "default:note");
+ options->logfile = iniparser_getstrdup(config, INISEC_GLOBAL, "log file", NULL);
- /* [AFP] "options" options wo values */
- if (q = iniparser_getstrdup(config, INISEC_GLOBAL, "options", NULL)) {
+ /* "server options" options wo values */
+ if (q = iniparser_getstrdup(config, INISEC_GLOBAL, "server options", NULL)) {
if (p = strtok(q, ", ")) {
while (p) {
if (strcasecmp(p, "nozeroconf"))
/* figure out options w values */
options->loginmesg = iniparser_getstrdup(config, INISEC_GLOBAL, "loginmesg", "");
- options->guest = iniparser_getstrdup(config, INISEC_GLOBAL, "guestname", "nobody");
- options->passwdfile = iniparser_getstrdup(config, INISEC_GLOBAL, "passwdfile", _PATH_AFPDPWFILE);
- options->uampath = iniparser_getstrdup(config, INISEC_GLOBAL, "uampath", _PATH_AFPDUAMPATH);
- options->uamlist = iniparser_getstrdup(config, INISEC_GLOBAL, "uamlist", "uams_dhx.so,uams_dhx2.so");
+ options->guest = iniparser_getstrdup(config, INISEC_GLOBAL, "guest account", "nobody");
+ options->passwdfile = iniparser_getstrdup(config, INISEC_GLOBAL, "passwd file",_PATH_AFPDPWFILE);
+ 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->k5service = iniparser_getstrdup(config, INISEC_GLOBAL, "k5service", NULL);
- options->k5realm = iniparser_getstrdup(config, INISEC_GLOBAL, "k5realm", NULL);
+ 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);
- options->ntdomain = iniparser_getstrdup(config, INISEC_GLOBAL, "ntdomain", NULL);
- options->ntseparator = iniparser_getstrdup(config, INISEC_GLOBAL, "ntseparator", NULL);
- options->mimicmodel = iniparser_getstrdup(config, INISEC_GLOBAL, "mimicmodel", NULL);
- options->adminauthuser = iniparser_getstrdup(config, INISEC_GLOBAL, "adminauthuser", NULL);
- options->connections = iniparser_getint (config, INISEC_GLOBAL, "maxcon", 200);
- options->passwdminlen = iniparser_getint (config, INISEC_GLOBAL, "passwdminlen", 0);
+ options->ntdomain = iniparser_getstrdup(config, INISEC_GLOBAL, "nt domain", NULL);
+ options->ntseparator = iniparser_getstrdup(config, INISEC_GLOBAL, "nt separator", NULL);
+ options->mimicmodel = iniparser_getstrdup(config, INISEC_GLOBAL, "mimic model", NULL);
+ options->adminauthuser = iniparser_getstrdup(config, INISEC_GLOBAL, "admin auth user",NULL);
+ options->connections = iniparser_getint (config, INISEC_GLOBAL, "max connections",200);
+ options->passwdminlen = iniparser_getint (config, INISEC_GLOBAL, "passwd minlen", 0);
options->tickleval = iniparser_getint (config, INISEC_GLOBAL, "tickleval", 30);
options->timeout = iniparser_getint (config, INISEC_GLOBAL, "timeout", 4);
options->dsireadbuf = iniparser_getint (config, INISEC_GLOBAL, "dsireadbuf", 12);
- options->server_quantum = iniparser_getint (config, INISEC_GLOBAL, "server_quantum", DSI_SERVQUANT_DEF);
+ options->server_quantum = iniparser_getint (config, INISEC_GLOBAL, "server quantum", DSI_SERVQUANT_DEF);
options->volnamelen = iniparser_getint (config, INISEC_GLOBAL, "volnamelen", 80);
options->dircachesize = iniparser_getint (config, INISEC_GLOBAL, "dircachesize", DEFAULT_MAX_DIRCACHE_SIZE);
options->tcp_sndbuf = iniparser_getint (config, INISEC_GLOBAL, "tcpsndbuf", 0);
options->tcp_rcvbuf = iniparser_getint (config, INISEC_GLOBAL, "tcprcvbuf", 0);
- options->fce_fmodwait = iniparser_getint (config, INISEC_GLOBAL, "fceholdfmod", 60);
- options->sleep = iniparser_getint (config, INISEC_GLOBAL, "sleep", 10);
- options->disconnected = iniparser_getint (config, INISEC_GLOBAL, "disconnect", 24);
+ options->fce_fmodwait = iniparser_getint (config, INISEC_GLOBAL, "fce holdfmod", 60);
+ options->sleep = iniparser_getint (config, INISEC_GLOBAL, "sleep time", 10);
+ options->disconnected = iniparser_getint (config, INISEC_GLOBAL, "disconnect time",24);
if ((p = iniparser_getstring(config, INISEC_GLOBAL, "hostname", NULL))) {
EC_NULL_LOG( options->hostname = strdup(p) );
options->hostname = strdup(val);
}
- if ((p = iniparser_getstring(config, INISEC_GLOBAL, "k5keytab", NULL))) {
+ if ((p = iniparser_getstring(config, INISEC_GLOBAL, "k5 keytab", NULL))) {
EC_NULL_LOG( options->k5keytab = malloc(strlen(p) + 14) );
snprintf(options->k5keytab, strlen(p) + 14, "KRB5_KTNAME=%s", p);
putenv(options->k5keytab);
}
#ifdef ADMIN_GRP
- if ((p = iniparser_getstring(config, INISEC_GLOBAL, "admingroup", NULL))) {
+ if ((p = iniparser_getstring(config, INISEC_GLOBAL, "admin group", NULL))) {
struct group *gr = getgrnam(p);
if (gr != NULL)
options->admingid = gr->gr_gid;
}
#endif /* ADMIN_GRP */
- q = iniparser_getstrdup(config, INISEC_GLOBAL, "cnidserver", "localhost:4700");
+ q = iniparser_getstrdup(config, INISEC_GLOBAL, "cnid server", "localhost:4700");
r = strrchr(q, ':');
if (r)
*r = 0;
free(q);
}
- if (!(p = iniparser_getstring(config, INISEC_GLOBAL, "unixcodepage", NULL))) {
+ /* Charset Options */
+
+ /* unix charset is in [G] only */
+ if (!(p = iniparser_getstring(config, INISEC_GLOBAL, "unix charset", NULL))) {
options->unixcharset = CH_UNIX;
options->unixcodepage = strdup("LOCALE");
} else {
if ((options->unixcharset = add_charset(p)) == (charset_t)-1) {
options->unixcharset = CH_UNIX;
options->unixcodepage = strdup("LOCALE");
- LOG(log_warning, logtype_afpd, "Setting Unix codepage to '%s' failed", p);
+ LOG(log_warning, logtype_afpd, "Setting unix charset to '%s' failed", p);
} else {
options->unixcodepage = strdup(p);
}
}
+
+ /* vol charset is in [V] strictly. */
+ /* However, this can be set in both of [G] and [V] for intuitiveness */
+ if (!(p = iniparser_getstring(config, INISEC_GLOBAL, "vol charset", NULL))) {
+ options->volcodepage = strdup("UTF8");
+ } else {
+ options->volcodepage = strdup(p);
+ }
- if (!(p = iniparser_getstring(config, INISEC_GLOBAL, "maccodepage", NULL))) {
+ /* mac charset is in both of [G] and [V] */
+ if (!(p = iniparser_getstring(config, INISEC_GLOBAL, "mac charset", NULL))) {
options->maccharset = CH_MAC;
options->maccodepage = strdup("MAC_ROMAN");
} else {
if ((options->maccharset = add_charset(p)) == (charset_t)-1) {
options->maccharset = CH_MAC;
options->maccodepage = strdup("MAC_ROMAN");
- LOG(log_warning, logtype_afpd, "Setting Mac codepage to '%s' failed", p);
+ LOG(log_warning, logtype_afpd, "Setting mac charset to '%s' failed", p);
} else {
options->maccodepage = strdup(p);
}
/* Check for sane values */
if (options->tickleval <= 0)
options->tickleval = 30;
- options->disconnected *= 3600 / options->tickleval;
- options->sleep *= 3600 / options->tickleval;
+ options->disconnected *= 3600 / options->tickleval;
+ options->sleep *= 3600 / options->tickleval;
if (options->timeout <= 0)
options->timeout = 4;
if (options->sleep <= 4)
if (options->volnamelen < 8)
options->volnamelen = 8; /* max mangled volname "???#FFFF" */
if (options->volnamelen > 255)
- options->volnamelen = 255; /* AFP3 spec */
+ options->volnamelen = 255; /* AFP3 spec */
EC_CLEANUP:
EC_EXIT;
}
-