jonathancammack / rpms / openssh

Forked from rpms/openssh 8 months ago
Clone

Blame SOURCES/openssh-6.6p1-k5login_directory.patch

8f2528
diff --git a/auth-krb5.c b/auth-krb5.c
8f2528
index 2b02a04..19b9364 100644
8f2528
--- a/auth-krb5.c
8f2528
+++ b/auth-krb5.c
8f2528
@@ -375,6 +375,22 @@ cleanup:
8f2528
 	return -1;
8f2528
 }
8f2528
 
8f2528
+/*
8f2528
+ * Reads  k5login_directory  option from the  krb5.conf
8f2528
+ */
8f2528
+krb5_error_code
8f2528
+ssh_krb5_get_k5login_directory(krb5_context ctx, char **k5login_directory) {
8f2528
+	profile_t p;
8f2528
+	int ret = 0;
8f2528
+
8f2528
+	ret = krb5_get_profile(ctx, &p);
8f2528
+	if (ret)
8f2528
+		return ret;
8f2528
+
8f2528
+	return profile_get_string(p, "libdefaults", "k5login_directory", NULL, NULL,
8f2528
+		k5login_directory);
8f2528
+}
8f2528
+
8f2528
 krb5_error_code
8f2528
 ssh_krb5_get_cctemplate(krb5_context ctx, char **ccname) {
8f2528
 	profile_t p;
8f2528
diff --git a/auth.h b/auth.h
8f2528
index f9d191c..c432d2f 100644
8f2528
--- a/auth.h
8f2528
+++ b/auth.h
8f2528
@@ -222,5 +222,7 @@ int	 sys_auth_passwd(Authctxt *, const char *);
8f2528
 #if defined(KRB5) && !defined(HEIMDAL)
8f2528
 #include <krb5.h>
8f2528
 krb5_error_code ssh_krb5_cc_gen(krb5_context, krb5_ccache *);
8f2528
+krb5_error_code ssh_krb5_get_k5login_directory(krb5_context ctx,
8f2528
+	char **k5login_directory);
8f2528
 #endif
8f2528
 #endif
8f2528
diff --git a/gss-serv-krb5.c b/gss-serv-krb5.c
8f2528
index a7c0c5f..df8cc9a 100644
8f2528
--- a/gss-serv-krb5.c
8f2528
+++ b/gss-serv-krb5.c
8f2528
@@ -244,8 +244,27 @@ ssh_gssapi_k5login_exists()
8f2528
 {
8f2528
 	char file[MAXPATHLEN];
8f2528
 	struct passwd *pw = the_authctxt->pw;
8f2528
+	char *k5login_directory = NULL;
8f2528
+	int ret = 0;
8f2528
+
8f2528
+	ret = ssh_krb5_get_k5login_directory(krb_context, &k5login_directory);
8f2528
+	debug3("%s: k5login_directory = %s (rv=%d)", __func__, k5login_directory, ret);
8f2528
+	if (k5login_directory == NULL || ret != 0) {
8f2528
+		/* If not set, the library will look for  k5login
8f2528
+		 * files in the user's home directory, with the filename  .k5login.
8f2528
+		 */
8f2528
+		snprintf(file, sizeof(file), "%s/.k5login", pw->pw_dir);
8f2528
+	} else {
8f2528
+		/* If set, the library will look for a local user's k5login file
8f2528
+		 * within the named directory, with a filename corresponding to the
8f2528
+		 * local username.
8f2528
+		 */
8f2528
+		snprintf(file, sizeof(file), "%s%s%s", k5login_directory, 
8f2528
+			k5login_directory[strlen(k5login_directory)-1] != '/' ? "/" : "",
8f2528
+			pw->pw_name);
8f2528
+	}
8f2528
+	debug("%s: Checking existence of file %s", __func__, file);
8f2528
 
8f2528
-	snprintf(file, sizeof(file), "%s/.k5login", pw->pw_dir);
8f2528
 	return access(file, F_OK) == 0;
8f2528
 }
8f2528
 
8f2528
diff --git a/sshd.8 b/sshd.8
8f2528
index 5c4f15b..135e290 100644
8f2528
--- a/sshd.8
8f2528
+++ b/sshd.8
8f2528
@@ -806,6 +806,10 @@ rlogin/rsh.
8f2528
 These files enforce GSSAPI/Kerberos authentication access control.
8f2528
 Further details are described in
8f2528
 .Xr ksu 1 .
8f2528
+The location of the k5login file depends on the configuration option
8f2528
+.Cm k5login_directory
8f2528
+in the
8f2528
+.Xr krb5.conf 5 .
8f2528
 .Pp
8f2528
 .It Pa ~/.ssh/
8f2528
 This directory is the default location for all user-specific configuration