-#define MAXVAL 1024
-int afp_config_parse(AFPObj *AFPObj)
-{
- dictionary *config = AFPObj->iniconfig;
- struct afp_options *options = &AFPObj->options;
- int i;
- const char *p, *tmp;
- char val[MAXVAL];
-
- memset(options, 0, sizeof(struct afp_options));
- options->configfile = strdup(_PATH_CONFDIR "afp.conf");
- options->sigconffile = strdup(_PATH_CONFDIR "afp_signature.conf");
- options->uuidconf = strdup(_PATH_CONFDIR "afp_voluuid.conf");
- options->flags |= OPTION_ACL2MACCESS | OPTION_UUID | OPTION_SERVERNOTIF;
-
- while (EOF != (p = getopt(AFPObj->argc, AFPObj->argv, "dF:"))) {
- switch (p) {
- case 'd':
- options->flags |= OPTION_DEBUG;
- break;
- case 'F':
- if (options->configfile)
- free(options->configfile);
- options->configfile = optarg;
- break;
- default :
- break;
- }
- }
-
- if ((config = iniparser_load(AFPObj->options.configfile)) == NULL)
- return -1;
- AFPObj->iniconfig = config;
-
- /* [Global] */
- options->logconfig = iniparser_getstring(config, INISEC_GLOBAL, "loglevel", "default:note");
- options->logfile = iniparser_getstring(config, INISEC_GLOBAL, "logfile", NULL);
- set_processname("afpd");
- setuplog(logconfig, logfile);
-
- /* [AFP] "options" options wo values */
- p = iniparser_getstring(config, INISEC_AFP, "options", "");
- strcpy(val, " ");
- strlcat(val, p, MAXVAL);
-
- if (strstr(val, " nozeroconf"))
- options->flags |= OPTION_NOZEROCONF;
- if (strstr(val, " icon"))
- options->flags |= OPTION_CUSTOMICON;
- if (strstr(val, " noicon"))
- options->flags &= ~OPTION_CUSTOMICON;
- if (strstr(val, " advertise_ssh"))
- options->flags |= OPTION_ANNOUNCESSH;
- if (strstr(val, " noacl2maccess"))
- options->flags &= ~OPTION_ACL2MACCESS;
- if (strstr(val, " keepsessions"))
- options->flags |= OPTION_KEEPSESSIONS;
- if (strstr(val, " keepsessions"))
- options->flags |= OPTION_CLOSEVOL;
- if (strstr(val, " client_polling"))
- options->flags &= ~OPTION_SERVERNOTIF;
- if (strstr(val, " nosavepassword"))
- options->passwdbits |= PASSWD_NOSAVE;
- if (strstr(val, " savepassword"))
- options->passwdbits &= ~PASSWD_NOSAVE;
- if (strstr(val, " nosetpassword"))
- options->passwdbits &= ~PASSWD_SET;
- if (strstr(val, " setpassword"))
- options->passwdbits |= PASSWD_SET;
-
- /* figure out options w values */
-
- options->loginmesg = iniparser_getstring(config, INISEC_AFP, "loginmesg", "");
- options->guest = iniparser_getstring(config, INISEC_AFP, "guestname", "nobody");
- options->passwdfile = iniparser_getstring(config, INISEC_AFP, "passwdfile", _PATH_AFPDPWFILE);
- options->uampath = iniparser_getstring(config, INISEC_AFP, "uampath", _PATH_AFPDUAMPATH);
- options->uamlist = iniparser_getstring(config, INISEC_AFP, "uamlist", "uams_dhx.so,uams_dhx2.so");
- options->port = iniparser_getstring(config, INISEC_AFP, "port", "548");
- options->signatureopt = iniparser_getstring(config, INISEC_AFP, "signature", "auto");
-
- options->connections = iniparser_getint (config, INISEC_AFP, "maxcon", 200);
- options->passwdminlen = iniparser_getint (config, INISEC_AFP, "passwdminlen", 0);
- options->tickleval = iniparser_getint (config, INISEC_AFP, "tickleval", 30);
- options->timeout = iniparser_getint (config, INISEC_AFP, "timeout", 4);
- options->dsireadbuf = iniparser_getint (config, INISEC_AFP, "dsireadbuf", 12);
- options->server_quantum = iniparser_getint (config, INISEC_AFP, "server_quantum", DSI_SERVQUANT_DEF);
- options->volnamelen = iniparser_getint (config, INISEC_AFP, "volnamelen", 80);
- options->dircachesize = iniparser_getint (config, INISEC_AFP, "dircachesize", DEFAULT_MAX_DIRCACHE_SIZE);
- options->tcp_sndbuf = iniparser_getint (config, INISEC_AFP, "tcpsndbuf", 0);
- options->tcp_rcvbuf = iniparser_getint (config, INISEC_AFP, "tcprcvbuf", 0);
- options->fce_fmodwait = iniparser_getint (config, INISEC_AFP, "fceholdfmod", 60);
- options->sleep = iniparser_getint (config, INISEC_AFP, "sleep", 10) * 60 * 2;
- options->disconnect = iniparser_getint (config, INISEC_AFP, "disconnect" 24) * 60 * 2;
-
- options->k5service = iniparser_getstringdup(config, INISEC_AFP, "k5service", NULL);
- options->k5realm = iniparser_getstringdup(config, INISEC_AFP, "k5realm", NULL);
- options->authprintdir = iniparser_getstringdup(config, INISEC_AFP, "authprintdir", NULL);
- options->ipaddr = iniparser_getstringdup(config, INISEC_AFP, "ipaddr", NULL);
- options->hostname = iniparser_getstringdup(config, INISEC_AFP, "hostname", NULL);
- options->ntdomain = iniparser_getstringdup(config, INISEC_AFP, "ntdomain", NULL);
- options->ntseparator = iniparser_getstringdup(config, INISEC_AFP, "ntseparator", NULL);
- options->mimicmodel = iniparser_getstringdup(config, INISEC_AFP, "mimicmodel", NULL);
- options->adminauthuser = iniparser_getstringdup(config, INISEC_AFP, "adminauthuser", NULL);
-
- if ((p = iniparser_getstring(config, INISEC_AFP, "k5keytab", 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_AFP, "admingroup", NULL))) {
- struct group *gr = getgrnam(p);
- if (gr != NULL)
- options->admingid = gr->gr_gid;
- }
-#endif /* ADMIN_GRP */
-
- p = iniparser_getstring(config, INISEC_AFP, "cnidserver", "localhost:4700");
- tmp = strrchr(p, ':');
- if (tmp)
- *t = 0;
- options->Cnid_srv = strdup(p);
- if (tmp)
- options->Cnid_port = strdup(tmp + 1);
- LOG(log_debug, logtype_afpd, "CNID Server: %s:%s", options->Cnid_srv, options->Cnid_port);
-
-
- if ((p = iniparser_getstring(config, INISEC_AFP, "fqdn", NULL))) {
- /* do a little checking for the domain name. */
- tmp = strchr(c, ':');
- if (tmp)
- *tmp = '\0';
- if (gethostbyname(p)) {
- if (tmp)
- *tmp = ':';
- if ((opt = strdup(p)))
- options->fqdn = opt;
- } else {
- LOG(log_error, logtype_afpd, "error parsing -fqdn, gethostbyname failed for: %s", c);
- }
- }
-
- p = iniparser_getstring(config, INISEC_AFP, "unixcodepage", "LOCALE");
- if ((options->unixcharset = add_charset(p)) == (charset_t)-1) {
- options->unixcharset = CH_UNIX;
- LOG(log_warning, logtype_afpd, "Setting Unix codepage to '%s' failed", p);
- } else {
- options->unixcodepage = strdup(p);
- }
-
- p = iniparser_getstring(config, INISEC_AFP, "maccodepage", "MAC_ROMAN");
- if ((options->maccharset = add_charset(p)) == (charset_t)-1) {
- options->maccharset = CH_MAC;
- LOG(log_warning, logtype_afpd, "Setting Unix codepage to '%s' failed", p);
- } else {
- options->maccharset = strdup(p);
- }
-
- if ((p = iniparser_getstring(config, INISEC_AFP, "fcelistener", NULL))) {
- LOG(log_note, logtype_afpd, "Adding FCE listener: %s", p);
- fce_add_udp_socket(p);
- }
- if ((p = iniparser_getstring(config, INISEC_AFP, "fcecoalesce", NULL))) {
- LOG(log_note, logtype_afpd, "Fce coalesce: %s", p);
- fce_set_coalesce(p);
- }
- if ((p = iniparser_getstring(config, INISEC_AFP, "fceevents", NULL))) {
- LOG(log_note, logtype_afpd, "Fce events: %s", p);
- fce_set_events(p);
- }
-
- /* Check for sane values */
- if (options->tickleval <= 0)
- options->tickleval = 30;
- if (options->timeout <= 0)
- options->timeout = 4;
- if (options->sleep <= 4)
- options->disconnected = options->sleep = 4;
- if (options->dsireadbuf < 6)
- options->dsireadbuf = 6;
- if (options->volnamelen < 8)
- options->volnamelen = 8; /* max mangled volname "???#FFFF" */
- if (options->volnamelen > 255)
- options->volnamelen = 255; /* AFP3 spec */
-
- return 1;
-}
-