View | Details | Raw Unified | Return to bug 937 | Differences between
and this patch

Collapse All | Expand All

(-)auth-pam.c (-4 / +4 lines)
Lines 621-627 Link Here
621
sshpam_init(Authctxt *authctxt)
621
sshpam_init(Authctxt *authctxt)
622
{
622
{
623
	extern char *__progname;
623
	extern char *__progname;
624
	const char *pam_rhost, *pam_user, *user = authctxt->user;
624
	const char *pam_rhost, *pam_user, *user = authctxt->pw->pw_name;
625
	const char **ptr_pam_user = &pam_user;
625
	const char **ptr_pam_user = &pam_user;
626
626
627
	if (sshpam_handle != NULL) {
627
	if (sshpam_handle != NULL) {
Lines 795-801 Link Here
795
			}
795
			}
796
			error("PAM: %s for %s%.100s from %.100s", msg,
796
			error("PAM: %s for %s%.100s from %.100s", msg,
797
			    sshpam_authctxt->valid ? "" : "illegal user ",
797
			    sshpam_authctxt->valid ? "" : "illegal user ",
798
			    sshpam_authctxt->user,
798
			    sshpam_authctxt->pw->pw_name,
799
			    get_remote_name_or_ip(utmp_len, options.use_dns));
799
			    get_remote_name_or_ip(utmp_len, options.use_dns));
800
			/* FALLTHROUGH */
800
			/* FALLTHROUGH */
801
		default:
801
		default:
Lines 1209-1219 Link Here
1209
	sshpam_password = NULL;
1209
	sshpam_password = NULL;
1210
	if (sshpam_err == PAM_SUCCESS && authctxt->valid) {
1210
	if (sshpam_err == PAM_SUCCESS && authctxt->valid) {
1211
		debug("PAM: password authentication accepted for %.100s",
1211
		debug("PAM: password authentication accepted for %.100s",
1212
		    authctxt->user);
1212
		    authctxt->pw->pw_name);
1213
		return 1;
1213
		return 1;
1214
	} else {
1214
	} else {
1215
		debug("PAM: password authentication failed for %.100s: %s",
1215
		debug("PAM: password authentication failed for %.100s: %s",
1216
		    authctxt->valid ? authctxt->user : "an illegal user",
1216
		    authctxt->valid ? authctxt->pw->pw_name : "an illegal user",
1217
		    pam_strerror(sshpam_handle, sshpam_err));
1217
		    pam_strerror(sshpam_handle, sshpam_err));
1218
		return 0;
1218
		return 0;
1219
	}
1219
	}
(-)auth2.c (-4 / +5 lines)
Lines 227-239 Link Here
227
	debug("userauth-request for user %s service %s method %s", user, service, method);
227
	debug("userauth-request for user %s service %s method %s", user, service, method);
228
	debug("attempt %d failures %d", authctxt->attempt, authctxt->failures);
228
	debug("attempt %d failures %d", authctxt->attempt, authctxt->failures);
229
229
230
	if (authctxt->attempt == 0) authctxt->user = xstrdup(user);
231
230
	if ((style = strchr(user, ':')) != NULL)
232
	if ((style = strchr(user, ':')) != NULL)
231
		*style++ = 0;
233
		*style++ = 0;
232
234
233
	if (authctxt->attempt++ == 0) {
235
	if (authctxt->attempt++ == 0) {
234
		/* setup auth context */
236
		/* setup auth context */
235
		authctxt->pw = PRIVSEP(getpwnamallow(user));
237
		authctxt->pw = PRIVSEP(getpwnamallow(user));
236
		authctxt->user = xstrdup(user);
237
		if (authctxt->pw && strcmp(service, "ssh-connection")==0) {
238
		if (authctxt->pw && strcmp(service, "ssh-connection")==0) {
238
			authctxt->valid = 1;
239
			authctxt->valid = 1;
239
			debug2("input_userauth_request: setting up authctxt for %s", user);
240
			debug2("input_userauth_request: setting up authctxt for %s", user);
Lines 253-265 Link Here
253
		authctxt->service = xstrdup(service);
254
		authctxt->service = xstrdup(service);
254
		authctxt->style = style ? xstrdup(style) : NULL;
255
		authctxt->style = style ? xstrdup(style) : NULL;
255
		if (use_privsep)
256
		if (use_privsep)
256
			mm_inform_authserv(service, style);
257
			mm_inform_authserv(authctxt->user, service, style);
257
		userauth_banner();
258
		userauth_banner();
258
	} else if (strcmp(user, authctxt->user) != 0 ||
259
	} else if (strcmp(user, authctxt->pw->pw_name) != 0 ||
259
	    strcmp(service, authctxt->service) != 0) {
260
	    strcmp(service, authctxt->service) != 0) {
260
		packet_disconnect("Change of username or service not allowed: "
261
		packet_disconnect("Change of username or service not allowed: "
261
		    "(%s,%s) -> (%s,%s)",
262
		    "(%s,%s) -> (%s,%s)",
262
		    authctxt->user, authctxt->service, user, service);
263
		    authctxt->pw->pw_name, authctxt->service, user, service);
263
	}
264
	}
264
	/* reset state */
265
	/* reset state */
265
	auth2_challenge_stop(authctxt);
266
	auth2_challenge_stop(authctxt);
(-)monitor.c (-4 / +3 lines)
Lines 741-747 Link Here
741
741
742
	pwent = getpwnamallow(username);
742
	pwent = getpwnamallow(username);
743
743
744
	authctxt->user = xstrdup(username);
745
	setproctitle("%s [priv]", pwent ? username : "unknown");
744
	setproctitle("%s [priv]", pwent ? username : "unknown");
746
	xfree(username);
745
	xfree(username);
747
746
Lines 823-832 Link Here
823
{
822
{
824
	monitor_permit_authentications(1);
823
	monitor_permit_authentications(1);
825
824
825
	authctxt->user = buffer_get_string(m, NULL);
826
	authctxt->service = buffer_get_string(m, NULL);
826
	authctxt->service = buffer_get_string(m, NULL);
827
	authctxt->style = buffer_get_string(m, NULL);
827
	authctxt->style = buffer_get_string(m, NULL);
828
	debug3("%s: service=%s, style=%s",
828
	debug3("%s: user=%s, service=%s, style=%s",
829
	    __func__, authctxt->service, authctxt->style);
829
	    __func__, authctxt->user, authctxt->service, authctxt->style);
830
830
831
	if (strlen(authctxt->style) == 0) {
831
	if (strlen(authctxt->style) == 0) {
832
		xfree(authctxt->style);
832
		xfree(authctxt->style);
Lines 1015-1021 Link Here
1015
{
1015
{
1016
1016
1017
	debug3("%s", __func__);
1017
	debug3("%s", __func__);
1018
	authctxt->user = buffer_get_string(m, NULL);
1019
	sshpam_ctxt = (sshpam_device.init_ctx)(authctxt);
1018
	sshpam_ctxt = (sshpam_device.init_ctx)(authctxt);
1020
	sshpam_authok = NULL;
1019
	sshpam_authok = NULL;
1021
	buffer_clear(m);
1020
	buffer_clear(m);
(-)monitor_wrap.c (-2 / +2 lines)
Lines 321-333 Link Here
321
/* Inform the privileged process about service and style */
321
/* Inform the privileged process about service and style */
322
322
323
void
323
void
324
mm_inform_authserv(char *service, char *style)
324
mm_inform_authserv(char *user, char *service, char *style)
325
{
325
{
326
	Buffer m;
326
	Buffer m;
327
327
328
	debug3("%s entering", __func__);
328
	debug3("%s entering", __func__);
329
329
330
	buffer_init(&m);
330
	buffer_init(&m);
331
	buffer_put_cstring(&m, user);
331
	buffer_put_cstring(&m, service);
332
	buffer_put_cstring(&m, service);
332
	buffer_put_cstring(&m, style ? style : "");
333
	buffer_put_cstring(&m, style ? style : "");
333
334
Lines 819-825 Link Here
819
820
820
	debug3("%s", __func__);
821
	debug3("%s", __func__);
821
	buffer_init(&m);
822
	buffer_init(&m);
822
	buffer_put_cstring(&m, authctxt->user);
823
	mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_INIT_CTX, &m);
823
	mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_INIT_CTX, &m);
824
	debug3("%s: waiting for MONITOR_ANS_PAM_INIT_CTX", __func__);
824
	debug3("%s: waiting for MONITOR_ANS_PAM_INIT_CTX", __func__);
825
	mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PAM_INIT_CTX, &m);
825
	mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PAM_INIT_CTX, &m);
(-)monitor_wrap.h (-1 / +1 lines)
Lines 41-47 Link Here
41
int mm_is_monitor(void);
41
int mm_is_monitor(void);
42
DH *mm_choose_dh(int, int, int);
42
DH *mm_choose_dh(int, int, int);
43
int mm_key_sign(Key *, u_char **, u_int *, u_char *, u_int);
43
int mm_key_sign(Key *, u_char **, u_int *, u_char *, u_int);
44
void mm_inform_authserv(char *, char *);
44
void mm_inform_authserv(char *, char *, char *);
45
struct passwd *mm_getpwnamallow(const char *);
45
struct passwd *mm_getpwnamallow(const char *);
46
char *mm_auth2_read_banner(void);
46
char *mm_auth2_read_banner(void);
47
int mm_auth_password(struct Authctxt *, char *);
47
int mm_auth_password(struct Authctxt *, char *);

Return to bug 937