noinst_HEADERS = auth.h afp_config.h desktop.h directory.h file.h \
- filedir.h fork.h globals.h icon.h mangle.h misc.h status.h switch.h \
+ filedir.h fork.h icon.h mangle.h misc.h status.h switch.h \
uam_auth.h uid.h unix.h volume.h hash.h acls.h acl_mappings.h extattrs.h \
dircache.h afp_zeroconf.h afp_avahi.h
#include <atalk/ldapconfig.h>
#endif
-#include "globals.h"
+#include <atalk/globals.h>
#include "afp_config.h"
#include "uam_auth.h"
#include "status.h"
#include <atalk/server_child.h>
#include <atalk/atp.h>
-#include "globals.h"
+#include <atalk/globals.h>
typedef struct AFPConfig {
AFPObj obj;
#include <atalk/paths.h>
#include <atalk/server_ipc.h>
-#include "globals.h"
+#include <atalk/globals.h>
#include "switch.h"
#include "auth.h"
#include "fork.h"
}
}
+/* SIGQUIT handler */
+static void ipc_reconnect_handler(int sig _U_)
+{
+ DSI *dsi = (DSI *)AFPobj->handle;
+
+ LOG(log_note, logtype_afpd, "ipc_reconnect_handler: got SIGQUIT, trying IPC reconnect");
+
+ if (reconnect_ipc(AFPobj) != 0) {
+ LOG(log_error, logtype_afpd, "ipc_reconnect_handler: failed IPC reconnect");
+ afp_dsi_close(AFPobj);
+ exit(EXITERR_SYS);
+ }
+
+ LOG(log_note, logtype_afpd, "ipc_reconnect_handler: resending client ID");
+ if (ipc_child_write(AFPobj->ipc_fd, IPC_GETSESSION, AFPobj->sinfo.clientid_len, AFPobj->sinfo.clientid) != 0) {
+ LOG(log_error, logtype_afpd, "ipc_reconnect_handler: failed IPC ID resend");
+ afp_dsi_close(AFPobj);
+ exit(EXITERR_SYS);
+ }
+ LOG(log_note, logtype_afpd, "ipc_reconnect_handler: done");
+}
+
/* SIGURG handler (primary reconnect) */
static void afp_dsi_transfer_session(int sig _U_)
{
u_int32_t err, cmd;
u_int8_t function;
struct sigaction action;
- struct pollfd pollfds[1];
AFPobj = obj;
+ dsi->AFPobj = obj;
obj->exit = afp_dsi_die;
obj->reply = (int (*)()) dsi_cmdreply;
obj->attention = (int (*)(void *, AFPUserBytes)) dsi_attention;
dsi->tickle = 0;
- pollfds[0].fd = obj->ipc_fd;
- pollfds[0].events = POLLOUT;
-
memset(&action, 0, sizeof(action));
+ sigfillset(&action.sa_mask);
+ action.sa_flags = SA_RESTART;
/* install SIGHUP */
action.sa_handler = afp_dsi_reload;
- sigemptyset( &action.sa_mask );
- sigaddset(&action.sa_mask, SIGALRM);
- sigaddset(&action.sa_mask, SIGTERM);
- sigaddset(&action.sa_mask, SIGUSR1);
- sigaddset(&action.sa_mask, SIGINT);
- sigaddset(&action.sa_mask, SIGUSR2);
- action.sa_flags = SA_RESTART;
if ( sigaction( SIGHUP, &action, NULL ) < 0 ) {
LOG(log_error, logtype_afpd, "afp_over_dsi: sigaction: %s", strerror(errno) );
afp_dsi_die(EXITERR_SYS);
/* install SIGURG */
action.sa_handler = afp_dsi_transfer_session;
- sigemptyset( &action.sa_mask );
- sigaddset(&action.sa_mask, SIGALRM);
- sigaddset(&action.sa_mask, SIGTERM);
- sigaddset(&action.sa_mask, SIGUSR1);
- sigaddset(&action.sa_mask, SIGINT);
- sigaddset(&action.sa_mask, SIGUSR2);
- action.sa_flags = SA_RESTART;
if ( sigaction( SIGURG, &action, NULL ) < 0 ) {
LOG(log_error, logtype_afpd, "afp_over_dsi: sigaction: %s", strerror(errno) );
afp_dsi_die(EXITERR_SYS);
/* install SIGTERM */
action.sa_handler = afp_dsi_die;
- sigemptyset( &action.sa_mask );
- sigaddset(&action.sa_mask, SIGALRM);
- sigaddset(&action.sa_mask, SIGHUP);
- sigaddset(&action.sa_mask, SIGUSR1);
- sigaddset(&action.sa_mask, SIGINT);
- sigaddset(&action.sa_mask, SIGUSR2);
- action.sa_flags = SA_RESTART;
if ( sigaction( SIGTERM, &action, NULL ) < 0 ) {
LOG(log_error, logtype_afpd, "afp_over_dsi: sigaction: %s", strerror(errno) );
afp_dsi_die(EXITERR_SYS);
}
- /* Added for server message support */
+ /* install SIGQUIT */
+ action.sa_handler = ipc_reconnect_handler;
+ if ( sigaction(SIGQUIT, &action, NULL ) < 0 ) {
+ LOG(log_error, logtype_afpd, "afp_over_dsi: sigaction: %s", strerror(errno) );
+ afp_dsi_die(EXITERR_SYS);
+ }
+
+ /* SIGUSR2 - server message support */
action.sa_handler = afp_dsi_getmesg;
- sigemptyset( &action.sa_mask );
- sigaddset(&action.sa_mask, SIGALRM);
- sigaddset(&action.sa_mask, SIGTERM);
- sigaddset(&action.sa_mask, SIGUSR1);
- sigaddset(&action.sa_mask, SIGHUP);
- sigaddset(&action.sa_mask, SIGINT);
- action.sa_flags = SA_RESTART;
if ( sigaction( SIGUSR2, &action, NULL) < 0 ) {
LOG(log_error, logtype_afpd, "afp_over_dsi: sigaction: %s", strerror(errno) );
afp_dsi_die(EXITERR_SYS);
/* SIGUSR1 - set down in 5 minutes */
action.sa_handler = afp_dsi_timedown;
- sigemptyset( &action.sa_mask );
- sigaddset(&action.sa_mask, SIGALRM);
- sigaddset(&action.sa_mask, SIGHUP);
- sigaddset(&action.sa_mask, SIGTERM);
- sigaddset(&action.sa_mask, SIGINT);
- sigaddset(&action.sa_mask, SIGUSR2);
action.sa_flags = SA_RESTART;
if ( sigaction( SIGUSR1, &action, NULL) < 0 ) {
LOG(log_error, logtype_afpd, "afp_over_dsi: sigaction: %s", strerror(errno) );
/* SIGINT - enable max_debug LOGging to /tmp/afpd.PID.XXXXXX */
action.sa_handler = afp_dsi_debug;
- sigfillset( &action.sa_mask );
- action.sa_flags = SA_RESTART;
if ( sigaction( SIGINT, &action, NULL) < 0 ) {
LOG(log_error, logtype_afpd, "afp_over_dsi: sigaction: %s", strerror(errno) );
afp_dsi_die(EXITERR_SYS);
}
#ifndef DEBUGGING
- /* tickle handler */
+ /* SIGALRM - tickle handler */
action.sa_handler = alarm_handler;
- sigemptyset(&action.sa_mask);
- sigaddset(&action.sa_mask, SIGHUP);
- sigaddset(&action.sa_mask, SIGTERM);
- sigaddset(&action.sa_mask, SIGUSR1);
- sigaddset(&action.sa_mask, SIGINT);
- sigaddset(&action.sa_mask, SIGUSR2);
- action.sa_flags = SA_RESTART;
if ((sigaction(SIGALRM, &action, NULL) < 0) ||
(setitimer(ITIMER_REAL, &dsi->timer, NULL) < 0)) {
afp_dsi_die(EXITERR_SYS);
* or a primary reconnect succeeds */
}
- static int saved_ipcfd = -1;
- if (saved_ipcfd == -1)
- saved_ipcfd = obj->ipc_fd;
- if (poll(pollfds, 1, 0) == 1) {
- if (pollfds[0].revents & (POLLHUP | POLLERR)) {
- if (saved_ipcfd == obj->ipc_fd && getppid() == 1) {
- close(obj->ipc_fd);
- sleep(30); /* give it enough time to start */
- if ((obj->ipc_fd = ipc_client_uds(_PATH_AFP_IPC)) == -1) {
- LOG(log_error, logtype_afpd, "afp_over_dsi: cant reconnect to master");
- afp_dsi_die(EXITERR_SYS);
- }
- }
- }
- }
-
-
if (!(dsi->flags & DSI_EXTSLEEP) && (dsi->flags & DSI_SLEEPING)) {
LOG(log_debug, logtype_afpd, "afp_over_dsi: got data, ending normal sleep");
dsi->flags &= ~DSI_SLEEPING;
#include <atalk/paths.h>
#include <atalk/util.h>
#include <atalk/compat.h>
+#include <atalk/globals.h>
-#include "globals.h"
#include "status.h"
#include "auth.h"
#include "dircache.h"
#endif /* HAVE_CONFIG_H */
#include <atalk/afp.h>
-#include "globals.h"
+#include <atalk/globals.h>
const char *AfpNum2name(int num)
{
#include <atalk/afp.h>
#include <atalk/bstrlib.h>
#include <atalk/bstradd.h>
+#include <atalk/globals.h>
#include "volume.h"
-#include "globals.h"
#include "directory.h"
#include "file.h"
#include "desktop.h"
#include <atalk/logger.h>
#include <atalk/server_ipc.h>
#include <atalk/uuid.h>
+#include <atalk/globals.h>
-#include "globals.h"
#include "auth.h"
#include "uam_auth.h"
#include "switch.h"
if (!obj->sinfo.clientid) {
obj->sinfo.clientid = malloc(idlen + 8);
memcpy(obj->sinfo.clientid, p, idlen + 8);
+ obj->sinfo.clientid_len = idlen + 8;
}
- if (ipc_child_write(&obj->ipc_fd, IPC_GETSESSION, idlen+8, p) == -1) {
-
- }
+ if (ipc_child_write(obj->ipc_fd, IPC_GETSESSION, idlen+8, p) != 0)
+ return AFPERR_MISC;
tklen = obj->sinfo.sessiontoken_len;
token = obj->sinfo.sessiontoken;
}
setitimer(ITIMER_REAL, &none, NULL);
/* check for old session, possibly transfering session from here to there */
- if (ipc_child_write(&obj->ipc_fd, IPC_DISCOLDSESSION, tklen, &token) == -1)
+ if (ipc_child_write(obj->ipc_fd, IPC_DISCOLDSESSION, tklen, &token) != 0)
goto exit;
/* write uint16_t DSI request ID */
if (writet(obj->ipc_fd, &dsi->header.dsi_requestID, 2, 0, 2) != 2) {
#include <sys/cdefs.h>
#endif /* HAVE_SYS_CDEFS_H */
-#include "globals.h"
+#include <atalk/globals.h>
struct afp_versions {
char *av_name;
#include <atalk/util.h>
#include <atalk/bstradd.h>
#include <atalk/unicode.h>
+#include <atalk/globals.h>
#include "desktop.h"
#include "directory.h"
#include "dircache.h"
#include "file.h"
#include "volume.h"
-#include "globals.h"
#include "filedir.h"
#include "fork.h"
#include <atalk/afp.h>
#include <atalk/util.h>
#include <atalk/logger.h>
+#include <atalk/globals.h>
#include "volume.h"
#include "directory.h"
#include "fork.h"
-#include "globals.h"
#include "desktop.h"
#include "mangle.h"
#define AFPD_DESKTOP_H 1
#include <sys/cdefs.h>
-#include "globals.h"
+#include <atalk/globals.h>
#include "volume.h"
struct savedt {
#include <atalk/queue.h>
#include <atalk/bstrlib.h>
#include <atalk/bstradd.h>
+#include <atalk/globals.h>
#include "dircache.h"
#include "directory.h"
#include "hash.h"
-#include "globals.h"
+
/*
* Directory Cache
#include <atalk/bstrlib.h>
#include <atalk/bstradd.h>
#include <atalk/errchk.h>
+#include <atalk/globals.h>
#include "directory.h"
#include "dircache.h"
#include "fork.h"
#include "file.h"
#include "filedir.h"
-#include "globals.h"
#include "unix.h"
#include "mangle.h"
#include "hash.h"
#endif
#include <atalk/directory.h>
+#include <atalk/globals.h>
-#include "globals.h"
#include "volume.h"
/* directory bits */
#include <atalk/util.h>
#include <atalk/bstrlib.h>
#include <atalk/bstradd.h>
+#include <atalk/globals.h>
#include "desktop.h"
#include "directory.h"
#include "dircache.h"
#include "volume.h"
-#include "globals.h"
#include "file.h"
#include "fork.h"
#include "filedir.h"
#include <atalk/afp.h>
#include <atalk/logger.h>
#include <atalk/ea.h>
+#include <atalk/globals.h>
-#include "globals.h"
#include "volume.h"
#include "desktop.h"
#include "directory.h"
#include <atalk/util.h>
#include <atalk/cnid.h>
#include <atalk/unix.h>
+#include <atalk/globals.h>
#include "directory.h"
#include "dircache.h"
#include "fork.h"
#include "file.h"
#include "filedir.h"
-#include "globals.h"
#include "unix.h"
/* the format for the finderinfo fields (from IM: Toolbox Essentials):
#include <sys/cdefs.h>
#include <netatalk/endian.h>
#include <atalk/adouble.h>
+#include <atalk/globals.h>
-#include "globals.h"
#include "volume.h"
#include "directory.h"
#include <atalk/bstrlib.h>
#include <atalk/bstradd.h>
#include <atalk/acl.h>
+#include <atalk/globals.h>
#include "directory.h"
#include "dircache.h"
#include "volume.h"
#include "fork.h"
#include "file.h"
-#include "globals.h"
#include "filedir.h"
#include "unix.h"
#include <sys/cdefs.h>
#include <sys/stat.h>
-#include "globals.h"
+#include <atalk/globals.h>
#include "volume.h"
extern struct afp_options default_options;
#include <atalk/atp.h>
#include <atalk/asp.h>
#include <atalk/afp.h>
-
#include <atalk/util.h>
#include <atalk/cnid.h>
+#include <atalk/globals.h>
#include "fork.h"
#include "file.h"
-#include "globals.h"
#include "directory.h"
#include "desktop.h"
#include "volume.h"
#include <ctype.h>
#include <pwd.h>
-#include "globals.h"
+#include <atalk/globals.h>
static char *l_curr;
static char *l_end;
+++ /dev/null
-/*
- * Copyright (c) 1990,1993 Regents of The University of Michigan.
- * All Rights Reserved. See COPYRIGHT.
- */
-
-#ifndef AFPD_GLOBALS_H
-#define AFPD_GLOBALS_H 1
-
-#include <sys/param.h>
-#include <sys/cdefs.h>
-
-#ifdef ADMIN_GRP
-#include <grp.h>
-#include <sys/types.h>
-#endif /* ADMIN_GRP */
-
-#ifdef HAVE_NETDB_H
-#include <netdb.h> /* this isn't header-protected under ultrix */
-#endif /* HAVE_NETDB_H */
-
-#include <netatalk/at.h>
-#include <atalk/afp.h>
-#include <atalk/compat.h>
-#include <atalk/unicode.h>
-#include <atalk/uam.h>
-
-/* #define DOSFILELEN 12 */ /* Type1, DOS-compat*/
-#define MACFILELEN 31 /* Type2, HFS-compat */
-#define UTF8FILELEN_EARLY 255 /* Type3, early Mac OS X 10.0-10.4.? */
-/* #define UTF8FILELEN_NAME_MAX 765 */ /* Type3, 10.4.?- , getconf NAME_MAX */
-/* #define UTF8FILELEN_SPEC 0xFFFF */ /* Type3, spec on document */
-/* #define HFSPLUSFILELEN 510 */ /* HFS+ spec, 510byte = 255codepoint */
-
-#define MAXUSERLEN 256
-
-#define OPTION_DEBUG (1 << 0)
-#define OPTION_USERVOLFIRST (1 << 1)
-#define OPTION_NOUSERVOL (1 << 2)
-#define OPTION_PROXY (1 << 3)
-#define OPTION_CUSTOMICON (1 << 4)
-#define OPTION_NOSLP (1 << 5)
-#define OPTION_ANNOUNCESSH (1 << 6)
-#define OPTION_UUID (1 << 7)
-#define OPTION_ACL2MACCESS (1 << 8)
-#define OPTION_NOZEROCONF (1 << 9)
-
-#ifdef FORCE_UIDGID
-/* set up a structure for this */
-typedef struct uidgidset_t {
- uid_t uid;
- gid_t gid;
-} uidgidset;
-#endif /* FORCE_UIDGID */
-
-/* a couple of these options could get stuck in unions to save
- * space. */
-struct afp_volume_name {
- time_t mtime;
- char *name;
- char *full_name;
- int loaded;
-};
-
-struct afp_options {
- int connections, transports, tickleval, timeout, server_notif, flags, dircachesize;
- int sleep; /* Maximum time allowed to sleep (in tickles) */
- int disconnected; /* Maximum time in disconnected state (in tickles) */
- unsigned int tcp_sndbuf, tcp_rcvbuf;
- unsigned char passwdbits, passwdminlen, loginmaxfail;
- u_int32_t server_quantum;
- int dsireadbuf; /* scale factor for sizefof(dsi->buffer) = server_quantum * dsireadbuf */
- char hostname[MAXHOSTNAMELEN + 1], *server, *ipaddr, *port, *configfile;
- struct at_addr ddpaddr;
- char *uampath, *fqdn;
- char *pidfile;
- char *sigconffile;
- char *uuidconf;
- struct afp_volume_name defaultvol, systemvol, uservol;
- int closevol;
-
- char *guest, *loginmesg, *keyfile, *passwdfile;
- char *uamlist;
- char *authprintdir;
- char *signatureopt;
- unsigned char signature[16];
- char *k5service, *k5realm, *k5keytab;
- char *unixcodepage,*maccodepage;
- charset_t maccharset, unixcharset;
- mode_t umask;
- mode_t save_mask;
-#ifdef ADMIN_GRP
- gid_t admingid;
-#endif /* ADMIN_GRP */
- int volnamelen;
-
- /* default value for winbind authentication */
- char *ntdomain, *ntseparator;
- char *logconfig;
-};
-
-#define AFPOBJ_TMPSIZ (MAXPATHLEN)
-typedef struct _AFPObj {
- int proto;
- unsigned long servernum;
- void *handle; /* either (DSI *) or (ASP *) */
- void *config;
- struct afp_options options;
- char *Obj, *Type, *Zone;
- char username[MAXUSERLEN];
- void (*logout)(void), (*exit)(int);
- int (*reply)(void *, int);
- int (*attention)(void *, AFPUserBytes);
- /* to prevent confusion, only use these in afp_* calls */
- char oldtmp[AFPOBJ_TMPSIZ + 1], newtmp[AFPOBJ_TMPSIZ + 1];
- void *uam_cookie; /* cookie for uams */
- struct session_info sinfo;
- uid_t uid; /* client running user id */
- int ipc_fd; /* anonymous PF_UNIX socket for IPC with afpd parent */
-#ifdef FORCE_UIDGID
- int force_uid;
- uidgidset uidgid;
-#endif
-} AFPObj;
-
-/* typedef for AFP functions handlers */
-typedef int (*AFPCmd)(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
-
-/* afp_dsi.c */
-extern AFPObj *AFPobj;
-
-extern int afp_version;
-extern int afp_errno;
-extern unsigned char nologin;
-extern struct dir *curdir;
-extern char getwdbuf[];
-
-/* FIXME CNID */
-extern const char *Cnid_srv;
-extern const char *Cnid_port;
-
-extern int get_afp_errno (const int param);
-extern void afp_options_init (struct afp_options *);
-extern int afp_options_parse (int, char **, struct afp_options *);
-extern int afp_options_parseline (char *, struct afp_options *);
-extern void afp_options_free (struct afp_options *,
- const struct afp_options *);
-extern void setmessage (const char *);
-extern void readmessage (AFPObj *);
-
-/* gettok.c */
-extern void initline (int, char *);
-extern int parseline (int, char *);
-
-/* afp_util.c */
-extern const char *AfpNum2name (int );
-extern const char *AfpErr2name(int err);
-
-/* directory.c */
-extern struct dir rootParent;
-
-#ifndef NO_DDP
-extern void afp_over_asp (AFPObj *);
-#endif /* NO_DDP */
-extern void afp_over_dsi (AFPObj *);
-
-#endif /* globals.h */
#define AFPD_ICON_H 1
#include <sys/cdefs.h>
-#include "globals.h"
+#include <atalk/globals.h>
static const unsigned char apple_atalk_icon[] = { /* default appletalk icon */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
#include <atalk/util.h>
#include <atalk/server_child.h>
#include <atalk/server_ipc.h>
+#include <atalk/globals.h>
-#include "globals.h"
#include "afp_config.h"
#include "status.h"
#include "fork.h"
switch( sig ) {
- case SIGTERM :
- LOG(log_note, logtype_afpd, "AFP Server shutting down on SIGTERM");
-
+ case SIGTERM:
+ case SIGQUIT:
+ switch (sig) {
+ case SIGTERM:
+ LOG(log_note, logtype_afpd, "AFP Server shutting down on SIGTERM");
+ break;
+ case SIGQUIT:
+ LOG(log_note, logtype_afpd, "AFP Server shutting down on SIGQUIT, NOT disconnecting clients");
+ break;
+ }
if (server_children)
server_child_kill(server_children, CHILD_DSIFORK, sig);
exit(0);
break;
- case SIGQUIT:
- LOG(log_note, logtype_afpd, "AFP Server shutting down on SIGQUIT, NOT disconnecting clients");
-
- for (config = configs; config; config = config->next)
- if (config->server_cleanup)
- config->server_cleanup(config);
-
- server_unlock(default_options.pidfile);
- exit(0);
- break;
-
case SIGUSR1 :
nologin++;
auth_unload();
case IPC_FD:
child = (afp_child_t *)polldata[i].data;
- if (fdset[i].revents & POLLIN) {
- LOG(log_debug, logtype_afpd, "main: IPC request from child[%u]", child->pid);
- if ((ret = ipc_server_read(server_children, child->ipc_fds[0])) == 0) {
- fdset_del_fd(&fdset, &polldata, &fdset_used, &fdset_size, child->ipc_fds[0]);
- close(child->ipc_fds[0]);
- child->ipc_fds[0] = -1;
- if (child->disasociated)
- server_child_remove(server_children, CHILD_DSIFORK, child->pid);
- }
- } else {
+ LOG(log_note, logtype_afpd, "main: IPC request from child[%u]", child->pid);
+
+ if ((ret = ipc_server_read(server_children, child->ipc_fds[0])) == 0) {
+ fdset_del_fd(&fdset, &polldata, &fdset_used, &fdset_size, child->ipc_fds[0]);
+ close(child->ipc_fds[0]);
+ child->ipc_fds[0] = -1;
if (child->disasociated) {
- fdset_del_fd(&fdset, &polldata, &fdset_used, &fdset_size, child->ipc_fds[0]);
- close(child->ipc_fds[0]);
- child->ipc_fds[0] = -1;
+ LOG(log_note, logtype_afpd, "main: removing reattached child[%u]", child->pid);
+ server_child_remove(server_children, CHILD_DSIFORK, child->pid);
}
}
break;
LOG(log_error, logtype_afpd, "main: readt: %s", strerror(errno));
close(fd[0]);
}
+ LOG(log_note, logtype_afpd, "main: welcome back child[%u]", pid);
if ((child = server_child_add(server_children, CHILD_DSIFORK, pid, fd)) == NULL) {
LOG(log_error, logtype_afpd, "main: server_child_add");
close(fd[0]);
#include <atalk/adouble.h>
#include <atalk/cnid.h>
#include <atalk/logger.h>
+#include <atalk/globals.h>
-#include "globals.h"
#include "volume.h"
#include "directory.h"
#include <atalk/dsi.h>
#include <atalk/util.h>
#include <atalk/logger.h>
-#include "globals.h"
+#include <atalk/globals.h>
+
#include "misc.h"
#define AFPD_MISC_H 1
#include <sys/cdefs.h>
-#include "globals.h"
+#include <atalk/globals.h>
/* FP functions */
/* messages.c */
#include <atalk/util.h>
#include <atalk/bstrlib.h>
#include <atalk/bstradd.h>
+#include <atalk/globals.h>
-#include "globals.h"
#include "volume.h"
#include "directory.h"
#include "fork.h"
#include <atalk/nbp.h>
#include <atalk/unicode.h>
#include <atalk/util.h>
+#include <atalk/globals.h>
-#include "globals.h" /* includes <netdb.h> */
#include "status.h"
#include "afp_config.h"
#include "icon.h"
#include <sys/cdefs.h>
#include <atalk/dsi.h>
#include <atalk/asp.h>
-#include "globals.h"
+#include <atalk/globals.h>
+
#include "afp_config.h"
/* we use these to prevent whacky alignment problems */
#include <atalk/afp.h>
#include <atalk/uam.h>
-
-#include "globals.h"
+#include <atalk/globals.h>
/* grab the FP functions */
#include "auth.h"
#include <atalk/dsi.h>
#include <atalk/afp.h>
#include <atalk/util.h>
+#include <atalk/globals.h>
-#include "globals.h"
#include "afp_config.h"
#include "auth.h"
#include "uam_auth.h"
#include <pwd.h>
#include <atalk/uam.h>
-#include "globals.h"
+#include <atalk/globals.h>
struct uam_mod {
void *uam_module;
#include <atalk/bstrlib.h>
#include <atalk/bstradd.h>
#include <atalk/ftw.h>
+#include <atalk/globals.h>
#ifdef CNID_DB
#include <atalk/cnid.h>
#endif /* CNID_DB*/
-#include "globals.h"
#include "directory.h"
#include "file.h"
#include "volume.h"
#include <atalk/volume.h>
#include <atalk/cnid.h>
#include <atalk/unicode.h>
+#include <atalk/globals.h>
-#include "globals.h"
#if 0
#include "hash.h"
#endif
#include <atalk/afp.h>
#include <atalk/uam.h>
-#include "../afpd/globals.h"
+#include <atalk/globals.h>
/* Number of bits for p which we generate. Everybode out there uses 512, so we beet them */
#define PRIMEBITS 1024
server_ipc.h tdb.h uam.h unicode.h util.h uuid.h volinfo.h \
zip.h ea.h acl.h unix.h directory.h hash.h volume.h
-noinst_HEADERS = cnid_dbd_private.h cnid_private.h bstradd.h bstrlib.h errchk.h ftw.h
+noinst_HEADERS = cnid_dbd_private.h cnid_private.h bstradd.h bstrlib.h errchk.h ftw.h globals.h
#include <netinet/in.h>
#include <atalk/afp.h>
#include <atalk/server_child.h>
+#include <atalk/globals.h>
#include <netatalk/endian.h>
#ifdef __OpenBSD__
/* child and parent processes might interpret a couple of these
* differently. */
typedef struct DSI {
+ AFPObj *AFPobj;
dsi_proto protocol;
struct dsi_block header;
struct sockaddr_storage server, client;
--- /dev/null
+/*
+ * Copyright (c) 1990,1993 Regents of The University of Michigan.
+ * All Rights Reserved. See COPYRIGHT.
+ */
+
+#ifndef AFPD_GLOBALS_H
+#define AFPD_GLOBALS_H 1
+
+#include <sys/param.h>
+#include <sys/cdefs.h>
+
+#ifdef ADMIN_GRP
+#include <grp.h>
+#include <sys/types.h>
+#endif /* ADMIN_GRP */
+
+#ifdef HAVE_NETDB_H
+#include <netdb.h> /* this isn't header-protected under ultrix */
+#endif /* HAVE_NETDB_H */
+
+#include <netatalk/at.h>
+#include <atalk/afp.h>
+#include <atalk/compat.h>
+#include <atalk/unicode.h>
+#include <atalk/uam.h>
+
+/* #define DOSFILELEN 12 */ /* Type1, DOS-compat*/
+#define MACFILELEN 31 /* Type2, HFS-compat */
+#define UTF8FILELEN_EARLY 255 /* Type3, early Mac OS X 10.0-10.4.? */
+/* #define UTF8FILELEN_NAME_MAX 765 */ /* Type3, 10.4.?- , getconf NAME_MAX */
+/* #define UTF8FILELEN_SPEC 0xFFFF */ /* Type3, spec on document */
+/* #define HFSPLUSFILELEN 510 */ /* HFS+ spec, 510byte = 255codepoint */
+
+#define MAXUSERLEN 256
+
+#define OPTION_DEBUG (1 << 0)
+#define OPTION_USERVOLFIRST (1 << 1)
+#define OPTION_NOUSERVOL (1 << 2)
+#define OPTION_PROXY (1 << 3)
+#define OPTION_CUSTOMICON (1 << 4)
+#define OPTION_NOSLP (1 << 5)
+#define OPTION_ANNOUNCESSH (1 << 6)
+#define OPTION_UUID (1 << 7)
+#define OPTION_ACL2MACCESS (1 << 8)
+#define OPTION_NOZEROCONF (1 << 9)
+
+#ifdef FORCE_UIDGID
+/* set up a structure for this */
+typedef struct uidgidset_t {
+ uid_t uid;
+ gid_t gid;
+} uidgidset;
+#endif /* FORCE_UIDGID */
+
+/* a couple of these options could get stuck in unions to save
+ * space. */
+struct afp_volume_name {
+ time_t mtime;
+ char *name;
+ char *full_name;
+ int loaded;
+};
+
+struct afp_options {
+ int connections, transports, tickleval, timeout, server_notif, flags, dircachesize;
+ int sleep; /* Maximum time allowed to sleep (in tickles) */
+ int disconnected; /* Maximum time in disconnected state (in tickles) */
+ unsigned int tcp_sndbuf, tcp_rcvbuf;
+ unsigned char passwdbits, passwdminlen, loginmaxfail;
+ u_int32_t server_quantum;
+ int dsireadbuf; /* scale factor for sizefof(dsi->buffer) = server_quantum * dsireadbuf */
+ char hostname[MAXHOSTNAMELEN + 1], *server, *ipaddr, *port, *configfile;
+ struct at_addr ddpaddr;
+ char *uampath, *fqdn;
+ char *pidfile;
+ char *sigconffile;
+ char *uuidconf;
+ struct afp_volume_name defaultvol, systemvol, uservol;
+ int closevol;
+
+ char *guest, *loginmesg, *keyfile, *passwdfile;
+ char *uamlist;
+ char *authprintdir;
+ char *signatureopt;
+ unsigned char signature[16];
+ char *k5service, *k5realm, *k5keytab;
+ char *unixcodepage,*maccodepage;
+ charset_t maccharset, unixcharset;
+ mode_t umask;
+ mode_t save_mask;
+#ifdef ADMIN_GRP
+ gid_t admingid;
+#endif /* ADMIN_GRP */
+ int volnamelen;
+
+ /* default value for winbind authentication */
+ char *ntdomain, *ntseparator;
+ char *logconfig;
+};
+
+#define AFPOBJ_TMPSIZ (MAXPATHLEN)
+typedef struct _AFPObj {
+ int proto;
+ unsigned long servernum;
+ void *handle; /* either (DSI *) or (ASP *) */
+ void *config;
+ struct afp_options options;
+ char *Obj, *Type, *Zone;
+ char username[MAXUSERLEN];
+ void (*logout)(void), (*exit)(int);
+ int (*reply)(void *, int);
+ int (*attention)(void *, AFPUserBytes);
+ /* to prevent confusion, only use these in afp_* calls */
+ char oldtmp[AFPOBJ_TMPSIZ + 1], newtmp[AFPOBJ_TMPSIZ + 1];
+ void *uam_cookie; /* cookie for uams */
+ struct session_info sinfo;
+ uid_t uid; /* client running user id */
+ int ipc_fd; /* anonymous PF_UNIX socket for IPC with afpd parent */
+#ifdef FORCE_UIDGID
+ int force_uid;
+ uidgidset uidgid;
+#endif
+} AFPObj;
+
+/* typedef for AFP functions handlers */
+typedef int (*AFPCmd)(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
+
+/* afp_dsi.c */
+extern AFPObj *AFPobj;
+
+extern int afp_version;
+extern int afp_errno;
+extern unsigned char nologin;
+extern struct dir *curdir;
+extern char getwdbuf[];
+
+/* FIXME CNID */
+extern const char *Cnid_srv;
+extern const char *Cnid_port;
+
+extern int get_afp_errno (const int param);
+extern void afp_options_init (struct afp_options *);
+extern int afp_options_parse (int, char **, struct afp_options *);
+extern int afp_options_parseline (char *, struct afp_options *);
+extern void afp_options_free (struct afp_options *,
+ const struct afp_options *);
+extern void setmessage (const char *);
+extern void readmessage (AFPObj *);
+
+/* gettok.c */
+extern void initline (int, char *);
+extern int parseline (int, char *);
+
+/* afp_util.c */
+extern const char *AfpNum2name (int );
+extern const char *AfpErr2name(int err);
+
+/* directory.c */
+extern struct dir rootParent;
+
+#ifndef NO_DDP
+extern void afp_over_asp (AFPObj *);
+#endif /* NO_DDP */
+extern void afp_over_dsi (AFPObj *);
+
+#endif /* globals.h */
#define ATALK_SERVER_IPC_H
#include <atalk/server_child.h>
+#include <atalk/globals.h>
#define IPC_DISCOLDSESSION 0
#define IPC_GETSESSION 1
extern int ipc_server_uds(const char *name);
extern int ipc_client_uds(const char *name);
+extern int reconnect_ipc(AFPObj *);
extern int ipc_server_read(server_child *children, int fd);
-extern ssize_t ipc_child_write(int *fd, uint16_t command, int len, void *token);
+extern int ipc_child_write(int fd, uint16_t command, int len, void *token);
#endif /* IPC_GETSESSION_LOGIN */
{
dsi->proto_close(dsi); /* 1 */
dsi->flags |= DSI_DISCONNECTED; /* 2 */
- if (getppid() == 1 || geteuid() == 0)
+ if (geteuid() == 0)
return -1;
return 0;
}
while (stored < length) {
len = buf_read(dsi, (u_int8_t *) data + stored, length - stored);
if (len == -1 && (errno == EINTR || errno == EAGAIN)) {
- LOG(log_debug, logtype_dsi, "dsi_stream_read: select read loop");
+ LOG(log_maxdebug, logtype_dsi, "dsi_stream_read: select read loop");
continue;
} else if (len > 0) {
stored += len;
if (type_configs[logtype].level >= log_debug)
goto log; /* bypass flooding checks */
+ goto log;
/* Prevent flooding: hash the message and check if we got the same one recently */
int hash = hash_message(temp_buffer) + log_src_linenumber;
#include <sys/un.h>
#include <errno.h>
#include <signal.h>
+#include <time.h>
#include <atalk/server_child.h>
#include <atalk/server_ipc.h>
#include <atalk/util.h>
#include <atalk/errchk.h>
#include <atalk/paths.h>
+#include <atalk/globals.h>
+#include <atalk/dsi.h>
#define IPC_HEADERLEN 14
#define IPC_MAXMSGSIZE 90
address_length = sizeof(address.sun_family) + sprintf(address.sun_path, name);
EC_ZERO_LOG( connect(fd, (struct sockaddr *)&address, address_length) ); /* 1 */
+ LOG(log_note, logtype_afpd, "ipc_client_uds: connected to master");
if (writet(fd, &pid, sizeof(pid_t), 0, 1) != sizeof(pid_t)) {
LOG(log_error, logtype_afpd, "ipc_client_uds: writet: %s", strerror(errno));
EC_FAIL;
}
+ LOG(log_note, logtype_afpd, "ipc_client_uds: sent pid");
EC_CLEANUP:
if (ret != 0) {
return fd;
}
+int reconnect_ipc(AFPObj *obj)
+{
+ int retrycount = 0;
+
+ LOG(log_note, logtype_afpd, "reconnect_ipc: start");
+
+ close(obj->ipc_fd);
+ obj->ipc_fd = -1;
+
+ srandom(getpid());
+ sleep((random() % 10) + 5); /* give it enough time to start */
+
+ while (retrycount++ < 10) {
+ if ((obj->ipc_fd = ipc_client_uds(_PATH_AFP_IPC)) == -1) {
+ LOG(log_error, logtype_afpd, "reconnect_ipc: cant reconnect to master");
+ sleep(1);
+ continue;
+ }
+ LOG(log_note, logtype_afpd, "reconnect_ipc: succesfull IPC reconnect");
+ return 0;
+ }
+ return -1;
+}
+
/* -----------------
* Ipc format
* command
}
/* ----------------- */
-ssize_t ipc_child_write(int *fd, uint16_t command, int len, void *msg)
+int ipc_child_write(int fd, uint16_t command, int len, void *msg)
{
- static int fd_saved = -1;
char block[IPC_MAXMSGSIZE], *p;
pid_t pid;
uid_t uid;
p = block;
- if (fd_saved == -1)
- fd_saved = *fd;
-
memset ( p, 0 , IPC_MAXMSGSIZE);
if (len + IPC_HEADERLEN > IPC_MAXMSGSIZE)
return -1;
LOG(log_debug, logtype_afpd, "ipc_child_write(%s)", ipc_cmd_str[command]);
- if ((ret = writet(*fd, block, len+IPC_HEADERLEN, 0, 1)) == -1) {
- if (*fd == fd_saved && getppid() == 1) {
- /* still using original socketpair IPC fd, master was possibly restarted, try reestablish connection across uds */
- if ((*fd = ipc_client_uds(_PATH_AFP_IPC)) == -1)
- return -1;
- /* now try again */
- ret = writet(*fd, block, len+IPC_HEADERLEN, 0, 1);
- }
+ if ((ret = writet(fd, block, len+IPC_HEADERLEN, 0, 1)) != -len+IPC_HEADERLEN) {
+ return -1;
}
- return ret;
+ return 0;
}