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 for (p = obj->dsi; p; p = q) {
64 afp_options_free(&obj->options);
67 /* the master loaded the volumes for zeroconf, get rid of that */
72 * Get everything running
74 int configinit(AFPObj *obj)
77 DSI *dsi, **next = &obj->dsi;
78 char *p = NULL, *q = NULL;
81 auth_load(obj->options.uampath, obj->options.uamlist);
82 set_signature(&obj->options);
84 LOG(log_debug, logtype_afpd, "DSIConfigInit: hostname: %s, listen: %s, port: %s",
85 obj->options.hostname,
86 obj->options.listen ? obj->options.listen : "(default: hostname)",
89 /* obj->options->listen is of the from "IP[:port][,IP:[PORT], ...]" */
90 /* obj->options->port is the default port to listen (548) */
92 if (obj->options.listen) {
93 EC_NULL( q = p = strdup(obj->options.listen) );
94 EC_NULL( p = strtok(p, ", ") );
98 if ((dsi = dsi_init(obj, obj->options.hostname, p, obj->options.port)) == NULL)
101 status_init(obj, dsi);
105 LOG(log_note, logtype_afpd, "Netatalk AFP/TCP listening on %s:%d",
106 getip_string((struct sockaddr *)&dsi->server),
107 getip_port((struct sockaddr *)&dsi->server));
110 /* p is NULL if ! obj->options.listen */
111 p = strtok(NULL, ", ");
116 if (obj->dsi == NULL)
120 /* Parse afp_ldap.conf */
121 acl_ldap_readconfig(obj->iniconfig);
122 #endif /* HAVE_LDAP */
124 /* Now register with zeroconf, we also need the volumes for that */
125 if (! (obj->options.flags & OPTION_NOZEROCONF)) {
126 load_volumes(obj, NULL);
127 zeroconf_register(obj);
130 if ((r = iniparser_getstring(obj->iniconfig, INISEC_AFP, "fcelistener", NULL))) {
131 LOG(log_note, logtype_afpd, "Adding FCE listener: %s", r);
132 fce_add_udp_socket(r);
134 if ((r = iniparser_getstring(obj->iniconfig, INISEC_AFP, "fcecoalesce", NULL))) {
135 LOG(log_note, logtype_afpd, "Fce coalesce: %s", r);
138 if ((r = iniparser_getstring(obj->iniconfig, INISEC_AFP, "fceevents", NULL))) {
139 LOG(log_note, logtype_afpd, "Fce events: %s", r);