components/openssh/patches/025-login_to_a_role.patch
author Tomas Kuthan <tomas.kuthan@oracle.com>
Wed, 15 Apr 2015 10:04:13 -0700
changeset 4130 b2f7921b1d1c
child 4503 bf30d46ab06e
permissions -rw-r--r--
20711463 OpenSSH wants to be able to login to a role too
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4130
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     1
#
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     2
# Enable login to a role for hostbased authentication if allowed by PAM.
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     3
#
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     4
# Sets PAM_AUSER item to user who is asserting a new identity before
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     5
# calling do_pam_account(). Implemented using existing static variable
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     6
# hostbased_cuser. The change is protected by new HAVE_PAM_AUSER ifdef-guard,
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     7
# which is set to defined on Solaris.
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     8
#
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     9
# Patch offered upstream:
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    10
#     https://bugzilla.mindrot.org/show_bug.cgi?id=2378
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    11
#
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    12
diff -pur old/auth-pam.c new/auth-pam.c
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    13
--- old/auth-pam.c	2015-04-13 07:40:15.102801416 -0700
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    14
+++ new/auth-pam.c	2015-04-13 07:40:15.170507123 -0700
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    15
@@ -1038,6 +1038,20 @@ do_pam_account(void)
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    16
 	return (sshpam_account_status);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    17
 }
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    18
 
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    19
+#ifdef HAVE_PAM_AUSER
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    20
+void
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    21
+do_pam_set_auser(const char* auser)
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    22
+{
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    23
+	if (auser != NULL) {
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    24
+		debug("PAM: setting PAM_AUSER to \"%s\"", auser);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    25
+		sshpam_err = pam_set_item(sshpam_handle, PAM_AUSER, auser);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    26
+		if (sshpam_err != PAM_SUCCESS)
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    27
+			error("PAM: failed to set PAM_AUSER: %s",
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    28
+			    pam_strerror(sshpam_handle, sshpam_err));
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    29
+	}
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    30
+}
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    31
+#endif
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    32
+
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    33
 void
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    34
 do_pam_set_tty(const char *tty)
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    35
 {
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    36
diff -pur old/auth-pam.h new/auth-pam.h
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    37
--- old/auth-pam.h	2004-09-11 05:17:26.000000000 -0700
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    38
+++ new/auth-pam.h	2015-04-13 07:40:15.170675124 -0700
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    39
@@ -35,6 +35,9 @@ void start_pam(Authctxt *);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    40
 void finish_pam(void);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    41
 u_int do_pam_account(void);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    42
 void do_pam_session(void);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    43
+#ifdef HAVE_PAM_AUSER
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    44
+void do_pam_set_auser(const char *);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    45
+#endif
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    46
 void do_pam_set_tty(const char *);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    47
 void do_pam_setcred(int );
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    48
 void do_pam_chauthtok(void);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    49
diff -pur old/auth.h new/auth.h
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    50
--- old/auth.h	2015-04-13 07:40:15.102912510 -0700
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    51
+++ new/auth.h	2015-04-13 07:40:15.170773363 -0700
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    52
@@ -79,6 +79,9 @@ struct Authctxt {
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    53
 #ifdef PAM_ENHANCEMENT
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    54
         char            *authmethod_name;
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    55
 #endif 
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    56
+#ifdef HAVE_PAM_AUSER
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    57
+	char		*auser;
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    58
+#endif 
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    59
 };
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    60
 /*
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    61
  * Every authentication method has to handle authentication requests for
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    62
diff -pur old/auth2-hostbased.c new/auth2-hostbased.c
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    63
--- old/auth2-hostbased.c	2013-12-30 17:25:41.000000000 -0800
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    64
+++ new/auth2-hostbased.c	2015-04-13 07:40:15.170883166 -0700
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    65
@@ -83,6 +83,9 @@ userauth_hostbased(Authctxt *authctxt)
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    66
 	buffer_dump(&b);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    67
 	buffer_free(&b);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    68
 #endif
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    69
+#ifdef HAVE_PAM_AUSER
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    70
+	authctxt->auser = NULL;
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    71
+#endif
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    72
 	pktype = key_type_from_name(pkalg);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    73
 	if (pktype == KEY_UNSPEC) {
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    74
 		/* this is perfectly legal */
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    75
@@ -133,6 +136,13 @@ userauth_hostbased(Authctxt *authctxt)
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    76
 			buffer_len(&b))) == 1)
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    77
 		authenticated = 1;
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    78
 
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    79
+#ifdef HAVE_PAM_AUSER
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    80
+	if (authenticated) {
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    81
+		authctxt->auser = cuser;
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    82
+		cuser = NULL;
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    83
+	}
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    84
+#endif
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    85
+
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    86
 	buffer_free(&b);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    87
 done:
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    88
 	debug2("userauth_hostbased: authenticated %d", authenticated);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    89
