X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=etc%2Fafpd%2Fafp_dsi.c;h=dfebaca0fb8f20e1781d46388afc469635a9bd07;hb=313b5f94348618d65523c1d8bde1fba9988f040a;hp=11390a894a4ddb9f7fb40a15aedb09c8614a9e74;hpb=3b9e9aa196ae6b8a189a6d64afe8d43da32ba0c4;p=netatalk.git diff --git a/etc/afpd/afp_dsi.c b/etc/afpd/afp_dsi.c index 11390a89..dfebaca0 100644 --- a/etc/afpd/afp_dsi.c +++ b/etc/afpd/afp_dsi.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "globals.h" #include "switch.h" @@ -38,11 +39,6 @@ #include "fork.h" #include "dircache.h" -#ifdef FORCE_UIDGID -#warning UIDGID -#include "uid.h" -#endif /* FORCE_UIDGID */ - /* * We generally pass this from afp_over_dsi to all afp_* funcs, so it should already be * available everywhere. Unfortunately some funcs (eg acltoownermode) need acces to it @@ -118,7 +114,7 @@ static void afp_dsi_die(int sig) dsi_attention(AFPobj->handle, AFPATTN_SHUTDOWN); afp_dsi_close(AFPobj); - if (sig) /* if no signal, assume dieing because logins are disabled & + if (sig) /* if no signal, assume dieing because logins are disabled & don't log it (maintenance mode)*/ LOG(log_info, logtype_afpd, "Connection terminated"); if (sig == SIGTERM || sig == SIGALRM) { @@ -284,7 +280,7 @@ static void alarm_handler(int sig _U_) if (dsi->flags & DSI_SLEEPING) { if (dsi->tickle > AFPobj->options.sleep) { - LOG(log_error, logtype_afpd, "afp_alarm: sleep time ended"); + LOG(log_note, logtype_afpd, "afp_alarm: sleep time ended"); afp_dsi_die(EXITERR_CLNT); } return; @@ -292,7 +288,7 @@ static void alarm_handler(int sig _U_) if (dsi->flags & DSI_DISCONNECTED) { if (dsi->tickle > AFPobj->options.disconnected) { - LOG(log_error, logtype_afpd, "afp_alarm: no reconnect within 10 minutes, goodbye"); + LOG(log_error, logtype_afpd, "afp_alarm: reconnect timer expired, goodbye"); afp_dsi_die(EXITERR_CLNT); } return; @@ -464,7 +460,7 @@ void afp_over_dsi(AFPObj *obj) SO_RCVBUF, &obj->options.tcp_rcvbuf, sizeof(obj->options.tcp_rcvbuf)) != 0) { - LOG(log_error, logtype_dsi, "dsi_tcp_open: setsockopt(SO_RCVBUF): %s", strerror(errno)); + LOG(log_error, logtype_dsi, "afp_over_dsi: setsockopt(SO_RCVBUF): %s", strerror(errno)); } } if (obj->options.tcp_sndbuf) { @@ -473,7 +469,7 @@ void afp_over_dsi(AFPObj *obj) SO_SNDBUF, &obj->options.tcp_sndbuf, sizeof(obj->options.tcp_sndbuf)) != 0) { - LOG(log_error, logtype_dsi, "dsi_tcp_open: setsockopt(SO_SNDBUF): %s", strerror(errno)); + LOG(log_error, logtype_dsi, "afp_over_dsi: setsockopt(SO_SNDBUF): %s", strerror(errno)); } } @@ -495,6 +491,13 @@ void afp_over_dsi(AFPObj *obj) } /* Some error on the client connection, enter disconnected state */ dsi->flags |= DSI_DISCONNECTED; + + /* the client sometimes logs out (afp_logout) but doesn't close the DSI session */ + if (dsi->flags & DSI_AFP_LOGGED_OUT) { + afp_dsi_close(obj); + exit(0); + } + pause(); /* gets interrupted by SIGALARM or SIGURG tickle */ continue; /* continue receiving until disconnect timer expires * or a primary reconnect succeeds */ @@ -509,8 +512,6 @@ void afp_over_dsi(AFPObj *obj) if (reload_request) { reload_request = 0; load_volumes(AFPobj); - dircache_dump(); - log_dircache_stat(); } /* The first SIGINT enables debugging, the next restores the config */ @@ -518,6 +519,8 @@ void afp_over_dsi(AFPObj *obj) static int debugging = 0; debug_request = 0; + dircache_dump(); + if (debugging) { if (obj->options.logconfig) setuplog(obj->options.logconfig); @@ -539,13 +542,14 @@ void afp_over_dsi(AFPObj *obj) switch(cmd) { case DSIFUNC_CLOSE: + LOG(log_debug, logtype_afpd, "DSI: close session request"); afp_dsi_close(obj); LOG(log_note, logtype_afpd, "done"); - return; + exit(0); case DSIFUNC_TICKLE: dsi->flags &= ~DSI_DATA; /* thats no data in the sense we use it in alarm_handler */ - LOG(log_debug, logtype_afpd, "DSI client tickle"); + LOG(log_debug, logtype_afpd, "DSI: client tickle"); /* timer is not every 30 seconds anymore, so we don't get killed on the client side. */ if ((dsi->flags & DSI_DIE)) dsi_tickle(dsi); @@ -591,11 +595,6 @@ void afp_over_dsi(AFPObj *obj) dir_free_invalid_q(); -#ifdef FORCE_UIDGID - /* bring everything back to old euid, egid */ - if (obj->force_uid) - restore_uidgid ( &obj->uidgid ); -#endif /* FORCE_UIDGID */ dsi->flags &= ~DSI_RUNNING; /* Add result to the AFP replay cache */ @@ -637,11 +636,6 @@ void afp_over_dsi(AFPObj *obj) AfpNum2name(function), AfpErr2name(err)); dsi->flags &= ~DSI_RUNNING; -#ifdef FORCE_UIDGID - /* bring everything back to old euid, egid */ - if (obj->force_uid) - restore_uidgid ( &obj->uidgid ); -#endif /* FORCE_UIDGID */ } else { LOG(log_error, logtype_afpd, "(write) bad function %x", function); dsi->datalen = 0;