X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=etc%2Fafpd%2Fauth.c;h=a41c624d8db739edfe5e46554aeb3fc8a7e7d1f8;hb=465246e257d9aff9855e3e35d8fd5983db932b45;hp=cd2f73f3cfb7a384df8e7dc9f0ca8154eabba3af;hpb=85a8591621dc4c47417402a24df31e40bd7cae15;p=netatalk.git diff --git a/etc/afpd/auth.c b/etc/afpd/auth.c index cd2f73f3..a41c624d 100644 --- a/etc/afpd/auth.c +++ b/etc/afpd/auth.c @@ -39,8 +39,8 @@ extern void afp_get_cmdline( int *ac, char ***av ); #include #include #include +#include -#include "globals.h" #include "auth.h" #include "uam_auth.h" #include "switch.h" @@ -436,12 +436,14 @@ static int login(AFPObj *obj, struct passwd *pwd, void (*logout)(void), int expi } /* ---------------------- */ -int afp_zzz(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbuflen) +int afp_zzz(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen) { uint32_t data; DSI *dsi = (DSI *)AFPobj->handle; *rbuflen = 0; + ibuf += 2; + ibuflen -= 2; if (ibuflen < 4) return AFPERR_MISC; @@ -457,19 +459,20 @@ int afp_zzz(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbu if (data & AFPZZZ_EXT_WAKEUP) { /* wakeup request from exetended sleep */ if (dsi->flags & DSI_EXTSLEEP) { - LOG(log_debug, logtype_afpd, "afp_zzz: waking up from extended sleep"); + LOG(log_note, logtype_afpd, "afp_zzz: waking up from extended sleep"); dsi->flags &= ~(DSI_SLEEPING | DSI_EXTSLEEP); } } else { /* sleep request */ dsi->flags |= DSI_SLEEPING; if (data & AFPZZZ_EXT_SLEEP) { - LOG(log_debug, logtype_afpd, "afp_zzz: entering extended sleep"); + LOG(log_note, logtype_afpd, "afp_zzz: entering extended sleep"); dsi->flags |= DSI_EXTSLEEP; } else { - LOG(log_debug, logtype_afpd, "afp_zzz: entering normal sleep"); + LOG(log_note, logtype_afpd, "afp_zzz: entering normal sleep"); } } + /* * According to AFP 3.3 spec we should not return anything, * but eg 10.5.8 server still returns the numbers of hours @@ -591,7 +594,13 @@ int afp_getsession( if (ibuflen < idlen || idlen > (90-10)) { return AFPERR_PARAM; } - ipc_child_write(obj->ipc_fd, IPC_GETSESSION, idlen+8, p); + 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) != 0) + return AFPERR_MISC; tklen = obj->sinfo.sessiontoken_len; token = obj->sinfo.sessiontoken; } @@ -673,7 +682,7 @@ int afp_disconnect(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, 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) { @@ -932,11 +941,15 @@ int afp_logincont(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *r } -int afp_logout(AFPObj *obj, char *ibuf _U_, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen _U_) +int afp_logout(AFPObj *obj, char *ibuf _U_, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen) { + DSI *dsi = (DSI *)(obj->handle); + LOG(log_note, logtype_afpd, "AFP logout by %s", obj->username); + of_close_all_forks(); close_all_vol(); - obj->exit(0); + dsi->flags = DSI_AFP_LOGGED_OUT; + *rbuflen = 0; return AFP_OK; }