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 config and DSI
46 * "dsi" can be NULL in which case all DSI objects and the config object is freed,
47 * otherwise its an afpd session child and only any unneeded DSI objects are freed
49 void configfree(AFPObj *obj, DSI *dsi)
54 /* Master afpd reloading config */
56 if (! (obj->options.flags & OPTION_NOZEROCONF)) {
58 zeroconf_deregister();
62 /* Master and child releasing unneeded DSI handles */
63 for (p = obj->dsi; p; p = q) {
72 /* afpd session child passes dsi handle to obj handle */
80 * Get everything running
82 int configinit(AFPObj *obj)
85 DSI *dsi, **next = &obj->dsi;
86 char *p = NULL, *q = NULL, *savep;
89 auth_load(obj->options.uampath, obj->options.uamlist);
90 set_signature(&obj->options);
92 acl_ldap_freeconfig();
93 #endif /* HAVE_LDAP */
95 LOG(log_debug, logtype_afpd, "DSIConfigInit: hostname: %s, listen: %s, port: %s",
96 obj->options.hostname,
97 obj->options.listen ? obj->options.listen : "(default: hostname)",
100 /* obj->options->listen is of the from "IP[:port][,IP:[PORT], ...]" */
101 /* obj->options->port is the default port to listen (548) */
103 if (obj->options.listen) {
104 EC_NULL( q = p = strdup(obj->options.listen) );
105 EC_NULL( p = strtok_r(p, ", ", &savep) );
109 if ((dsi = dsi_init(obj, obj->options.hostname, p, obj->options.port)) == NULL)
112 status_init(obj, dsi);
117 LOG(log_note, logtype_afpd, "Netatalk AFP/TCP listening on %s:%d",
118 getip_string((struct sockaddr *)&dsi->server),
119 getip_port((struct sockaddr *)&dsi->server));
122 /* p is NULL if ! obj->options.listen */
123 p = strtok_r(NULL, ", ", &savep);
130 acl_ldap_readconfig(obj->iniconfig);
131 #endif /* HAVE_LDAP */
133 /* Now register with zeroconf, we also need the volumes for that */
134 if (! (obj->options.flags & OPTION_NOZEROCONF)) {
136 zeroconf_register(obj);
139 if ((r = iniparser_getstring(obj->iniconfig, INISEC_GLOBAL, "fce listener", NULL))) {
140 LOG(log_note, logtype_afpd, "Adding FCE listener: %s", r);
141 fce_add_udp_socket(r);
143 if ((r = iniparser_getstring(obj->iniconfig, INISEC_GLOBAL, "fce coalesce", NULL))) {
144 LOG(log_note, logtype_afpd, "Fce coalesce: %s", r);
147 if ((r = iniparser_getstring(obj->iniconfig, INISEC_GLOBAL, "fce events", NULL))) {
148 LOG(log_note, logtype_afpd, "Fce events: %s", r);