diff -pur old/auth2.c new/auth2.c
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    90
--- old/auth2.c	2015-04-13 07:40:15.125748357 -0700
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    91
+++ new/auth2.c	2015-04-13 07:54:08.589929143 -0700
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    92
@@ -347,6 +347,14 @@ userauth_finish(Authctxt *authctxt, int
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    93
 #endif
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    94
 	}
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    95
 
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    96
+#ifdef HAVE_PAM_AUSER
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    97
+	if (!use_privsep) {
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    98
+		do_pam_set_auser(authctxt->auser);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    99
+		free(authctxt->auser);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   100
+		authctxt->auser = NULL;	
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   101
+	}
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   102
+#endif
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   103
+
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   104
 	if (authenticated && options.num_auth_methods != 0) {
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   105
 
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   106
 #if defined(USE_PAM) && defined(PAM_ENHANCEMENT)
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   107
diff -pur old/config.h.in new/config.h.in
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   108
--- old/config.h.in	2015-04-13 07:40:15.118922540 -0700
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   109
+++ new/config.h.in	2015-04-13 07:40:15.171493102 -0700
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   110
@@ -814,6 +814,9 @@
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   111
 /* Define if you have Digital Unix Security Integration Architecture */
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   112
 #undef HAVE_OSF_SIA
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   113
 
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   114
+/* Define if you have PAM_AUSER PAM item */
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   115
+#undef HAVE_PAM_AUSER
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   116
+
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   117
 /* Define to 1 if you have the `pam_getenvlist' function. */
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   118
 #undef HAVE_PAM_GETENVLIST
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   119
 
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   120
diff -pur old/configure new/configure
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   121
--- old/configure	2015-04-13 07:40:15.121667931 -0700
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   122
+++ new/configure	2015-04-13 07:40:15.174438856 -0700
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   123
@@ -7799,6 +7799,7 @@ fi
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   124
 
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   125
         $as_echo "#define USE_GSS_STORE_CRED 1" >>confdefs.h
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   126
         $as_echo "#define GSSAPI_STORECREDS_NEEDS_RUID 1" >>confdefs.h
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   127
+        $as_echo "#define HAVE_PAM_AUSER 1" >>confdefs.h
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   128
 
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   129
 	TEST_SHELL=$SHELL	# let configure find us a capable shell
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   130
 	;;
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   131
diff -pur old/configure.ac new/configure.ac
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   132
--- old/configure.ac	2015-04-13 07:40:15.085660430 -0700
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   133
+++ new/configure.ac	2015-04-13 07:40:15.175130655 -0700
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   134
@@ -868,6 +868,7 @@ mips-sony-bsd|mips-sony-newsos4)
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   135
 	TEST_SHELL=$SHELL	# let configure find us a capable shell
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   136
         AC_DEFINE([USE_GSS_STORE_CRED])
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   137
         AC_DEFINE([GSSAPI_STORECREDS_NEEDS_RUID])
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   138
+        AC_DEFINE([HAVE_PAM_AUSER])
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   139
 	;;
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   140
 *-*-sunos4*)
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   141
 	CPPFLAGS="$CPPFLAGS -DSUNOS4"
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   142
diff -pur old/monitor.c new/monitor.c
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   143
--- old/monitor.c	2015-04-13 07:40:15.136922050 -0700
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   144
+++ new/monitor.c	2015-04-13 07:40:15.175533060 -0700
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   145
@@ -490,6 +490,12 @@ monitor_child_preauth(Authctxt *_authctx
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   146
 #endif
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   147
 	}
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   148
 
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   149
+#if defined(HAVE_PAM_AUSER) && defined(USE_PAM)
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   150
+	if (hostbased_cuser != NULL) {
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   151
+		free(hostbased_cuser);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   152
+		hostbased_cuser = NULL;
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   153
+	}
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   154
+#endif
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   155
 	if (!authctxt->valid)
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   156
 		fatal("%s: authenticated invalid user", __func__);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   157
 	if (strcmp(auth_method, "unknown") == 0)
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   158
@@ -699,12 +705,14 @@ monitor_reset_key_state(void)
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   159
 {
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   160
 	/* reset state */
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   161
 	free(key_blob);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   162
+#if !defined(HAVE_PAM_AUSER) || !defined(USE_PAM)
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   163
 	free(hostbased_cuser);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   164
+	hostbased_cuser = NULL;
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   165
+#endif
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   166
 	free(hostbased_chost);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   167
 	key_blob = NULL;
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   168
 	key_bloblen = 0;
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   169
 	key_blobtype = MM_NOKEY;
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   170
-	hostbased_cuser = NULL;
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   171
 	hostbased_chost = NULL;
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   172
 }
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   173
 
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   174
@@ -1111,6 +1119,11 @@ mm_answer_pam_account(int sock, Buffer *
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   175
 	if (!options.use_pam)
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   176
 		fatal("UsePAM not set, but ended up in %s anyway", __func__);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   177
 
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   178
+#ifdef HAVE_PAM_AUSER
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   179
+	if (hostbased_cuser != NULL)
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   180
+		do_pam_set_auser(hostbased_cuser);
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   181
+#endif
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   182
+
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   183
 	ret = do_pam_account();
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   184
 
b2f7921b1d1c 20711463 OpenSSH wants to be able to login to a role too
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   185
 	buffer_put_int(m, ret);