summaryrefslogtreecommitdiff
path: root/usr.bin/su
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2000-09-15 07:13:52 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2000-09-15 07:13:52 +0000
commit42a3e69c05af72afbc1d37574fba7729b828289b (patch)
treebecf08be7a11e201542de4de93b8cd0f8650f9e1 /usr.bin/su
parentb74ef7bac5077f29fc1c12e8b5ccaf0e2f1f8fdc (diff)
check return value for setenv(3) for failure, and deal appropriately
Diffstat (limited to 'usr.bin/su')
-rw-r--r--usr.bin/su/su.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/usr.bin/su/su.c b/usr.bin/su/su.c
index 63fa5a7ebba..0a0f67e7604 100644
--- a/usr.bin/su/su.c
+++ b/usr.bin/su/su.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: su.c,v 1.33 2000/08/20 18:42:41 millert Exp $ */
+/* $OpenBSD: su.c,v 1.34 2000/09/15 07:13:50 deraadt Exp $ */
/*
* Copyright (c) 1988 The Regents of the University of California.
@@ -41,7 +41,7 @@ char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)su.c 5.26 (Berkeley) 7/6/91";*/
-static char rcsid[] = "$OpenBSD: su.c,v 1.33 2000/08/20 18:42:41 millert Exp $";
+static char rcsid[] = "$OpenBSD: su.c,v 1.34 2000/09/15 07:13:50 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -253,8 +253,10 @@ badlogin:
errx(1, "calloc");
if (setusercontext(lc, pwd, pwd->pw_uid, LOGIN_SETPATH))
err(1, "unable to set user context");
- if (p)
- (void)setenv("TERM", p, 1);
+ if (p) {
+ if (setenv("TERM", p, 1) == -1)
+ err(1, "unable to set environment");
+ }
seteuid(pwd->pw_uid);
setegid(pwd->pw_gid);
@@ -269,16 +271,20 @@ badlogin:
err(1, "unable to set user context");
}
if (asthem || pwd->pw_uid) {
- (void)setenv("LOGNAME", pwd->pw_name, 1);
- (void)setenv("USER", pwd->pw_name, 1);
+ if (setenv("LOGNAME", pwd->pw_name, 1) == -1 ||
+ setenv("USER", pwd->pw_name, 1) == -1)
+ err(1, "unable to set environment");
}
- (void)setenv("HOME", pwd->pw_dir, 1);
- (void)setenv("SHELL", shell, 1);
+ if (setenv("HOME", pwd->pw_dir, 1) == -1 ||
+ setenv("SHELL", shell, 1) == -1)
+ err(1, "unable to set environment");
}
#ifdef KERBEROS
- if (*krbtkfile)
- (void)setenv("KRBTKFILE", krbtkfile, 1);
+ if (*krbtkfile) {
+ if (setenv("KRBTKFILE", krbtkfile, 1) == -1)
+ err(1, "unable to set environment");
+ }
#endif
if (iscsh == YES) {