#include <time.h>
#include <pwd.h>
#include <grp.h>
-#include <atalk/logger.h>
-#include <atalk/server_ipc.h>
-#include <atalk/uuid.h>
#ifdef TRU64
#include <netdb.h>
extern void afp_get_cmdline( int *ac, char ***av );
#endif /* TRU64 */
+#include <atalk/logger.h>
+#include <atalk/server_ipc.h>
+#include <atalk/uuid.h>
+
#include "globals.h"
#include "auth.h"
#include "uam_auth.h"
return AFPERR_NOTAUTH;
}
- LOG(log_note, logtype_afpd, "%2 Login by %s",
+ LOG(log_note, logtype_afpd, "%s Login by %s",
afp_versions[afp_version_index].av_name, pwd->pw_name);
#ifndef NO_DDP
token = obj->sinfo.sessiontoken;
}
break;
- case 3: /* Jaguar */
+ case 3:
case 4:
if (ibuflen >= 8 ) {
p = ibuf;
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;
}
}
/* ---------------------- */
-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;
}
}
- /* 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;
}
/* ---------------------- */
u_int8_t thisuser;
u_int32_t id;
u_int16_t bitmap;
+ char *bitmapp;
LOG(log_debug, logtype_afpd, "begin afp_getuserinfo:");
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);
*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;