X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=etc%2Fafpd%2Fauth.c;h=3e0fd5ebeecae396babc23d48c6d7ee859e99a1e;hb=d28f176330075b2789ce4d50a64fc3fe5d6bbe9b;hp=0a5727fad0304babb30cb3f7a2fd23504adb5eb4;hpb=e6a19801e7d0ad53350a396b4a7f3d5762d4fc1a;p=netatalk.git diff --git a/etc/afpd/auth.c b/etc/afpd/auth.c index 0a5727fa..3e0fd5eb 100644 --- a/etc/afpd/auth.c +++ b/etc/afpd/auth.c @@ -26,9 +26,6 @@ #include #include #include -#include -#include -#include #ifdef TRU64 #include @@ -39,6 +36,10 @@ extern void afp_get_cmdline( int *ac, char ***av ); #endif /* TRU64 */ +#include +#include +#include + #include "globals.h" #include "auth.h" #include "uam_auth.h" @@ -545,7 +546,7 @@ int afp_getsession( token = obj->sinfo.sessiontoken; } break; - case 3: /* Jaguar */ + case 3: case 4: if (ibuflen >= 8 ) { p = ibuf; @@ -558,7 +559,7 @@ int afp_getsession( if (ibuflen < idlen || idlen > (90-10)) { return AFPERR_PARAM; } - server_ipc_write(IPC_GETSESSION, idlen+8, p ); + ipc_child_write(obj->ipc_fd, IPC_GETSESSION, idlen+8, p); tklen = obj->sinfo.sessiontoken_len; token = obj->sinfo.sessiontoken; } @@ -588,10 +589,10 @@ int afp_getsession( } /* ---------------------- */ -int afp_disconnect(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen) +int afp_disconnect(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen) { + DSI *dsi = (DSI *)obj->handle; u_int16_t type; - u_int32_t tklen; pid_t token; int i; @@ -632,11 +633,26 @@ int afp_disconnect(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf _ } } - /* killed old session, not easy */ - server_ipc_write(IPC_KILLTOKEN, tklen, &token); - sleep(1); + LOG(log_note, logtype_afpd, "afp_disconnect: trying primary reconnect"); - return AFPERR_SESSCLOS; /* was AFP_OK */ + /* check for old session, possibly transfering session from here to there */ + if (ipc_child_write(obj->ipc_fd, IPC_DISCOLDSESSION, tklen, &token) == -1) + goto exit; + /* write uint16_t DSI request ID */ + if (writet(obj->ipc_fd, &dsi->header.dsi_requestID, 2, 0, 2) != 2) { + LOG(log_error, logtype_afpd, "afp_disconnect: couldn't send DSI request ID"); + goto exit; + } + /* now send our connected AFP client socket */ + if (send_fd(obj->ipc_fd, dsi->socket) != 0) + goto exit; + /* Now see what happens: either afpd master kills us because our session */ + /* has been transfered to a old disconnected session, or we continue */ + sleep(2); + +exit: + LOG(log_error, logtype_afpd, "afp_disconnect: primary reconnect failed"); + return AFPERR_MISC; } /* ---------------------- */ @@ -959,6 +975,7 @@ int afp_getuserinfo(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, u_int8_t thisuser; u_int32_t id; u_int16_t bitmap; + char *bitmapp; LOG(log_debug, logtype_afpd, "begin afp_getuserinfo:"); @@ -977,8 +994,9 @@ int afp_getuserinfo(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, if ((bitmap & USERIBIT_ALL) != bitmap) return AFPERR_BITMAP; - /* copy the bitmap back to reply buffer */ + /* remember place where we store the possibly modified bitmap later */ memcpy(rbuf, ibuf, sizeof(bitmap)); + bitmapp = rbuf; rbuf += sizeof(bitmap); *rbuflen = sizeof(bitmap); @@ -997,29 +1015,27 @@ int afp_getuserinfo(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, *rbuflen += sizeof(id); } -#ifdef HAVE_ACLS if (bitmap & USERIBIT_UUID) { - int ret; - atalk_uuid_t uuid; - char *uuidstring; - - if ( ! (obj->options.flags & OPTION_UUID)) - return AFPERR_BITMAP; - LOG(log_debug, logtype_afpd, "afp_getuserinfo: get UUID for \'%s\'", obj->username); - ret = getuuidfromname( obj->username, UUID_USER, uuid); - if (ret != 0) { - LOG(log_info, logtype_afpd, "afp_getuserinfo: error getting UUID !"); - return AFPERR_NOITEM; - } - if (0 == (uuid_bin2string( uuid, &uuidstring))) { - LOG(log_debug, logtype_afpd, "afp_getuserinfo: got UUID: %s", uuidstring); - free(uuidstring); + if ( ! (obj->options.flags & OPTION_UUID)) { + bitmap &= ~USERIBIT_UUID; + bitmap = htons(bitmap); + memcpy(bitmapp, &bitmap, sizeof(bitmap)); + } else { + LOG(log_debug, logtype_afpd, "afp_getuserinfo: get UUID for \'%s\'", obj->username); + int ret; + atalk_uuid_t uuid; + ret = getuuidfromname( obj->username, UUID_USER, uuid); + if (ret != 0) { + LOG(log_info, logtype_afpd, "afp_getuserinfo: error getting UUID !"); + return AFPERR_NOITEM; + } + LOG(log_debug, logtype_afpd, "afp_getuserinfo: got UUID: %s", uuid_bin2string(uuid)); + + memcpy(rbuf, uuid, UUID_BINSIZE); + rbuf += UUID_BINSIZE; + *rbuflen += UUID_BINSIZE; } - memcpy(rbuf, uuid, UUID_BINSIZE); - rbuf += UUID_BINSIZE; - *rbuflen += UUID_BINSIZE; } -#endif /* HAVE_ACLS */ LOG(log_debug, logtype_afpd, "END afp_getuserinfo:"); return AFP_OK;