diff --git a/src/aklog/aklog.c b/src/aklog/aklog.c index 127cf65dd0..2104bc58b7 100644 --- a/src/aklog/aklog.c +++ b/src/aklog/aklog.c @@ -1520,19 +1520,15 @@ main(int argc, char *argv[]) #if defined(KRB5_PROG_ETYPE_NOSUPP) && !(defined(HAVE_KRB5_ENCTYPE_ENABLE) || defined(HAVE_KRB5_ALLOW_WEAK_CRYPTO)) { char *filepath = NULL, *newpath = NULL; - filepath = getenv("KRB5_CONFIG"); - if (!filepath) { - int slen; #ifndef AFS_DARWIN_ENV - slen = strlen(filepath)+strlen(":/etc/krb5.conf")+1; - newpath = malloc(slen); - snprintf(newpath, slen, "%s:/etc/krb5.conf", filepath); + char *defaultpath = "/etc/krb5.conf"; #else - slen = strlen("~/Library/Preferences/edu.mit.Kerberos:/Library/Preferences/edu.mit.Kerberos:")+strlen(AFSDIR_CLIENT_ETC_DIRPATH)+strlen("/krb5-weak.conf")+1; - newpath = malloc(slen); - snprintf(newpath, slen, "~/Library/Preferences/edu.mit.Kerberos:/Library/Preferences/edu.mit.Kerberos:%s/krb5-weak.conf", AFSDIR_CLIENT_ETC_DIRPATH); + char *defaultpath = "~/Library/Preferences/edu.mit.Kerberos:/Library/Preferences/edu.mit.Kerberos"; #endif - } + filepath = getenv("KRB5_CONFIG"); + afs_asprintf(&newpath, "%s:%s/krb5-weak.conf", + filepath ? filepath : defaultpath, + AFSDIR_CLIENT_ETC_DIRPATH); setenv("KRB5_CONFIG", newpath, 1); #endif krb5_init_context(&context);