summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-04-12 07:18:58 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-04-12 07:18:58 +0000
commit1104d3a3fd6f41ac54e4e3bd05cbcc31edf1eef9 (patch)
tree35835eb9ecbbe047daee6b1dbc64030f275e2f7f /gnu
parent3e69f20c4cb350dfe7f8611b5a6ff069cf3e6b5c (diff)
Fixed coredump when passwd file is missing or unavailable.
Reported by Jason Downs <downsj@teeny.org> and Klee Dienes <klee@mit.edu> (via a Debian Linux bug report).
Diffstat (limited to 'gnu')
-rw-r--r--gnu/usr.bin/sudo/sudo/sudo.c11
-rw-r--r--gnu/usr.bin/sudo/visudo/visudo.c9
2 files changed, 13 insertions, 7 deletions
diff --git a/gnu/usr.bin/sudo/sudo/sudo.c b/gnu/usr.bin/sudo/sudo/sudo.c
index c735f8c116c..c1615a47469 100644
--- a/gnu/usr.bin/sudo/sudo/sudo.c
+++ b/gnu/usr.bin/sudo/sudo/sudo.c
@@ -51,7 +51,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: sudo.c,v 1.2 1996/11/17 16:34:04 millert Exp $";
+static char rcsid[] = "$Id: sudo.c,v 1.3 1997/04/12 07:18:56 millert Exp $";
#endif /* lint */
#define MAIN
@@ -405,10 +405,7 @@ static void load_globals(sudo_mode)
* if necesary. It is assumed that euid is 0 at this point so we
* can read the shadow passwd file if necesary.
*/
- user_pw_ent = sudo_getpwuid(getuid());
- set_perms(PERM_ROOT, sudo_mode);
- set_perms(PERM_USER, sudo_mode);
- if (user_pw_ent == NULL) {
+ if ((user_pw_ent = sudo_getpwuid(getuid())) == NULL) {
/* need to make a fake user_pw_ent */
struct passwd pw_ent;
char pw_name[MAX_UID_T_LEN+1];
@@ -425,6 +422,10 @@ static void load_globals(sudo_mode)
exit(1);
}
+ /* Set euid == user and ruid == root */
+ set_perms(PERM_ROOT, sudo_mode);
+ set_perms(PERM_USER, sudo_mode);
+
#ifdef HAVE_TZSET
(void) tzset(); /* set the timezone if applicable */
#endif /* HAVE_TZSET */
diff --git a/gnu/usr.bin/sudo/visudo/visudo.c b/gnu/usr.bin/sudo/visudo/visudo.c
index 45d446172e2..f977b314977 100644
--- a/gnu/usr.bin/sudo/visudo/visudo.c
+++ b/gnu/usr.bin/sudo/visudo/visudo.c
@@ -26,7 +26,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: visudo.c,v 1.3 1996/11/17 16:34:08 millert Exp $";
+static char rcsid[] = "$Id: visudo.c,v 1.4 1997/04/12 07:18:57 millert Exp $";
#endif /* lint */
#include "config.h"
@@ -156,7 +156,12 @@ int main(argc, argv)
usage();
/* user_pw_ent needs to point to something... */
- user_pw_ent = getpwuid(getuid());
+ if ((user_pw_ent = getpwuid(getuid())) == NULL) {
+ (void) fprintf(stderr, "%s: Can't find you in the passwd database: ",
+ Argv[0]);
+ perror(stmp);
+ exit(1);
+ }
#ifdef ENV_EDITOR
/*