aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacques Vidrine <nectar@FreeBSD.org>2002-01-17 15:45:27 +0000
committerJacques Vidrine <nectar@FreeBSD.org>2002-01-17 15:45:27 +0000
commit8bb03a578802659f226c24adfd2935a8dadc515b (patch)
treefc4eec2af1aaa540bbfde8ba60fa8416a9e4199b
parent6c34f2064ca283428d5fd35c49a9f4f36d66663a (diff)
downloadsrc-8bb03a578802659f226c24adfd2935a8dadc515b.tar.gz
src-8bb03a578802659f226c24adfd2935a8dadc515b.zip
MFC 1.1.1.4: Don't use getlogin() to determine whether we are root.
Notes
Notes: svn path=/releng/4.3/; revision=89459
-rw-r--r--crypto/heimdal/appl/su/su.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/crypto/heimdal/appl/su/su.c b/crypto/heimdal/appl/su/su.c
index a5fd44292e87..1d3a9dd74948 100644
--- a/crypto/heimdal/appl/su/su.c
+++ b/crypto/heimdal/appl/su/su.c
@@ -134,7 +134,11 @@ krb5_verify(struct passwd *login_info, struct passwd *su_info,
#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
@@ -143,9 +147,11 @@ krb5_verify(struct passwd *login_info, struct passwd *su_info,
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
@@ -264,7 +270,6 @@ main(int argc, char **argv)
int i, optind = 0;
char *su_user;
struct passwd *su_info;
- char *login_user = NULL;
struct passwd *login_info;
struct passwd *pwd;
@@ -305,10 +310,6 @@ main(int argc, char **argv)
}
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?");