diff mbox

[cifs-utils] cifs: use krb5_kt_default() to determine default keytab location

Message ID 1396488119-7796-1-git-send-email-jlayton@samba.org (mailing list archive)
State New, archived
Headers show

Commit Message

Jeff Layton April 3, 2014, 1:21 a.m. UTC
...don't assume that it's in /etc/krb5.keytab.

Reported-by: Konstantin Lepikhov <klepikho@redhat.com>
Signed-off-by: Jeff Layton <jlayton@samba.org>
---
 cifs.upcall.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

Jeff Layton April 7, 2014, 6:37 p.m. UTC | #1
On Wed,  2 Apr 2014 21:21:59 -0400
Jeff Layton <jlayton@samba.org> wrote:

> ...don't assume that it's in /etc/krb5.keytab.
> 
> Reported-by: Konstantin Lepikhov <klepikho@redhat.com>
> Signed-off-by: Jeff Layton <jlayton@samba.org>
> ---
>  cifs.upcall.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/cifs.upcall.c b/cifs.upcall.c
> index cc65824d3689..e8544c2b68ad 100644
> --- a/cifs.upcall.c
> +++ b/cifs.upcall.c
> @@ -55,7 +55,6 @@
>  #define	CIFS_DEFAULT_KRB5_DIR		"/tmp"
>  #define	CIFS_DEFAULT_KRB5_USER_DIR	"/run/user/%U"
>  #define	CIFS_DEFAULT_KRB5_PREFIX	"krb5cc"
> -#define CIFS_DEFAULT_KRB5_KEYTAB	"/etc/krb5.keytab"
>  
>  #define	MAX_CCNAME_LEN			PATH_MAX + 5
>  
> @@ -205,9 +204,15 @@ init_cc_from_keytab(const char *keytab_name, const char *user)
>  		goto icfk_cleanup;
>  	}
>  
> -	ret = krb5_kt_resolve(context, keytab_name, &keytab);
> +	if (keytab_name)
> +		ret = krb5_kt_resolve(context, keytab_name, &keytab);
> +	else
> +		ret = krb5_kt_default(context, &keytab);
> +
>  	if (ret) {
> -		syslog(LOG_DEBUG, "krb5_kt_resolve: %d", (int)ret);
> +		syslog(LOG_DEBUG, "%s: %d",
> +			keytab_name ? "krb5_kt_resolve" : "krb5_kt_default",
> +			(int)ret);
>  		goto icfk_cleanup;
>  	}
>  
> @@ -841,7 +846,7 @@ int main(const int argc, char *const argv[])
>  	struct decoded_args arg;
>  	const char *oid;
>  	uid_t uid;
> -	char *keytab_name = CIFS_DEFAULT_KRB5_KEYTAB;
> +	char *keytab_name = NULL;
>  	time_t best_time = 0;
>  
>  	hostbuf[0] = '\0';


Merged...
diff mbox

Patch

diff --git a/cifs.upcall.c b/cifs.upcall.c
index cc65824d3689..e8544c2b68ad 100644
--- a/cifs.upcall.c
+++ b/cifs.upcall.c
@@ -55,7 +55,6 @@ 
 #define	CIFS_DEFAULT_KRB5_DIR		"/tmp"
 #define	CIFS_DEFAULT_KRB5_USER_DIR	"/run/user/%U"
 #define	CIFS_DEFAULT_KRB5_PREFIX	"krb5cc"
-#define CIFS_DEFAULT_KRB5_KEYTAB	"/etc/krb5.keytab"
 
 #define	MAX_CCNAME_LEN			PATH_MAX + 5
 
@@ -205,9 +204,15 @@  init_cc_from_keytab(const char *keytab_name, const char *user)
 		goto icfk_cleanup;
 	}
 
-	ret = krb5_kt_resolve(context, keytab_name, &keytab);
+	if (keytab_name)
+		ret = krb5_kt_resolve(context, keytab_name, &keytab);
+	else
+		ret = krb5_kt_default(context, &keytab);
+
 	if (ret) {
-		syslog(LOG_DEBUG, "krb5_kt_resolve: %d", (int)ret);
+		syslog(LOG_DEBUG, "%s: %d",
+			keytab_name ? "krb5_kt_resolve" : "krb5_kt_default",
+			(int)ret);
 		goto icfk_cleanup;
 	}
 
@@ -841,7 +846,7 @@  int main(const int argc, char *const argv[])
 	struct decoded_args arg;
 	const char *oid;
 	uid_t uid;
-	char *keytab_name = CIFS_DEFAULT_KRB5_KEYTAB;
+	char *keytab_name = NULL;
 	time_t best_time = 0;
 
 	hostbuf[0] = '\0';