#include "acls.h"
#endif
-int afp_version = 11;
static int afp_version_index;
static struct uam_mod uam_modules = {NULL, NULL, &uam_modules, &uam_modules};
static struct uam_obj uam_login = {"", "", 0, {{NULL, NULL, NULL, NULL }}, &uam_login,
return( AFPERR_NOOP );
}
-static int set_auth_switch(int expired)
+static int set_auth_switch(const AFPObj *obj, int expired)
{
int i;
}
else {
afp_switch = postauth_switch;
- switch (afp_version) {
+ switch (obj->afp_version) {
case 33:
case 32:
#endif /* ADMIN_GRP */
obj->uid = geteuid();
- set_auth_switch(expired);
+ set_auth_switch(obj, expired);
/* save our euid, we need it for preexec_close */
obj->uid = geteuid();
obj->logout = logout;
+ /* pam_umask or similar might have changed our umask */
+ (void)umask(obj->options.umask);
+
+ /* Some PAM module might have reset our signal handlers and timer, so we need to reestablish them */
+ afp_over_dsi_sighandlers(obj);
+
return( AFP_OK );
}
if (dsi->flags & DSI_EXTSLEEP) {
LOG(log_note, logtype_afpd, "afp_zzz: waking up from extended sleep");
dsi->flags &= ~(DSI_SLEEPING | DSI_EXTSLEEP);
+ ipc_child_state(obj, DSI_RUNNING);
}
} else {
/* sleep request */
if (data & AFPZZZ_EXT_SLEEP) {
LOG(log_note, logtype_afpd, "afp_zzz: entering extended sleep");
dsi->flags |= DSI_EXTSLEEP;
+ ipc_child_state(obj, DSI_EXTSLEEP);
} else {
LOG(log_note, logtype_afpd, "afp_zzz: entering normal sleep");
+ ipc_child_state(obj, DSI_SLEEPING);
}
}
num = sizeof( afp_versions ) / sizeof( afp_versions[ 0 ]);
for ( i = 0; i < num; i++ ) {
if ( strncmp( ibuf, afp_versions[ i ].av_name , len ) == 0 ) {
- afp_version = afp_versions[ i ].av_number;
+ obj->afp_version = afp_versions[ i ].av_number;
afp_version_index = i;
break;
}
return AFPERR_BADVERS ;
/* FIXME Hack */
- if (afp_version >= 30 && sizeof(off_t) != 8) {
+ if (obj->afp_version >= 30 && sizeof(off_t) != 8) {
LOG(log_error, logtype_afpd, "get_version: no LARGE_FILE support recompile!" );
return AFPERR_BADVERS ;
}
DSI *dsi = (DSI *)(obj->dsi);
LOG(log_note, logtype_afpd, "AFP logout by %s", obj->username);
- of_close_all_forks();
- close_all_vol();
+ of_close_all_forks(obj);
+ close_all_vol(obj);
dsi->flags = DSI_AFP_LOGGED_OUT;
*rbuflen = 0;
return AFP_OK;
if ((len + 1) & 1) /* pad byte */
ibuf++;
- if ( afp_version < 30) {
+ if (obj->afp_version < 30) {
len = (unsigned char) *ibuf++;
if ( len > sizeof(username) - 1) {
return AFPERR_PARAM;
if ( ibuf[0] != '\0' || ibuf[1] != '\0')
return AFPERR_PARAM;
ibuf += 2;
- len = MIN(sizeof(username), strlen(obj->username));
+ len = MIN(sizeof(username) - 1, strlen(obj->username));
memcpy(username, obj->username, len);
username[ len ] = '\0';
}
(ret == AFPERR_AUTHCONT) ? "continued" :
(ret ? "failed" : "succeeded"));
if ( ret == AFP_OK )
- set_auth_switch(0);
+ set_auth_switch(obj, 0);
return ret;
}
return -1;
strlcpy(buf, list, sizeof(buf));
- if ((p = strtok(buf, ",")) == NULL)
+ if ((p = strtok(buf, ", ")) == NULL)
return -1;
strcpy(name, path);
} else {
LOG(log_info, logtype_afpd, "uam: uam not found (status=%d)", stat(name, &st));
}
- p = strtok(NULL, ",");
+ p = strtok(NULL, ", ");
}
return 0;