Index: crypto/heimdal/appl/su/su.c diff -u crypto/heimdal/appl/su/su.c:1.1.1.3 crypto/heimdal/appl/su/su.c:1.1.1.4 --- crypto/heimdal/appl/su/su.c:1.1.1.3 Wed Jun 20 22:09:39 2001 +++ crypto/heimdal/appl/su/su.c Tue Jan 15 14:25:55 2002 @@ -138,7 +138,11 @@ #ifdef KRB5 krb5_error_code ret; krb5_principal p; + char *login_name = NULL; +#if defined(HAVE_GETLOGIN) && !defined(POSIX_GETLOGIN) + login_name = getlogin(); +#endif ret = krb5_init_context (&context); if (ret) { #if 0 @@ -147,9 +151,11 @@ return 1; } + if (login_name == NULL || strcmp (login_name, "root") == 0) + login_name = login_info->pw_name; if (strcmp (su_info->pw_name, "root") == 0) ret = krb5_make_principal(context, &p, NULL, - login_info->pw_name, + login_name, kerberos_instance, NULL); else @@ -268,7 +274,6 @@ int i, optind = 0; char *su_user; struct passwd *su_info; - char *login_user = NULL; struct passwd *login_info; struct passwd *pwd; @@ -309,10 +314,6 @@ } su_info = make_info(pwd); -#if defined(HAVE_GETLOGIN) && !defined(POSIX_GETLOGIN) - login_user = getlogin(); -#endif - if(login_user == NULL || (pwd = getpwnam(login_user)) == NULL) pwd = getpwuid(getuid()); if(pwd == NULL) errx(1, "who are you?");