summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnu/usr.bin/sudo/sudo/Makefile4
-rw-r--r--gnu/usr.bin/sudo/sudo/alloc.c119
-rw-r--r--gnu/usr.bin/sudo/sudo/check.c150
-rw-r--r--gnu/usr.bin/sudo/sudo/compat.h6
-rw-r--r--gnu/usr.bin/sudo/sudo/config.h19
-rw-r--r--gnu/usr.bin/sudo/sudo/find_path.c22
-rw-r--r--gnu/usr.bin/sudo/sudo/getspwuid.c47
-rw-r--r--gnu/usr.bin/sudo/sudo/goodpath.c8
-rw-r--r--gnu/usr.bin/sudo/sudo/ins_2001.h6
-rw-r--r--gnu/usr.bin/sudo/sudo/ins_classic.h6
-rw-r--r--gnu/usr.bin/sudo/sudo/ins_csops.h6
-rw-r--r--gnu/usr.bin/sudo/sudo/ins_goons.h6
-rw-r--r--gnu/usr.bin/sudo/sudo/insults.h6
-rw-r--r--gnu/usr.bin/sudo/sudo/interfaces.c40
-rw-r--r--gnu/usr.bin/sudo/sudo/logging.c16
-rw-r--r--gnu/usr.bin/sudo/sudo/parse.c15
-rw-r--r--gnu/usr.bin/sudo/sudo/parse.lex14
-rw-r--r--gnu/usr.bin/sudo/sudo/parse.yacc102
-rw-r--r--gnu/usr.bin/sudo/sudo/pathnames.h6
-rw-r--r--gnu/usr.bin/sudo/sudo/sudo.84
-rw-r--r--gnu/usr.bin/sudo/sudo/sudo.c49
-rw-r--r--gnu/usr.bin/sudo/sudo/sudo.h12
-rw-r--r--gnu/usr.bin/sudo/sudo/sudo_setenv.c8
-rw-r--r--gnu/usr.bin/sudo/sudo/sudoers.54
-rw-r--r--gnu/usr.bin/sudo/sudo/tgetpass.c6
-rw-r--r--gnu/usr.bin/sudo/sudo/version.h8
-rw-r--r--gnu/usr.bin/sudo/visudo/Makefile5
-rw-r--r--gnu/usr.bin/sudo/visudo/visudo.84
-rw-r--r--gnu/usr.bin/sudo/visudo/visudo.c8
29 files changed, 379 insertions, 327 deletions
diff --git a/gnu/usr.bin/sudo/sudo/Makefile b/gnu/usr.bin/sudo/sudo/Makefile
index dbb94bbe8b7..225a0c64da1 100644
--- a/gnu/usr.bin/sudo/sudo/Makefile
+++ b/gnu/usr.bin/sudo/sudo/Makefile
@@ -1,9 +1,9 @@
-# $OpenBSD: Makefile,v 1.5 1998/09/15 02:42:43 millert Exp $
+# $OpenBSD: Makefile,v 1.6 1999/03/29 20:29:00 millert Exp $
PROG= sudo
MAN= sudo.8 sudoers.5
CFLAGS+=-I${.CURDIR} -I.
-SRCS= check.c find_path.c getspwuid.c goodpath.c interfaces.c logging.c parse.c sudo.c sudo_setenv.c tgetpass.c sudo.tab.c lex.yy.c
+SRCS= check.c find_path.c getspwuid.c goodpath.c interfaces.c logging.c parse.c sudo.c sudo_setenv.c tgetpass.c sudo.tab.c lex.yy.c alloc.c
CLEANFILES+=sudo.tab.c sudo.tab.h lex.yy.c
LDADD= -lcompat
diff --git a/gnu/usr.bin/sudo/sudo/alloc.c b/gnu/usr.bin/sudo/sudo/alloc.c
new file mode 100644
index 00000000000..09de3570caf
--- /dev/null
+++ b/gnu/usr.bin/sudo/sudo/alloc.c
@@ -0,0 +1,119 @@
+/* $OpenBSD: alloc.c,v 1.1 1999/03/29 20:29:01 millert Exp $ */
+
+/*
+ * CU sudo version 1.5.9
+ * Copyright (c) 1999 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 1, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Please send bugs, changes, problems to sudo-bugs@courtesan.com
+ *
+ *******************************************************************
+ *
+ * This module contains memory allocation routines used by sudo.
+ *
+ * Todd C. Miller <Todd.Miller@courtesan.com> Fri Jun 3 18:32:19 MDT 1994
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif /* STDC_HEADERS */
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif /* HAVE_STRING_H */
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif /* HAVE_STRINGS_H */
+#if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
+#include <malloc.h>
+#endif /* HAVE_MALLOC_H && !STDC_HEADERS */
+
+#include "compat.h"
+
+#ifndef STDC_HEADERS
+#ifndef __GNUC__ / *gcc has its own malloc */
+extern VOID *malloc __P((size_t));
+#endif /* __GNUC__ */
+extern char *strdup __P((const char *));
+#endif /* !STDC_HEADERS */
+
+extern char **Argv; /* from sudo.c */
+
+#ifndef lint
+static const char rcsid[] = "$Sudo: alloc.c,v 1.2 1999/03/29 04:05:05 millert Exp $";
+#endif /* lint */
+
+
+/**********************************************************************
+ *
+ * emalloc()
+ *
+ * emalloc() calls the system malloc(3) and exits with an error if
+ * malloc(3) fails.
+ */
+
+VOID *emalloc(size)
+ size_t size;
+{
+ VOID *ret;
+
+ if ((ret = malloc(size)) == NULL) {
+ (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
+ exit(1);
+ }
+ return(ret);
+}
+
+/**********************************************************************
+ *
+ * erealloc()
+ *
+ * erealloc() calls the system realloc(3) and exits with an error if
+ * realloc(3) fails.
+ */
+
+VOID *erealloc(ptr, size)
+ VOID *ptr;
+ size_t size;
+{
+
+ if ((ptr = ptr ? realloc(ptr, size) : malloc(size)) == NULL) {
+ (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
+ exit(1);
+ }
+ return(ptr);
+}
+
+/**********************************************************************
+ *
+ * estrdup()
+ *
+ * estrdup() calls the system strdup(3) and exits with an error if
+ * strdup(3) fails. NOTE: unlike strdup(3), estrdup(NULL) is legal.
+ */
+
+char *estrdup(str)
+ char *str;
+{
+
+ if (str != NULL && (str = (char *)strdup(str)) == NULL) {
+ (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
+ exit(1);
+ }
+ return(str);
+}
diff --git a/gnu/usr.bin/sudo/sudo/check.c b/gnu/usr.bin/sudo/sudo/check.c
index aa154058050..85cb409976e 100644
--- a/gnu/usr.bin/sudo/sudo/check.c
+++ b/gnu/usr.bin/sudo/sudo/check.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: check.c,v 1.14 1999/02/19 04:32:49 millert Exp $ */
+/* $OpenBSD: check.c,v 1.15 1999/03/29 20:29:02 millert Exp $ */
/*
- * CU sudo version 1.5.8 (based on Root Group sudo version 1.1)
+ * CU sudo version 1.5.9 (based on Root Group sudo version 1.1)
* Copyright (c) 1994,1996,1998,1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This software comes with no waranty whatsoever, use at your own risk.
@@ -70,7 +70,6 @@
#endif /* HAVE_KERB5 */
#ifdef HAVE_PAM
# include <security/pam_appl.h>
-# include <security/pam_misc.h>
#endif /* HAVE_PAM */
#ifdef HAVE_AFS
# include <afs/stds.h>
@@ -103,7 +102,7 @@
#include "version.h"
#ifndef lint
-static const char rcsid[] = "$Sudo: check.c,v 1.170 1999/02/07 00:43:24 millert Exp $";
+static const char rcsid[] = "$Sudo: check.c,v 1.174 1999/03/29 04:05:05 millert Exp $";
#endif /* lint */
/*
@@ -124,6 +123,10 @@ static int verify_krb_v5_tgt __P((krb5_ccache));
#endif /* HAVE_KERB5 */
#ifdef HAVE_PAM
static void pam_attempt_auth __P((void));
+static int pam_auth __P((char *, char *));
+static int PAM_conv __P((int,
+ PAM_CONST struct pam_message **,
+ struct pam_response **, void *));
#endif /* HAVE_PAM */
#ifdef HAVE_SKEY
static char *sudo_skeyprompt __P((struct skey *, char *));
@@ -817,11 +820,7 @@ static int sudo_krb5_validate_user(pw, pass)
return -1;
krb5_get_init_creds_opt_init(&opts);
- princ_name = malloc(strlen(pw->pw_name) + strlen(realm) + 2);
- if (!princ_name) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ princ_name = emalloc(strlen(pw->pw_name) + strlen(realm) + 2);
sprintf(princ_name, "%s@%s", pw->pw_name, realm);
if (retval = krb5_parse_name(sudo_context, princ_name, &princ))
@@ -940,44 +939,110 @@ cleanup:
*
* Try to authenticate the user using Pluggable Authentication
* Modules (PAM). Added 9/11/98 by Gary J. Calvin
+ * Reworked for stock PAM by Amos Elberg and Todd Miller
*/
+static char *PAM_username;
+static char *PAM_password;
+
+static int PAM_conv(num_msg, msg, resp, appdata_ptr)
+ int num_msg;
+ PAM_CONST struct pam_message **msg;
+ struct pam_response **resp;
+ void *appdata_ptr;
+{
+ int replies = 0;
+ struct pam_response *reply = NULL;
+
+ if ((reply = malloc(sizeof(struct pam_response) * num_msg)) == NULL)
+ return(PAM_CONV_ERR);
+
+ for (replies = 0; replies < num_msg; replies++) {
+ switch (msg[replies]->msg_style) {
+ case PAM_PROMPT_ECHO_ON:
+ reply[replies].resp_retcode = PAM_SUCCESS;
+ reply[replies].resp = estrdup(PAM_username);
+ /* PAM frees resp */
+ break;
+ case PAM_PROMPT_ECHO_OFF:
+ reply[replies].resp_retcode = PAM_SUCCESS;
+ reply[replies].resp = estrdup(PAM_password);
+ /* PAM frees resp */
+ break;
+ case PAM_TEXT_INFO:
+ /* fall through */
+ case PAM_ERROR_MSG:
+ /* ignore it... */
+ reply[replies].resp_retcode = PAM_SUCCESS;
+ reply[replies].resp = NULL;
+ break;
+ default:
+ /* Must be an error of some sort... */
+ free(reply);
+ return(PAM_CONV_ERR);
+ }
+ }
+ if (reply)
+ *resp = reply;
+
+ return(PAM_SUCCESS);
+}
+
+static int pam_auth(user, password)
+ char *user;
+ char *password;
+{
+ struct pam_conv PAM_conversation;
+ pam_handle_t *pamh;
+
+ /* Initialize our variables for PAM */
+ PAM_conversation.conv = PAM_conv;
+ PAM_conversation.appdata_ptr = NULL;
+ PAM_password = password;
+ PAM_username = user;
+
+ /*
+ * Setting PAM_SILENT stops generation of error messages to syslog
+ * to enable debugging on Red Hat Linux set:
+ * /etc/pam.d/sudo:
+ * auth required /lib/security/pam_pwdb.so shadow nullok audit
+ * _OR_ change PAM_SILENT to 0 to force detailed reporting (logging)
+ */
+ if (pam_start("sudo", user, &PAM_conversation, &pamh) != PAM_SUCCESS ||
+ pam_authenticate(pamh, PAM_SILENT) != PAM_SUCCESS) {
+ pam_end(pamh, 0);
+ return(0);
+ }
+
+ /* User authenticated successfully */
+ pam_end(pamh, PAM_SUCCESS);
+
+ return(1);
+}
+
static void pam_attempt_auth()
{
- pam_handle_t *pamh=NULL;
- int retval;
- register int counter = TRIES_FOR_PASSWORD;
- struct pam_conv conv = {
- misc_conv,
- NULL
- };
+ int i = TRIES_FOR_PASSWORD;
set_perms(PERM_ROOT, 0);
- retval = pam_start("sudo", user_name, &conv, &pamh);
- if (retval != PAM_SUCCESS) {
- pam_end(pamh, retval);
- exit(1);
- }
- while (counter > 0) {
- retval = pam_authenticate(pamh, 0);
- if (retval == PAM_SUCCESS) {
+ while (i > 0) {
+ char *pamPass = (char *) GETPASS(prompt, PASSWORD_TIMEOUT * 60);
+
+ if (pam_auth(user_name, pamPass)) {
set_perms(PERM_USER, 0);
- pam_end(pamh, retval);
return;
}
-
- --counter;
+ --i;
pass_warn(stderr);
}
set_perms(PERM_USER, 0);
- if (counter > 0) {
+ if (i == 0) {
log_error(PASSWORD_NOT_CORRECT);
inform_user(PASSWORD_NOT_CORRECT);
} else {
log_error(PASSWORDS_NOT_CORRECT);
inform_user(PASSWORDS_NOT_CORRECT);
}
- pam_end(pamh, retval);
exit(1);
}
#endif /* HAVE_PAM */
@@ -1031,19 +1096,12 @@ static char *sudo_skeyprompt(user_skey, p)
if (new_prompt == NULL) {
/* allocate space for new prompt */
np_size = op_len + strlen(challenge) + 7;
- if (!(new_prompt = (char *) malloc(np_size))) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ new_prompt = (char *) emalloc(np_size);
} else {
/* already have space allocated, is it enough? */
if (np_size < op_len + strlen(challenge) + 7) {
np_size = op_len + strlen(challenge) + 7;
- if (!(new_prompt = (char *) realloc(new_prompt, np_size))) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n",
- Argv[0]);
- exit(1);
- }
+ new_prompt = (char *) erealloc(new_prompt, np_size);
}
}
@@ -1104,19 +1162,12 @@ static char *sudo_opieprompt(user_opie, p)
if (new_prompt == NULL) {
/* allocate space for new prompt */
np_size = op_len + strlen(challenge) + 7;
- if (!(new_prompt = (char *) malloc(np_size))) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ new_prompt = (char *) emalloc(np_size);
} else {
/* already have space allocated, is it enough? */
if (np_size < op_len + strlen(challenge) + 7) {
np_size = op_len + strlen(challenge) + 7;
- if (!(new_prompt = (char *) realloc(new_prompt, np_size))) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n",
- Argv[0]);
- exit(1);
- }
+ new_prompt = (char *) erealloc(new_prompt, np_size);
}
}
@@ -1217,10 +1268,7 @@ static char *expand_prompt(old_prompt, user, host)
}
if (subst) {
- if ((new_prompt = (char *) malloc(len + 1)) == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ new_prompt = (char *) emalloc(len + 1);
for (p = prompt, np = new_prompt; *p; p++) {
if (lastchar == '%' && (*p == 'h' || *p == 'u' || *p == '%')) {
/* substiture user/host name */
diff --git a/gnu/usr.bin/sudo/sudo/compat.h b/gnu/usr.bin/sudo/sudo/compat.h
index 7fcfa31df96..7cf12f202c1 100644
--- a/gnu/usr.bin/sudo/sudo/compat.h
+++ b/gnu/usr.bin/sudo/sudo/compat.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: compat.h,v 1.8 1999/02/19 04:32:49 millert Exp $ */
+/* $OpenBSD: compat.h,v 1.9 1999/03/29 20:29:02 millert Exp $ */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -20,7 +20,7 @@
*
* Please send bugs, changes, problems to sudo-bugs@courtesan.com
*
- * $Sudo: compat.h,v 1.45 1999/02/03 04:32:13 millert Exp $
+ * $Sudo: compat.h,v 1.46 1999/03/29 04:05:06 millert Exp $
*/
#ifndef _SUDO_COMPAT_H
diff --git a/gnu/usr.bin/sudo/sudo/config.h b/gnu/usr.bin/sudo/sudo/config.h
index 6ec16e99f90..42a53679e07 100644
--- a/gnu/usr.bin/sudo/sudo/config.h
+++ b/gnu/usr.bin/sudo/sudo/config.h
@@ -1,8 +1,8 @@
-/* $OpenBSD: config.h,v 1.8 1999/03/08 00:17:23 millert Exp $ */
+/* $OpenBSD: config.h,v 1.9 1999/03/29 20:29:02 millert Exp $ */
/* config.h. Generated automatically by configure. */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -21,7 +21,7 @@
*
* Please send bugs, changes, problems to sudo-bugs@courtesan.com
*
- * $Sudo: config.h.in,v 1.114 1999/02/03 04:32:13 millert Exp $
+ * $Sudo: config.h.in,v 1.117 1999/03/29 04:05:06 millert Exp $
*/
/*
@@ -86,6 +86,13 @@
/* Define to be nil if C compiler doesn't support "const." */
/* #undef const */
+/* Solaris doesn't use const qualifiers in PAM. */
+#ifdef sun
+#define PAM_CONST
+#else
+#define PAM_CONST const
+#endif
+
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
@@ -284,10 +291,10 @@
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H 1
-/* Define if you have the <strings.h> header file. */
-#if !defined(__convex__) && !defined(convex)
+/* Define if you have the <strings.h> header file but no <string.h>. */
+#ifndef HAVE_STRING_H
#define HAVE_STRINGS_H 1
-#endif /* convex */
+#endif /* !HAVE_STRING_H */
/* Define your flavor of dir entry header file. */
#define HAVE_DIRENT_H 1
diff --git a/gnu/usr.bin/sudo/sudo/find_path.c b/gnu/usr.bin/sudo/sudo/find_path.c
index a83aff04e83..4769065fa58 100644
--- a/gnu/usr.bin/sudo/sudo/find_path.c
+++ b/gnu/usr.bin/sudo/sudo/find_path.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: find_path.c,v 1.9 1999/02/19 04:32:50 millert Exp $ */
+/* $OpenBSD: find_path.c,v 1.10 1999/03/29 20:29:02 millert Exp $ */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -28,7 +28,7 @@
* ocommand contain the resolved and unresolved pathnames respectively.
* NOTE: if "." or "" exists in PATH it will be searched last.
*
- * Todd C. Miller (millert@colorado.edu) Sat Mar 25 21:50:36 MST 1995
+ * Todd C. Miller <Todd.Miller@courtesan.com> Sat Mar 25 21:50:36 MST 1995
*/
#include "config.h"
@@ -46,9 +46,6 @@
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif /* HAVE_STRINGS_H */
-#if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
-#include <malloc.h>
-#endif /* HAVE_MALLOC_H && !STDC_HEADERS */
#include <errno.h>
#include <sys/types.h>
#include <sys/param.h>
@@ -57,18 +54,12 @@
#include "sudo.h"
#ifndef STDC_HEADERS
-#ifndef __GNUC__ /* gcc has its own malloc */
-extern char *malloc __P((size_t));
-#endif /* __GNUC__ */
extern char *getenv __P((const char *));
extern char *strcpy __P((char *, const char *));
extern int fprintf __P((FILE *, const char *, ...));
extern ssize_t readlink __P((const char *, VOID *, size_t));
extern int stat __P((const char *, struct stat *));
extern int lstat __P((const char *, struct stat *));
-#ifdef HAVE_STRDUP
-extern char *strdup __P((const char *));
-#endif /* HAVE_STRDUP */
#endif /* !STDC_HEADERS */
#ifndef _S_IFMT
@@ -79,7 +70,7 @@ extern char *strdup __P((const char *));
#endif /* _S_IFLNK */
#ifndef lint
-static const char rcsid[] = "$Sudo: find_path.c,v 1.83 1999/02/03 04:32:14 millert Exp $";
+static const char rcsid[] = "$Sudo: find_path.c,v 1.85 1999/03/29 04:05:08 millert Exp $";
#endif /* lint */
/*******************************************************************
@@ -131,10 +122,7 @@ int find_path(infile, outfile)
if ((path = getenv("PATH")) == NULL)
return(NOT_FOUND);
- if ((path = (char *) strdup(path)) == NULL) {
- (void) fprintf(stderr, "%s: out of memory!\n", Argv[0]);
- exit(1);
- }
+ path = estrdup(path);
origpath = path;
/* XXX use strtok() */
diff --git a/gnu/usr.bin/sudo/sudo/getspwuid.c b/gnu/usr.bin/sudo/sudo/getspwuid.c
index 21b5fca059e..7ed7cd944f1 100644
--- a/gnu/usr.bin/sudo/sudo/getspwuid.c
+++ b/gnu/usr.bin/sudo/sudo/getspwuid.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: getspwuid.c,v 1.9 1999/02/19 04:32:50 millert Exp $ */
+/* $OpenBSD: getspwuid.c,v 1.10 1999/03/29 20:29:03 millert Exp $ */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -36,9 +36,6 @@
#ifdef STDC_HEADERS
#include <stdlib.h>
#endif /* STDC_HEADERS */
-#if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
-#include <malloc.h>
-#endif /* HAVE_MALLOC_H && !STDC_HEADERS */
#ifdef HAVE_STRING_H
#include <string.h>
#endif /* HAVE_STRING_H */
@@ -73,17 +70,11 @@
#include "sudo.h"
#ifndef lint
-static const char rcsid[] = "$Sudo: getspwuid.c,v 1.43 1999/02/03 04:32:14 millert Exp $";
+static const char rcsid[] = "$Sudo: getspwuid.c,v 1.45 1999/03/29 04:05:08 millert Exp $";
#endif /* lint */
#ifndef STDC_HEADERS
-#ifndef __GNUC__ /* gcc has its own malloc */
-extern char *malloc __P((size_t));
-#endif /* __GNUC__ */
extern char *getenv __P((const char *));
-#ifdef HAVE_STRDUP
-extern char *strdup __P((const char *));
-#endif /* HAVE_STRDUP */
#endif /* !STDC_HEADERS */
/*
@@ -220,42 +211,20 @@ struct passwd *sudo_getpwuid(uid)
return(NULL);
/* allocate space for a local copy of pw */
- local_pw = (struct passwd *) malloc(sizeof(struct passwd));
- if (local_pw == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ local_pw = (struct passwd *) emalloc(sizeof(struct passwd));
/*
* Copy the struct passwd and the interesting strings...
*/
(void) memcpy(local_pw, pw, sizeof(struct passwd));
-
- local_pw->pw_name = (char *) strdup(pw->pw_name);
- if (local_pw->pw_name == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
-
- local_pw->pw_dir = (char *) strdup(pw->pw_dir);
- if (local_pw->pw_dir == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ local_pw->pw_name = estrdup(pw->pw_name);
+ local_pw->pw_dir = estrdup(pw->pw_dir);
/* pw_shell is a special case since we overide with $SHELL */
- local_pw->pw_shell = (char *) strdup(sudo_getshell(pw));
- if (local_pw->pw_shell == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ local_pw->pw_shell = estrdup(sudo_getshell(pw));
/* pw_passwd gets a shadow password if applicable */
- local_pw->pw_passwd = (char *) strdup(sudo_getepw(pw));
- if (local_pw->pw_passwd == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ local_pw->pw_passwd = estrdup(sudo_getepw(pw));
return(local_pw);
}
diff --git a/gnu/usr.bin/sudo/sudo/goodpath.c b/gnu/usr.bin/sudo/sudo/goodpath.c
index 1e282417528..ce914d6e10d 100644
--- a/gnu/usr.bin/sudo/sudo/goodpath.c
+++ b/gnu/usr.bin/sudo/sudo/goodpath.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: goodpath.c,v 1.8 1999/02/19 04:32:50 millert Exp $ */
+/* $OpenBSD: goodpath.c,v 1.9 1999/03/29 20:29:03 millert Exp $ */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -28,7 +28,7 @@
* if the path is stat(2)'able, a regular file, and executable by
* root. The string's size should be <= MAXPATHLEN.
*
- * Todd C. Miller (millert@colorado.edu) Sat Mar 25 21:58:17 MST 1995
+ * Todd C. Miller <Todd.Miller@courtesan.com> Sat Mar 25 21:58:17 MST 1995
*/
#include "config.h"
@@ -56,7 +56,7 @@ extern int stat __P((const char *, struct stat *));
#endif /* !STDC_HEADERS */
#ifndef lint
-static const char rcsid[] = "$Sudo: goodpath.c,v 1.29 1999/02/03 04:32:14 millert Exp $";
+static const char rcsid[] = "$Sudo: goodpath.c,v 1.31 1999/03/29 04:05:08 millert Exp $";
#endif /* lint */
/******************************************************************
diff --git a/gnu/usr.bin/sudo/sudo/ins_2001.h b/gnu/usr.bin/sudo/sudo/ins_2001.h
index d2ed9892f08..9ece577ae47 100644
--- a/gnu/usr.bin/sudo/sudo/ins_2001.h
+++ b/gnu/usr.bin/sudo/sudo/ins_2001.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: ins_2001.h,v 1.8 1999/02/19 04:32:50 millert Exp $ */
+/* $OpenBSD: ins_2001.h,v 1.9 1999/03/29 20:29:03 millert Exp $ */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -20,7 +20,7 @@
*
* Please send bugs, changes, problems to sudo-bugs@courtesan.com
*
- * $Sudo: ins_2001.h,v 1.24 1999/02/03 04:32:14 millert Exp $
+ * $Sudo: ins_2001.h,v 1.25 1999/03/29 04:05:09 millert Exp $
*/
#ifndef _SUDO_INS_2001_H
diff --git a/gnu/usr.bin/sudo/sudo/ins_classic.h b/gnu/usr.bin/sudo/sudo/ins_classic.h
index 585eb2fe3b9..03334947d2f 100644
--- a/gnu/usr.bin/sudo/sudo/ins_classic.h
+++ b/gnu/usr.bin/sudo/sudo/ins_classic.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: ins_classic.h,v 1.8 1999/02/19 04:32:50 millert Exp $ */
+/* $OpenBSD: ins_classic.h,v 1.9 1999/03/29 20:29:03 millert Exp $ */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -20,7 +20,7 @@
*
* Please send bugs, changes, problems to sudo-bugs@courtesan.com
*
- * $Sudo: ins_classic.h,v 1.24 1999/02/03 04:32:14 millert Exp $
+ * $Sudo: ins_classic.h,v 1.25 1999/03/29 04:05:09 millert Exp $
*/
#ifndef _SUDO_INS_CLASSIC_H
diff --git a/gnu/usr.bin/sudo/sudo/ins_csops.h b/gnu/usr.bin/sudo/sudo/ins_csops.h
index 16d062ba7c0..884fd6a1ce7 100644
--- a/gnu/usr.bin/sudo/sudo/ins_csops.h
+++ b/gnu/usr.bin/sudo/sudo/ins_csops.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: ins_csops.h,v 1.8 1999/02/19 04:32:50 millert Exp $ */
+/* $OpenBSD: ins_csops.h,v 1.9 1999/03/29 20:29:04 millert Exp $ */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -20,7 +20,7 @@
*
* Please send bugs, changes, problems to sudo-bugs@courtesan.com
*
- * $Sudo: ins_csops.h,v 1.23 1999/02/03 04:32:14 millert Exp $
+ * $Sudo: ins_csops.h,v 1.24 1999/03/29 04:05:09 millert Exp $
*/
#ifndef _SUDO_INS_CSOPS_H
diff --git a/gnu/usr.bin/sudo/sudo/ins_goons.h b/gnu/usr.bin/sudo/sudo/ins_goons.h
index c4ddd4fe34a..99149956050 100644
--- a/gnu/usr.bin/sudo/sudo/ins_goons.h
+++ b/gnu/usr.bin/sudo/sudo/ins_goons.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: ins_goons.h,v 1.8 1999/02/19 04:32:50 millert Exp $ */
+/* $OpenBSD: ins_goons.h,v 1.9 1999/03/29 20:29:04 millert Exp $ */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -20,7 +20,7 @@
*
* Please send bugs, changes, problems to sudo-bugs@courtesan.com
*
- * $Sudo: ins_goons.h,v 1.24 1999/02/03 04:32:15 millert Exp $
+ * $Sudo: ins_goons.h,v 1.25 1999/03/29 04:05:09 millert Exp $
*/
#ifndef _SUDO_INS_GOONS_H
diff --git a/gnu/usr.bin/sudo/sudo/insults.h b/gnu/usr.bin/sudo/sudo/insults.h
index 4c9c00a516b..a7085c32d0b 100644
--- a/gnu/usr.bin/sudo/sudo/insults.h
+++ b/gnu/usr.bin/sudo/sudo/insults.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: insults.h,v 1.8 1999/02/19 04:32:50 millert Exp $ */
+/* $OpenBSD: insults.h,v 1.9 1999/03/29 20:29:04 millert Exp $ */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1994,1996,1998,1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -20,7 +20,7 @@
*
* Please send bugs, changes, problems to sudo-bugs@courtesan.com
*
- * $Sudo: insults.h,v 1.38 1999/02/03 04:32:15 millert Exp $
+ * $Sudo: insults.h,v 1.39 1999/03/29 04:05:09 millert Exp $
*/
#ifndef _SUDO_INSULTS_H
diff --git a/gnu/usr.bin/sudo/sudo/interfaces.c b/gnu/usr.bin/sudo/sudo/interfaces.c
index 74308d2743f..91f89716872 100644
--- a/gnu/usr.bin/sudo/sudo/interfaces.c
+++ b/gnu/usr.bin/sudo/sudo/interfaces.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: interfaces.c,v 1.10 1999/03/08 00:17:23 millert Exp $ */
+/* $OpenBSD: interfaces.c,v 1.11 1999/03/29 20:29:04 millert Exp $ */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -44,9 +44,6 @@
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif /* HAVE_STRINGS_H */
-#if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
-#include <malloc.h>
-#endif /* HAVE_MALLOC_H && !STDC_HEADERS */
#include <netdb.h>
#include <errno.h>
#include <sys/types.h>
@@ -77,13 +74,8 @@
#include "sudo.h"
#include "version.h"
-#if !defined(STDC_HEADERS) && !defined(__GNUC__)
-extern char *malloc __P((size_t));
-extern char *realloc __P((VOID *, size_t));
-#endif /* !STDC_HEADERS && !__GNUC__ */
-
#ifndef lint
-static const char rcsid[] = "$Sudo: interfaces.c,v 1.50 1999/02/26 06:19:49 millert Exp $";
+static const char rcsid[] = "$Sudo: interfaces.c,v 1.52 1999/03/29 04:05:09 millert Exp $";
#endif /* lint */
/*
@@ -126,11 +118,7 @@ void load_interfaces()
* get interface configuration or return (leaving interfaces NULL)
*/
for (;;) {
- ifconf_buf = ifconf_buf ? realloc(ifconf_buf, len) : malloc(len);
- if (ifconf_buf == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ ifconf_buf = erealloc(ifconf_buf, len);
ifconf = (struct ifconf *) ifconf_buf;
ifconf->ifc_len = len - sizeof(struct ifconf);
ifconf->ifc_buf = (caddr_t) (ifconf_buf + sizeof(struct ifconf));
@@ -159,13 +147,9 @@ void load_interfaces()
n = ifconf->ifc_len / sizeof(struct ifreq);
/*
- * malloc() space for interfaces array
+ * allocate space for interfaces array
*/
- interfaces = (struct interface *) malloc(sizeof(struct interface) * n);
- if (interfaces == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ interfaces = (struct interface *) emalloc(sizeof(struct interface) * n);
/*
* for each interface, store the ip address and netmask
@@ -245,17 +229,11 @@ void load_interfaces()
/* if there were bogus entries, realloc the array */
if (n != num_interfaces) {
/* it is unlikely that num_interfaces will be 0 but who knows... */
- if (num_interfaces != 0) {
- interfaces = (struct interface *) realloc(interfaces,
+ if (num_interfaces != 0)
+ interfaces = (struct interface *) erealloc(interfaces,
sizeof(struct interface) * num_interfaces);
- if (interfaces == NULL) {
- perror("realloc");
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
- } else {
+ else
(void) free(interfaces);
- }
}
(void) free(ifconf_buf);
(void) close(sock);
diff --git a/gnu/usr.bin/sudo/sudo/logging.c b/gnu/usr.bin/sudo/sudo/logging.c
index e8064a43632..918abab8618 100644
--- a/gnu/usr.bin/sudo/sudo/logging.c
+++ b/gnu/usr.bin/sudo/sudo/logging.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: logging.c,v 1.9 1999/02/19 04:32:50 millert Exp $ */
+/* $OpenBSD: logging.c,v 1.10 1999/03/29 20:29:04 millert Exp $ */
/*
- * CU sudo version 1.5.8 (based on Root Group sudo version 1.1)
+ * CU sudo version 1.5.9 (based on Root Group sudo version 1.1)
* Copyright (c) 1994,1996,1998,1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This software comes with no waranty whatsoever, use at your own risk.
@@ -54,9 +54,6 @@
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif /* HAVE_STRINGS_H */
-#if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
-#include <malloc.h>
-#endif /* HAVE_MALLOC_H && !STDC_HEADERS */
#include <pwd.h>
#include <signal.h>
#include <time.h>
@@ -70,7 +67,7 @@
#include "sudo.h"
#ifndef lint
-static const char rcsid[] = "$Sudo: logging.c,v 1.110 1999/02/03 04:32:15 millert Exp $";
+static const char rcsid[] = "$Sudo: logging.c,v 1.112 1999/03/29 04:05:10 millert Exp $";
#endif /* lint */
/*
@@ -160,12 +157,7 @@ void log_error(code)
strlen(runas_user);
if (cmnd_args)
count += strlen(cmnd_args);
-
- logline = (char *) malloc(count);
- if (logline == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ logline = (char *) emalloc(count);
/*
* we will skip this stuff when using syslog(3) but it is
diff --git a/gnu/usr.bin/sudo/sudo/parse.c b/gnu/usr.bin/sudo/sudo/parse.c
index 06c08981e1d..90ef24e121d 100644
--- a/gnu/usr.bin/sudo/sudo/parse.c
+++ b/gnu/usr.bin/sudo/sudo/parse.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: parse.c,v 1.10 1999/02/19 04:32:50 millert Exp $ */
+/* $OpenBSD: parse.c,v 1.11 1999/03/29 20:29:05 millert Exp $ */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -49,9 +49,6 @@
# include "emul/fnmatch.h"
# endif /* HAVE_FNMATCH */
#endif /* HAVE_FNMATCH_H */
-#if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
-# include <malloc.h>
-#endif /* HAVE_MALLOC_H && !STDC_HEADERS */
#ifdef HAVE_NETGROUP_H
# include <netgroup.h>
#endif /* HAVE_NETGROUP_H */
@@ -84,7 +81,7 @@
#include "sudo.h"
#ifndef lint
-static const char rcsid[] = "$Sudo: parse.c,v 1.100 1999/02/03 04:32:15 millert Exp $";
+static const char rcsid[] = "$Sudo: parse.c,v 1.102 1999/03/29 04:05:10 millert Exp $";
#endif /* lint */
/*
@@ -412,11 +409,7 @@ int netgr_matches(netgr, host, user)
#ifdef HAVE_GETDOMAINNAME
/* get the domain name (if any) */
if (domain == (char *) -1) {
- if ((domain = (char *) malloc(MAXHOSTNAMELEN)) == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
-
+ domain = (char *) emalloc(MAXHOSTNAMELEN);
if (getdomainname(domain, MAXHOSTNAMELEN) != 0 || *domain == '\0') {
(void) free(domain);
domain = NULL;
diff --git a/gnu/usr.bin/sudo/sudo/parse.lex b/gnu/usr.bin/sudo/sudo/parse.lex
index 3652f9fb062..d247beb7e07 100644
--- a/gnu/usr.bin/sudo/sudo/parse.lex
+++ b/gnu/usr.bin/sudo/sudo/parse.lex
@@ -1,8 +1,8 @@
-/* $OpenBSD: parse.lex,v 1.9 1999/03/08 00:17:23 millert Exp $ */
-
%{
+/* $OpenBSD: parse.lex,v 1.10 1999/03/29 20:29:05 millert Exp $ */
+
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -50,7 +50,7 @@
#include "sudo.tab.h"
#ifndef lint
-static const char rcsid[] = "$Sudo: parse.lex,v 1.86 1999/03/07 23:34:31 millert Exp $";
+static const char rcsid[] = "$Sudo: parse.lex,v 1.88 1999/03/29 04:05:10 millert Exp $";
#endif /* lint */
#undef yywrap /* guard against a yywrap macro */
@@ -325,9 +325,11 @@ static void fill_args(s, len, addspace)
while (new_len >= (arg_size += COMMANDARGINC))
;
- yylval.command.args = (char *) realloc(yylval.command.args, arg_size);
- if (yylval.command.args == NULL)
+ if ((p = (char *) realloc(yylval.command.args, arg_size)) == NULL) {
+ (void) free(yylval.command.args);
yyerror("unable to allocate memory");
+ } else
+ yylval.command.args = p;
}
}
diff --git a/gnu/usr.bin/sudo/sudo/parse.yacc b/gnu/usr.bin/sudo/sudo/parse.yacc
index fa3960b8798..80d6c98024f 100644
--- a/gnu/usr.bin/sudo/sudo/parse.yacc
+++ b/gnu/usr.bin/sudo/sudo/parse.yacc
@@ -1,7 +1,8 @@
%{
+/* $OpenBSD: parse.yacc,v 1.13 1999/03/29 20:29:05 millert Exp $ */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -63,7 +64,7 @@
#endif /* !HAVE_STRCASECMP */
#ifndef lint
-static const char rcsid[] = "$Sudo: parse.yacc,v 1.127 1999/02/11 06:41:31 millert Exp $";
+static const char rcsid[] = "$Sudo: parse.yacc,v 1.133 1999/03/29 04:31:15 millert Exp $";
#endif /* lint */
/*
@@ -92,11 +93,7 @@ int top = 0, stacksize = 0;
{ \
if (top >= stacksize) { \
while ((stacksize += STACKINCREMENT) < top); \
- match = (struct matchstack *) realloc(match, sizeof(struct matchstack) * stacksize); \
- if (match == NULL) { \
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]); \
- exit(1); \
- } \
+ match = (struct matchstack *) erealloc(match, sizeof(struct matchstack) * stacksize); \
} \
match[top].user = -1; \
match[top].cmnd = -1; \
@@ -270,10 +267,21 @@ cmndspeclist : cmndspec
| cmndspeclist ',' cmndspec
;
-cmndspec : runasspec nopasswd opcmnd {
- if ($1 > 0 && $3 == TRUE) {
+cmndspec : { /* Push a new entry onto the stack if needed */
+ if (user_matches == TRUE && host_matches == TRUE &&
+ cmnd_matches == TRUE && runas_matches == TRUE) {
+ push;
+ user_matches = TRUE;
+ host_matches = TRUE;
+ } else {
+ cmnd_matches = -1;
+ runas_matches = -1;
+ no_passwd = -1;
+ }
+ } runasspec nopasswd opcmnd {
+ if ($2 > 0 && $4 == TRUE) {
runas_matches = TRUE;
- if ($2 == TRUE)
+ if ($3 == TRUE)
no_passwd = TRUE;
} else if (printmatches == TRUE) {
cm_list[cm_list_len].runas_len = 0;
@@ -511,11 +519,7 @@ cmndalias : ALIAS {
in_alias = TRUE;
/* Allocate space for ga_list if necesary. */
expand_ga_list();
- if (!(ga_list[ga_list_len-1].alias = (char *) strdup($1))){
- (void) fprintf(stderr,
- "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ ga_list[ga_list_len-1].alias = estrdup($1);
}
} '=' cmndlist {
if (cmnd_matches == TRUE &&
@@ -544,11 +548,7 @@ runasalias : ALIAS {
in_alias = TRUE;
/* Allocate space for ga_list if necesary. */
expand_ga_list();
- if (!(ga_list[ga_list_len-1].alias = (char *) strdup($1))){
- (void) fprintf(stderr,
- "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ ga_list[ga_list_len-1].alias = estrdup($1);
}
} '=' runaslist {
if ($4 > 0 && add_alias($1, RUNAS_ALIAS) == FALSE)
@@ -846,6 +846,8 @@ void list_matches()
}
(void) free(cm_list);
cm_list = NULL;
+ cm_list_len = 0;
+ cm_list_size = 0;
}
@@ -868,11 +870,7 @@ static void append(src, dstp, dst_len, dst_size, separator)
/* Assumes dst will be NULL if not set. */
if (dst == NULL) {
- if ((dst = (char *) malloc(BUFSIZ)) == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
-
+ dst = (char *) emalloc(BUFSIZ);
*dst_size = BUFSIZ;
*dst_len = 0;
*dstp = dst;
@@ -883,10 +881,7 @@ static void append(src, dstp, dst_len, dst_size, separator)
while (*dst_size <= *dst_len + src_len)
*dst_size += BUFSIZ;
- if (!(dst = (char *) realloc(dst, *dst_size))) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ dst = (char *) erealloc(dst, *dst_size);
*dstp = dst;
}
@@ -909,8 +904,10 @@ static void append(src, dstp, dst_len, dst_size, separator)
void reset_aliases()
{
- if (aliases)
+ if (aliases) {
(void) free(aliases);
+ aliases = NULL;
+ }
naliases = nslots = 0;
}
@@ -925,20 +922,10 @@ void reset_aliases()
static void expand_ga_list()
{
if (++ga_list_len >= ga_list_size) {
- while ((ga_list_size += STACKINCREMENT) < ga_list_len);
- if (ga_list == NULL) {
- if ((ga_list = (struct generic_alias *)
- malloc(sizeof(struct generic_alias) * ga_list_size)) == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
- } else {
- if ((ga_list = (struct generic_alias *) realloc(ga_list,
- sizeof(struct generic_alias) * ga_list_size)) == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
- }
+ while ((ga_list_size += STACKINCREMENT) < ga_list_len)
+ ;
+ ga_list = (struct generic_alias *)
+ erealloc(ga_list, sizeof(struct generic_alias) * ga_list_size);
}
ga_list[ga_list_len - 1].entries = NULL;
@@ -955,21 +942,12 @@ static void expand_ga_list()
static void expand_match_list()
{
if (++cm_list_len >= cm_list_size) {
- while ((cm_list_size += STACKINCREMENT) < cm_list_len);
- if (cm_list == NULL) {
- if ((cm_list = (struct command_match *)
- malloc(sizeof(struct command_match) * cm_list_size)) == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
- cm_list_len = 0;
- } else {
- if ((cm_list = (struct command_match *) realloc(cm_list,
- sizeof(struct command_match) * cm_list_size)) == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
- }
+ while ((cm_list_size += STACKINCREMENT) < cm_list_len)
+ ;
+ if (cm_list == NULL)
+ cm_list_len = 0; /* start at 0 since it is a subscript */
+ cm_list = (struct command_match *)
+ erealloc(cm_list, sizeof(struct command_match) * cm_list_size);
}
cm_list[cm_list_len].runas = cm_list[cm_list_len].cmnd = NULL;
@@ -999,11 +977,7 @@ void init_parser()
/* Allocate space for the matching stack. */
stacksize = STACKINCREMENT;
- match = (struct matchstack *) malloc(sizeof(struct matchstack) * stacksize);
- if (match == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ match = (struct matchstack *) emalloc(sizeof(struct matchstack) * stacksize);
/* Allocate space for the match list (for `sudo -l'). */
if (printmatches == TRUE)
diff --git a/gnu/usr.bin/sudo/sudo/pathnames.h b/gnu/usr.bin/sudo/sudo/pathnames.h
index bff7ae3d7c1..4b8b739c6a2 100644
--- a/gnu/usr.bin/sudo/sudo/pathnames.h
+++ b/gnu/usr.bin/sudo/sudo/pathnames.h
@@ -1,8 +1,8 @@
-/* $OpenBSD: pathnames.h,v 1.8 1999/02/19 04:32:51 millert Exp $ */
+/* $OpenBSD: pathnames.h,v 1.9 1999/03/29 20:29:05 millert Exp $ */
/* pathnames.h. Generated automatically by configure. */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -21,7 +21,7 @@
*
* Please send bugs, changes, problems to sudo-bugs@courtesan.com
*
- * $Sudo: pathnames.h.in,v 1.37 1999/02/03 04:32:16 millert Exp $
+ * $Sudo: pathnames.h.in,v 1.38 1999/03/29 04:05:11 millert Exp $
*/
/*
diff --git a/gnu/usr.bin/sudo/sudo/sudo.8 b/gnu/usr.bin/sudo/sudo/sudo.8
index a4074712acb..19600ce1825 100644
--- a/gnu/usr.bin/sudo/sudo/sudo.8
+++ b/gnu/usr.bin/sudo/sudo/sudo.8
@@ -1,5 +1,5 @@
.rn '' }`
-''' $OpenBSD: sudo.8,v 1.10 1999/03/08 00:17:23 millert Exp $
+''' $OpenBSD: sudo.8,v 1.11 1999/03/29 20:29:06 millert Exp $
'''
.de Sh
.br
@@ -91,7 +91,7 @@
.nr % 0
.rr F
.\}
-.TH sudo 8 "1.5.8" "17/Feb/99" "MAINTENANCE COMMANDS"
+.TH sudo 8 "1.5.9" "17/Feb/99" "MAINTENANCE COMMANDS"
.UC
.if n .hy 0
.if n .na
diff --git a/gnu/usr.bin/sudo/sudo/sudo.c b/gnu/usr.bin/sudo/sudo/sudo.c
index 0802c519b91..403a453d498 100644
--- a/gnu/usr.bin/sudo/sudo/sudo.c
+++ b/gnu/usr.bin/sudo/sudo/sudo.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: sudo.c,v 1.12 1999/02/19 04:32:51 millert Exp $ */
+/* $OpenBSD: sudo.c,v 1.13 1999/03/29 20:29:06 millert Exp $ */
/*
- * CU sudo version 1.5.8 (based on Root Group sudo version 1.1)
+ * CU sudo version 1.5.9 (based on Root Group sudo version 1.1)
* Copyright (c) 1994,1996,1998,1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This software comes with no waranty whatsoever, use at your own risk.
@@ -70,9 +70,6 @@
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif /* HAVE_STRINGS_H */
-#if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
-#include <malloc.h>
-#endif /* HAVE_MALLOC_H && !STDC_HEADERS */
#include <pwd.h>
#include <errno.h>
#include <fcntl.h>
@@ -92,17 +89,11 @@
#include "version.h"
#ifndef STDC_HEADERS
-#ifndef __GNUC__ /* gcc has its own malloc */
-extern char *malloc __P((size_t));
-#endif /* __GNUC__ */
-#ifdef HAVE_STRDUP
-extern char *strdup __P((const char *));
-#endif /* HAVE_STRDUP */
extern char *getenv __P((char *));
#endif /* STDC_HEADERS */
#ifndef lint
-static const char rcsid[] = "$Sudo: sudo.c,v 1.219 1999/02/11 06:41:31 millert Exp $";
+static const char rcsid[] = "$Sudo: sudo.c,v 1.222 1999/03/29 04:05:12 millert Exp $";
#endif /* lint */
@@ -273,11 +264,7 @@ int main(argc, argv)
if ((sudo_mode & MODE_SHELL)) {
char **dst, **src = NewArgv;
- NewArgv = (char **) malloc (sizeof(char *) * (++NewArgc + 1));
- if (NewArgv == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ NewArgv = (char **) emalloc (sizeof(char *) * (++NewArgc + 1));
/* add the shell as argv[0] */
if (user_shell && *user_shell) {
@@ -439,6 +426,13 @@ static void load_globals(sudo_mode)
char *lrealm;
#endif /* HAVE_KERB5 */
+#ifdef HOST_IN_LOG
+ /*
+ * Logging routines may use shost so set to a dummy value for now.
+ */
+ shost = strcpy(host, "localhost");
+#endif
+
/*
* Get a local copy of the user's struct passwd with the shadow password
* if necesary. It is assumed that euid is 0 at this point so we
@@ -483,11 +477,7 @@ static void load_globals(sudo_mode)
realm = lrealm;
if (!arg_prompt) {
- p = malloc(strlen(user_name) + strlen(realm) + 17);
- if (p == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ p = emalloc(strlen(user_name) + strlen(realm) + 17);
sprintf(p, "Password for %s@%s: ", user_name, realm);
prompt = p;
}
@@ -507,10 +497,7 @@ static void load_globals(sudo_mode)
if ((p = (char *) ttyname(0)) || (p = (char *) ttyname(1))) {
if (strncmp(p, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
p += sizeof(_PATH_DEV) - 1;
- if ((tty = (char *) strdup(p)) == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ tty = estrdup(p);
}
#ifdef SUDO_UMASK
@@ -562,10 +549,7 @@ static void load_globals(sudo_mode)
*/
if ((p = strchr(host, '.'))) {
*p = '\0';
- if ((shost = (char *) strdup(host)) == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ shost = estrdup(host);
*p = '.';
} else {
shost = &host[0];
@@ -763,10 +747,7 @@ static void add_env(contiguous)
size += strlen(*from) + 1;
}
- if ((buf = (char *) malloc(size)) == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
+ buf = (char *) emalloc(size);
/*
* Copy the command and it's arguments info buf
diff --git a/gnu/usr.bin/sudo/sudo/sudo.h b/gnu/usr.bin/sudo/sudo/sudo.h
index 769252dc88d..ea04d9e5a36 100644
--- a/gnu/usr.bin/sudo/sudo/sudo.h
+++ b/gnu/usr.bin/sudo/sudo/sudo.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: sudo.h,v 1.8 1999/02/19 04:32:51 millert Exp $ */
+/* $OpenBSD: sudo.h,v 1.9 1999/03/29 20:29:06 millert Exp $ */
/*
- * CU sudo version 1.5.8 (based on Root Group sudo version 1.1)
+ * CU sudo version 1.5.9 (based on Root Group sudo version 1.1)
* Copyright (c) 1994,1996,1998,1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This software comes with no waranty whatsoever, use at your own risk.
@@ -28,7 +28,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Sudo: sudo.h,v 1.138 1999/02/07 00:43:24 millert Exp $
+ * $Sudo: sudo.h,v 1.140 1999/03/29 04:05:12 millert Exp $
*/
#ifndef _SUDO_SUDO_H
@@ -231,9 +231,6 @@ struct generic_alias {
*/
#define YY_DECL int yylex __P((void))
-#ifndef HAVE_STRDUP
-char *strdup __P((const char *));
-#endif
#ifndef HAVE_GETCWD
char *getcwd __P((char *, size_t size));
#endif
@@ -255,6 +252,9 @@ int check_secureware __P((char *));
void sia_attempt_auth __P((void));
int yyparse __P((void));
void pass_warn __P((FILE *));
+VOID *emalloc __P((size_t));
+VOID *erealloc __P((VOID *, size_t));
+VOID *estrdup __P((char *));
YY_DECL;
diff --git a/gnu/usr.bin/sudo/sudo/sudo_setenv.c b/gnu/usr.bin/sudo/sudo/sudo_setenv.c
index de361c20dea..22680412df3 100644
--- a/gnu/usr.bin/sudo/sudo/sudo_setenv.c
+++ b/gnu/usr.bin/sudo/sudo/sudo_setenv.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: sudo_setenv.c,v 1.8 1999/02/19 04:32:51 millert Exp $ */
+/* $OpenBSD: sudo_setenv.c,v 1.9 1999/03/29 20:29:07 millert Exp $ */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -25,7 +25,7 @@
* This module contains sudo_setenv().
* sudo_setenv(3) adds a string of the form "var=val" to the environment.
*
- * Todd C. Miller (millert@colorado.edu) Fri Jun 3 18:32:19 MDT 1994
+ * Todd C. Miller <Todd.Miller@courtesan.com> Fri Jun 3 18:32:19 MDT 1994
*/
#include "config.h"
@@ -56,7 +56,7 @@ extern int setenv __P((char *, char *, int));
#endif /* !STDC_HEADERS */
#ifndef lint
-static const char rcsid[] = "$Sudo: sudo_setenv.c,v 1.33 1999/02/03 04:32:17 millert Exp $";
+static const char rcsid[] = "$Sudo: sudo_setenv.c,v 1.35 1999/03/29 04:05:13 millert Exp $";
#endif /* lint */
diff --git a/gnu/usr.bin/sudo/sudo/sudoers.5 b/gnu/usr.bin/sudo/sudo/sudoers.5
index 2c5a4620719..fae8dd28129 100644
--- a/gnu/usr.bin/sudo/sudo/sudoers.5
+++ b/gnu/usr.bin/sudo/sudo/sudoers.5
@@ -1,5 +1,5 @@
.rn '' }`
-''' $OpenBSD: sudoers.5,v 1.9 1999/03/08 00:17:23 millert Exp $
+''' $OpenBSD: sudoers.5,v 1.10 1999/03/29 20:29:07 millert Exp $
'''
.de Sh
.br
@@ -91,7 +91,7 @@
.nr % 0
.rr F
.\}
-.TH sudoers 5 "1.5.8" "6/Feb/98" "FILE FORMATS"
+.TH sudoers 5 "1.5.9" "17/Jan/99" "FILE FORMATS"
.UC
.if n .hy 0
.if n .na
diff --git a/gnu/usr.bin/sudo/sudo/tgetpass.c b/gnu/usr.bin/sudo/sudo/tgetpass.c
index 496045ee3f0..e33b2f63da7 100644
--- a/gnu/usr.bin/sudo/sudo/tgetpass.c
+++ b/gnu/usr.bin/sudo/sudo/tgetpass.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: tgetpass.c,v 1.13 1999/02/19 04:32:51 millert Exp $ */
+/* $OpenBSD: tgetpass.c,v 1.14 1999/03/29 20:29:07 millert Exp $ */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -85,7 +85,7 @@
#endif /* TCSASOFT */
#ifndef lint
-static const char rcsid[] = "$Sudo: tgetpass.c,v 1.75 1999/02/03 04:32:18 millert Exp $";
+static const char rcsid[] = "$Sudo: tgetpass.c,v 1.76 1999/03/29 04:05:13 millert Exp $";
#endif /* lint */
diff --git a/gnu/usr.bin/sudo/sudo/version.h b/gnu/usr.bin/sudo/sudo/version.h
index 6d014aa3842..260cd1f7a3e 100644
--- a/gnu/usr.bin/sudo/sudo/version.h
+++ b/gnu/usr.bin/sudo/sudo/version.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: version.h,v 1.10 1999/03/08 00:17:23 millert Exp $ */
+/* $OpenBSD: version.h,v 1.11 1999/03/29 20:29:07 millert Exp $ */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -20,12 +20,12 @@
*
* Please send bugs, changes, problems to sudo-bugs@courtesan.com
*
- * $Sudo: version.h,v 1.50 1999/02/03 04:32:18 millert Exp $
+ * $Sudo: version.h,v 1.51 1999/03/29 04:05:14 millert Exp $
*/
#ifndef _SUDO_VERSION_H
#define _SUDO_VERSION_H
-static const char version[] = "1.5.8p2";
+static const char version[] = "1.5.9";
#endif /* _SUDO_VERSION_H */
diff --git a/gnu/usr.bin/sudo/visudo/Makefile b/gnu/usr.bin/sudo/visudo/Makefile
index ff0775a32e1..b0f774af0f0 100644
--- a/gnu/usr.bin/sudo/visudo/Makefile
+++ b/gnu/usr.bin/sudo/visudo/Makefile
@@ -1,10 +1,11 @@
-# $OpenBSD: Makefile,v 1.2 1998/09/15 02:42:45 millert Exp $
+# $OpenBSD: Makefile,v 1.3 1999/03/29 20:29:08 millert Exp $
PROG= visudo
MAN= visudo.8
CFLAGS+=-I${.CURDIR}/../sudo -I.
-SRCS= sudo.tab.c lex.yy.c visudo.c
+SRCS= sudo.tab.c lex.yy.c visudo.c alloc.c
CLEANFILES+=sudo.tab.c sudo.tab.h lex.yy.c
+.PATH: ${.CURDIR}/../sudo
LDADD= -lcompat
DPADD= ${LIBCOMPAT}
diff --git a/gnu/usr.bin/sudo/visudo/visudo.8 b/gnu/usr.bin/sudo/visudo/visudo.8
index e5ccb579245..7443749bef6 100644
--- a/gnu/usr.bin/sudo/visudo/visudo.8
+++ b/gnu/usr.bin/sudo/visudo/visudo.8
@@ -1,5 +1,5 @@
.rn '' }`
-''' $OpenBSD: visudo.8,v 1.9 1999/03/08 00:17:23 millert Exp $
+''' $OpenBSD: visudo.8,v 1.10 1999/03/29 20:29:08 millert Exp $
'''
.de Sh
.br
@@ -91,7 +91,7 @@
.nr % 0
.rr F
.\}
-.TH visudo 8 "1.5.8" "17/Oct/98" "MAINTENANCE COMMANDS"
+.TH visudo 8 "1.5.9" "17/Jan/99" "MAINTENANCE COMMANDS"
.UC
.if n .hy 0
.if n .na
diff --git a/gnu/usr.bin/sudo/visudo/visudo.c b/gnu/usr.bin/sudo/visudo/visudo.c
index a030d9bf037..e6a54cf064d 100644
--- a/gnu/usr.bin/sudo/visudo/visudo.c
+++ b/gnu/usr.bin/sudo/visudo/visudo.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: visudo.c,v 1.10 1999/02/19 04:32:51 millert Exp $ */
+/* $OpenBSD: visudo.c,v 1.11 1999/03/29 20:29:08 millert Exp $ */
/*
- * CU sudo version 1.5.8
+ * CU sudo version 1.5.9
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -25,7 +25,7 @@
* visudo.c -- locks the sudoers file for safe editing and check
* for parse errors.
*
- * Todd C. Miller (millert@colorado.edu) Sat Mar 25 21:50:36 MST 1995
+ * Todd C. Miller <Todd.Miller@courtesan.com> Sat Mar 25 21:50:36 MST 1995
*/
#include "config.h"
@@ -73,7 +73,7 @@ extern int stat __P((const char *, struct stat *));
#endif /* POSIX_SIGNALS && !SA_RESETHAND */
#ifndef lint
-static const char rcsid[] = "$Sudo: visudo.c,v 1.98 1999/02/03 04:32:18 millert Exp $";
+static const char rcsid[] = "$Sudo: visudo.c,v 1.100 1999/03/29 04:05:14 millert Exp $";
#endif /* lint */
/*