2 * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
3 * All Rights Reserved. See COPYRIGHT.
8 #endif /* HAVE_CONFIG_H */
17 #include <sys/socket.h>
18 #include <netinet/in.h>
19 #include <arpa/inet.h>
21 #include <atalk/logger.h>
22 #include <atalk/util.h>
23 #include <atalk/dsi.h>
24 #include <atalk/afp.h>
25 #include <atalk/compat.h>
26 #include <atalk/server_child.h>
27 #include <atalk/globals.h>
28 #include <atalk/errchk.h>
29 #include <atalk/netatalk_conf.h>
30 #include <atalk/fce_api.h>
33 #include <atalk/ldapconfig.h>
36 #include "afp_config.h"
40 #include "afp_zeroconf.h"
44 * Free and cleanup all linked DSI objects from config
46 * Preserve object pointed to by "dsi".
47 * "dsi" can be NULL in which case all DSI objects _and_ the options object are freed
49 void configfree(AFPObj *obj, DSI *dsi)
53 /* the master loaded the volumes for zeroconf, get rid of that */
56 for (p = obj->dsi; p; p = q) {
68 afp_options_free(&obj->options);
73 * Get everything running
75 int configinit(AFPObj *obj)
78 DSI *dsi, **next = &obj->dsi;
79 char *p = NULL, *q = NULL, *savep;
82 auth_load(obj->options.uampath, obj->options.uamlist);
83 set_signature(&obj->options);
85 LOG(log_debug, logtype_afpd, "DSIConfigInit: hostname: %s, listen: %s, port: %s",
86 obj->options.hostname,
87 obj->options.listen ? obj->options.listen : "(default: hostname)",
90 /* obj->options->listen is of the from "IP[:port][,IP:[PORT], ...]" */
91 /* obj->options->port is the default port to listen (548) */
93 if (obj->options.listen) {
94 EC_NULL( q = p = strdup(obj->options.listen) );
95 EC_NULL( p = strtok_r(p, ", ", &savep) );
99 if ((dsi = dsi_init(obj, obj->options.hostname, p, obj->options.port)) == NULL)
102 status_init(obj, dsi);
107 LOG(log_note, logtype_afpd, "Netatalk AFP/TCP listening on %s:%d",
108 getip_string((struct sockaddr *)&dsi->server),
109 getip_port((struct sockaddr *)&dsi->server));
112 /* p is NULL if ! obj->options.listen */
113 p = strtok_r(NULL, ", ", &savep);
120 acl_ldap_readconfig(obj->iniconfig);
121 #endif /* HAVE_LDAP */
123 /* Now register with zeroconf, we also need the volumes for that */
124 if (! (obj->options.flags & OPTION_NOZEROCONF)) {
125 load_volumes(obj, NULL);
126 zeroconf_register(obj);
129 if ((r = iniparser_getstring(obj->iniconfig, INISEC_GLOBAL, "fce listener", NULL))) {
130 LOG(log_note, logtype_afpd, "Adding FCE listener: %s", r);
131 fce_add_udp_socket(r);
133 if ((r = iniparser_getstring(obj->iniconfig, INISEC_GLOBAL, "fce coalesce", NULL))) {
134 LOG(log_note, logtype_afpd, "Fce coalesce: %s", r);
137 if ((r = iniparser_getstring(obj->iniconfig, INISEC_GLOBAL, "fce events", NULL))) {
138 LOG(log_note, logtype_afpd, "Fce events: %s", r);