From 3344b15a67c3a0d99e637eb0ed2621fea3633dba Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Sun, 7 Feb 2010 07:43:20 -0500 Subject: cifs.upcall: don't use smb_krb5_unparse_name ...we don't really need a talloc-ified version here. Just use the normal one. Also don't use strnequal. Use strncasecmp instead. Signed-off-by: Jeff Layton --- cifs.upcall.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'cifs.upcall.c') diff --git a/cifs.upcall.c b/cifs.upcall.c index e956d99..6ca708a 100644 --- a/cifs.upcall.c +++ b/cifs.upcall.c @@ -38,6 +38,13 @@ create dns_resolver * * /usr/local/sbin/cifs.upcall %k #define MAX_CCNAME_LEN PATH_MAX + 5 +/* + * samba forces the build to fail if strncasecmp is used, disable that for now + */ +#ifdef strncasecmp +#undef strncasecmp +#endif + const char *CIFSSPNEGO_VERSION = "1.3"; static const char *prog = "cifs.upcall"; typedef enum _sectype { @@ -71,6 +78,13 @@ static char *cifs_krb5_principal_get_realm(krb5_context context, #endif } +#if !defined(HAVE_KRB5_FREE_UNPARSED_NAME) +void krb5_free_unparsed_name(krb5_context context, char *val) +{ + SAFE_FREE(val); +} +#endif + /* does the ccache have a valid TGT? */ static time_t get_tgt_time(const char *ccname) { @@ -114,17 +128,17 @@ get_tgt_time(const char *ccname) { while (!credtime && !krb5_cc_next_cred(context, ccache, &cur, &creds)) { char *name; - if (smb_krb5_unparse_name(NULL, context, creds.server, &name)) { + if (krb5_unparse_name(context, creds.server, &name)) { syslog(LOG_DEBUG, "%s: unable to unparse name", __func__); goto err_endseq; } if (krb5_realm_compare(context, creds.server, principal) && - strnequal(name, KRB5_TGS_NAME, KRB5_TGS_NAME_SIZE) && - strnequal(name+KRB5_TGS_NAME_SIZE+1, realm, strlen(realm)) && + !strncasecmp(name, KRB5_TGS_NAME, KRB5_TGS_NAME_SIZE) && + !strncasecmp(name+KRB5_TGS_NAME_SIZE+1, realm, strlen(realm)) && creds.times.endtime > time(NULL)) credtime = creds.times.endtime; krb5_free_cred_contents(context, &creds); - TALLOC_FREE(name); + krb5_free_unparsed_name(context, name); } err_endseq: krb5_cc_end_seq_get(context, ccache, &cur); -- cgit v1.2.3