ALT Linux repos
S: | 1.9.14p1-alt2.1 |
5.0: | 1.6.8p12-alt5 |
4.1: | 1.6.8p12-alt5.M41.1 |
4.0: | 1.6.8p12-alt5 |
+updates: | 1.6.8p12-alt5 |
3.0: | 1.6.7p5-alt5 |
Group :: System/Base
RPM: sudo
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: sudo-1.6.7p2-alt-progname.patch
Download
Download
diff -upk.orig sudo-1.6.7p2.orig/alloc.c sudo-1.6.7p2/alloc.c
--- sudo-1.6.7p2.orig/alloc.c 2003-03-15 23:31:01 +0300
+++ sudo-1.6.7p2/alloc.c 2003-04-09 15:43:38 +0400
@@ -81,8 +81,6 @@ static const char rcsid[] = "$Sudo: allo
# endif /* SIZE_T_MAX */
#endif /* SIZE_MAX */
-extern char **Argv; /* from sudo.c */
-
/*
* emalloc() calls the system malloc(3) and exits with an error if
* malloc(3) fails.
@@ -95,11 +93,11 @@ emalloc(size)
if (size == 0) {
(void) fprintf(stderr, "%s: internal error, tried to emalloc(0)\n",
- Argv[0]);
+ __progname);
exit(1);
}
if ((ptr = (VOID *) malloc(size)) == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
+ (void) fprintf(stderr, "%s: cannot allocate memory!\n", __progname);
exit(1);
}
return(ptr);
@@ -118,17 +116,17 @@ emalloc2(nmemb, size)
if (nmemb == 0 || size == 0) {
(void) fprintf(stderr, "%s: internal error, tried to emalloc2(0)\n",
- Argv[0]);
+ __progname);
exit(1);
}
if (nmemb > SIZE_MAX / size) {
(void) fprintf(stderr, "%s: internal error, emalloc2() overflow\n",
- Argv[0]);
+ __progname);
exit(1);
}
size *= nmemb;
if ((ptr = (VOID *) malloc(size)) == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
+ (void) fprintf(stderr, "%s: cannot allocate memory!\n", __progname);
exit(1);
}
return(ptr);
@@ -147,12 +145,12 @@ erealloc(ptr, size)
if (size == 0) {
(void) fprintf(stderr, "%s: internal error, tried to erealloc(0)\n",
- Argv[0]);
+ __progname);
exit(1);
}
ptr = ptr ? (VOID *) realloc(ptr, size) : (VOID *) malloc(size);
if (ptr == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
+ (void) fprintf(stderr, "%s: cannot allocate memory!\n", __progname);
exit(1);
}
return(ptr);
@@ -173,18 +171,18 @@ erealloc3(ptr, nmemb, size)
if (nmemb == 0 || size == 0) {
(void) fprintf(stderr, "%s: internal error, tried to erealloc3(0)\n",
- Argv[0]);
+ __progname);
exit(1);
}
if (nmemb > SIZE_MAX / size) {
(void) fprintf(stderr, "%s: internal error, erealloc3() overflow\n",
- Argv[0]);
+ __progname);
exit(1);
}
size *= nmemb;
ptr = ptr ? (VOID *) realloc(ptr, size) : (VOID *) malloc(size);
if (ptr == NULL) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
+ (void) fprintf(stderr, "%s: cannot allocate memory!\n", __progname);
exit(1);
}
return(ptr);
@@ -237,7 +235,7 @@ easprintf(va_alist)
va_end(ap);
if (len == -1) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
+ (void) fprintf(stderr, "%s: cannot allocate memory!\n", __progname);
exit(1);
}
return(len);
@@ -256,7 +254,7 @@ evasprintf(ret, format, args)
int len;
if ((len = vasprintf(ret, format, args)) == -1) {
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
+ (void) fprintf(stderr, "%s: cannot allocate memory!\n", __progname);
exit(1);
}
return(len);
Общие подкаталоги: sudo-1.6.7p2.orig/auth и sudo-1.6.7p2/auth
diff -upk.orig sudo-1.6.7p2.orig/check.c sudo-1.6.7p2/check.c
--- sudo-1.6.7p2.orig/check.c 2003-04-01 18:58:55 +0400
+++ sudo-1.6.7p2/check.c 2003-04-09 15:43:24 +0400
@@ -270,7 +270,7 @@ expand_prompt(old_prompt, user, host)
oflow:
/* We pre-allocate enough space, so this should never happen. */
(void) fprintf(stderr, "%s: internal error, expand_prompt() overflow\n",
- Argv[0]);
+ __progname);
exit(1);
}
@@ -550,7 +550,7 @@ remove_timestamp(remove)
}
if (!remove && touch(ts, 0) == -1) {
(void) fprintf(stderr, "%s: can't reset %s to epoch: %s\n",
- Argv[0], ts, strerror(errno));
+ __progname, ts, strerror(errno));
}
}
diff -upk.orig sudo-1.6.7p2.orig/defaults.c sudo-1.6.7p2/defaults.c
--- sudo-1.6.7p2.orig/defaults.c 2001-12-30 21:40:09 +0300
+++ sudo-1.6.7p2/defaults.c 2003-04-09 14:53:22 +0400
@@ -220,7 +220,7 @@ set_default(var, val, op)
}
if (!cur->name) {
(void) fprintf(stderr,
- "%s: unknown defaults entry `%s' referenced near line %d\n", Argv[0],
+ "%s: unknown defaults entry `%s' referenced near line %d\n", __progname,
var, sudolineno);
return(FALSE);
}
@@ -230,11 +230,11 @@ set_default(var, val, op)
if (!store_syslogfac(val, cur, op)) {
if (val)
(void) fprintf(stderr,
- "%s: value '%s' is invalid for option '%s'\n", Argv[0],
+ "%s: value '%s' is invalid for option '%s'\n", __progname,
val, var);
else
(void) fprintf(stderr,
- "%s: no value specified for `%s' on line %d\n", Argv[0],
+ "%s: no value specified for `%s' on line %d\n", __progname,
var, sudolineno);
return(FALSE);
}
@@ -243,11 +243,11 @@ set_default(var, val, op)
if (!store_syslogpri(val, cur, op)) {
if (val)
(void) fprintf(stderr,
- "%s: value '%s' is invalid for option '%s'\n", Argv[0],
+ "%s: value '%s' is invalid for option '%s'\n", __progname,
val, var);
else
(void) fprintf(stderr,
- "%s: no value specified for `%s' on line %d\n", Argv[0],
+ "%s: no value specified for `%s' on line %d\n", __progname,
var, sudolineno);
return(FALSE);
}
@@ -256,11 +256,11 @@ set_default(var, val, op)
if (!store_pwflag(val, cur, op)) {
if (val)
(void) fprintf(stderr,
- "%s: value '%s' is invalid for option '%s'\n", Argv[0],
+ "%s: value '%s' is invalid for option '%s'\n", __progname,
val, var);
else
(void) fprintf(stderr,
- "%s: no value specified for `%s' on line %d\n", Argv[0],
+ "%s: no value specified for `%s' on line %d\n", __progname,
var, sudolineno);
return(FALSE);
}
@@ -270,20 +270,20 @@ set_default(var, val, op)
/* Check for bogus boolean usage or lack of a value. */
if (!(cur->type & T_BOOL) || op != FALSE) {
(void) fprintf(stderr,
- "%s: no value specified for `%s' on line %d\n", Argv[0],
+ "%s: no value specified for `%s' on line %d\n", __progname,
var, sudolineno);
return(FALSE);
}
}
if ((cur->type & T_PATH) && val && *val != '/') {
(void) fprintf(stderr,
- "%s: values for `%s' must start with a '/'\n", Argv[0],
+ "%s: values for `%s' must start with a '/'\n", __progname,
var);
return(FALSE);
}
if (!store_str(val, cur, op)) {
(void) fprintf(stderr,
- "%s: value '%s' is invalid for option '%s'\n", Argv[0],
+ "%s: value '%s' is invalid for option '%s'\n", __progname,
val, var);
return(FALSE);
}
@@ -293,14 +293,14 @@ set_default(var, val, op)
/* Check for bogus boolean usage or lack of a value. */
if (!(cur->type & T_BOOL) || op != FALSE) {
(void) fprintf(stderr,
- "%s: no value specified for `%s' on line %d\n", Argv[0],
+ "%s: no value specified for `%s' on line %d\n", __progname,
var, sudolineno);
return(FALSE);
}
}
if (!store_int(val, cur, op)) {
(void) fprintf(stderr,
- "%s: value '%s' is invalid for option '%s'\n", Argv[0],
+ "%s: value '%s' is invalid for option '%s'\n", __progname,
val, var);
return(FALSE);
}
@@ -310,14 +310,14 @@ set_default(var, val, op)
/* Check for bogus boolean usage or lack of a value. */
if (!(cur->type & T_BOOL) || op != FALSE) {
(void) fprintf(stderr,
- "%s: no value specified for `%s' on line %d\n", Argv[0],
+ "%s: no value specified for `%s' on line %d\n", __progname,
var, sudolineno);
return(FALSE);
}
}
if (!store_uint(val, cur, op)) {
(void) fprintf(stderr,
- "%s: value '%s' is invalid for option '%s'\n", Argv[0],
+ "%s: value '%s' is invalid for option '%s'\n", __progname,
val, var);
return(FALSE);
}
@@ -327,14 +327,14 @@ set_default(var, val, op)
/* Check for bogus boolean usage or lack of a value. */
if (!(cur->type & T_BOOL) || op != FALSE) {
(void) fprintf(stderr,
- "%s: no value specified for `%s' on line %d\n", Argv[0],
+ "%s: no value specified for `%s' on line %d\n", __progname,
var, sudolineno);
return(FALSE);
}
}
if (!store_mode(val, cur, op)) {
(void) fprintf(stderr,
- "%s: value '%s' is invalid for option '%s'\n", Argv[0],
+ "%s: value '%s' is invalid for option '%s'\n", __progname,
val, var);
return(FALSE);
}
@@ -343,7 +343,7 @@ set_default(var, val, op)
if (val) {
(void) fprintf(stderr,
"%s: option `%s' does not take a value on line %d\n",
- Argv[0], var, sudolineno);
+ __progname, var, sudolineno);
return(FALSE);
}
cur->sd_un.flag = op;
@@ -357,14 +357,14 @@ set_default(var, val, op)
/* Check for bogus boolean usage or lack of a value. */
if (!(cur->type & T_BOOL) || op != FALSE) {
(void) fprintf(stderr,
- "%s: no value specified for `%s' on line %d\n", Argv[0],
+ "%s: no value specified for `%s' on line %d\n", __progname,
var, sudolineno);
return(FALSE);
}
}
if (!store_list(val, cur, op)) {
(void) fprintf(stderr,
- "%s: value '%s' is invalid for option '%s'\n", Argv[0],
+ "%s: value '%s' is invalid for option '%s'\n", __progname,
val, var);
return(FALSE);
}
Общие подкаталоги: sudo-1.6.7p2.orig/emul и sudo-1.6.7p2/emul
diff -upk.orig sudo-1.6.7p2.orig/env.c sudo-1.6.7p2/env.c
--- sudo-1.6.7p2.orig/env.c 2003-04-02 23:01:08 +0400
+++ sudo-1.6.7p2/env.c 2003-04-09 15:42:30 +0400
@@ -224,7 +224,7 @@ format_env(var, val)
strlcat(estring, "=", esize) >= esize ||
strlcat(estring, val, esize) >= esize) {
(void) fprintf(stderr, "%s: internal error, format_env() overflow\n",
- Argv[0]);
+ __progname);
exit(1);
}
diff -upk.orig sudo-1.6.7p2.orig/find_path.c sudo-1.6.7p2/find_path.c
--- sudo-1.6.7p2.orig/find_path.c 2003-03-15 23:31:02 +0300
+++ sudo-1.6.7p2/find_path.c 2003-04-09 14:54:16 +0400
@@ -85,7 +85,7 @@ find_path(infile, outfile, path)
int len; /* length parameter */
if (strlen(infile) >= MAXPATHLEN) {
- (void) fprintf(stderr, "%s: path too long: %s\n", Argv[0], infile);
+ (void) fprintf(stderr, "%s: path too long: %s\n", __progname, infile);
exit(1);
}
@@ -131,7 +131,7 @@ find_path(infile, outfile, path)
*/
len = snprintf(command, sizeof(command), "%s/%s", path, infile);
if (len <= 0 || len >= sizeof(command)) {
- (void) fprintf(stderr, "%s: path too long: %s\n", Argv[0], infile);
+ (void) fprintf(stderr, "%s: path too long: %s\n", __progname, infile);
exit(1);
}
if ((result = sudo_goodpath(command)))
diff -upk.orig sudo-1.6.7p2.orig/interfaces.c sudo-1.6.7p2/interfaces.c
--- sudo-1.6.7p2.orig/interfaces.c 2003-03-15 23:31:02 +0300
+++ sudo-1.6.7p2/interfaces.c 2003-04-09 14:53:22 +0400
@@ -188,7 +188,7 @@ load_interfaces()
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0) {
(void) fprintf(stderr, "%s: cannot open socket: %s\n",
- Argv[0], strerror(errno));
+ __progname, strerror(errno));
exit(1);
}
diff -upk.orig sudo-1.6.7p2.orig/logging.c sudo-1.6.7p2/logging.c
--- sudo-1.6.7p2.orig/logging.c 2003-03-25 00:09:27 +0300
+++ sudo-1.6.7p2/logging.c 2003-04-09 14:53:22 +0400
@@ -107,9 +107,9 @@ mysyslog(pri, fmt, va_alist)
va_start(ap);
#endif
#ifdef LOG_NFACILITIES
- openlog(Argv[0], 0, def_ival(I_LOGFAC));
+ openlog(__progname, 0, def_ival(I_LOGFAC));
#else
- openlog(Argv[0], 0);
+ openlog(__progname, 0);
#endif
vsnprintf(buf, sizeof(buf), fmt, ap);
#ifdef BROKEN_SYSLOG
@@ -400,7 +400,7 @@ log_error(va_alist)
/*
* Tell the user.
*/
- (void) fprintf(stderr, "%s: %s", Argv[0], message);
+ (void) fprintf(stderr, "%s: %s", __progname, message);
if (flags & USE_ERRNO)
(void) fprintf(stderr, ": %s", strerror(serrno));
(void) fputc('\n', stderr);
@@ -461,7 +461,7 @@ send_mail(line)
if (pipe(pfd) == -1) {
(void) fprintf(stderr, "%s: cannot open pipe: %s\n",
- Argv[0], strerror(errno));
+ __progname, strerror(errno));
exit(1);
}
@@ -469,7 +469,7 @@ send_mail(line)
case -1:
/* Error. */
(void) fprintf(stderr, "%s: cannot fork: %s\n",
- Argv[0], strerror(errno));
+ __progname, strerror(errno));
exit(1);
break;
case 0:
diff -upk.orig sudo-1.6.7p2.orig/sudo.c sudo-1.6.7p2/sudo.c
--- sudo-1.6.7p2.orig/sudo.c 2003-04-01 19:02:49 +0400
+++ sudo-1.6.7p2/sudo.c 2003-04-09 15:36:39 +0400
@@ -176,10 +176,13 @@ main(argc, argv, envp)
Argc = argc;
if (geteuid() != 0) {
- (void) fprintf(stderr, "Sorry, %s must be setuid root.\n", Argv[0]);
+ (void) fprintf(stderr, "Sorry, %s must be setuid root.\n", __progname);
exit(1);
}
+ if ( argc < 1 )
+ usage(1);
+
/*
* Signal setup:
* Ignore keyboard-generated signals so the user cannot interrupt
@@ -322,7 +325,7 @@ main(argc, argv, envp)
if (user_uid == 0 && !def_flag(I_ROOT_SUDO)) {
(void) fprintf(stderr,
"Sorry, %s has been configured to not allow root to run it.\n",
- Argv[0]);
+ __progname);
exit(1);
}
@@ -360,10 +363,10 @@ main(argc, argv, envp)
if (validated & VALIDATE_OK) {
/* Finally tell the user if the command did not exist. */
if (cmnd_status == NOT_FOUND_DOT) {
- (void) fprintf(stderr, "%s: ignoring `%s' found in '.'\nUse `sudo ./%s' if this is the `%s' you wish to run.\n", Argv[0], user_cmnd, user_cmnd, user_cmnd);
+ (void) fprintf(stderr, "%s: ignoring `%s' found in '.'\nUse `sudo ./%s' if this is the `%s' you wish to run.\n", __progname, user_cmnd, user_cmnd, user_cmnd);
exit(1);
} else if (cmnd_status == NOT_FOUND) {
- (void) fprintf(stderr, "%s: %s: command not found\n", Argv[0],
+ (void) fprintf(stderr, "%s: %s: command not found\n", __progname,
user_cmnd);
exit(1);
}
@@ -421,7 +424,7 @@ main(argc, argv, envp)
* If we got here then the exec() failed...
*/
(void) fprintf(stderr, "%s: unable to exec %s: %s\n",
- Argv[0], safe_cmnd, strerror(errno));
+ __progname, safe_cmnd, strerror(errno));
exit(127);
} else if ((validated & FLAG_NO_USER) || (validated & FLAG_NO_HOST)) {
log_auth(validated, 1);
@@ -438,10 +441,10 @@ main(argc, argv, envp)
log_auth(validated,
!(cmnd_status == NOT_FOUND_DOT || cmnd_status == NOT_FOUND));
if (cmnd_status == NOT_FOUND)
- (void) fprintf(stderr, "%s: %s: command not found\n", Argv[0],
+ (void) fprintf(stderr, "%s: %s: command not found\n", __progname,
user_cmnd);
else if (cmnd_status == NOT_FOUND_DOT)
- (void) fprintf(stderr, "%s: ignoring `%s' found in '.'\nUse `sudo ./%s' if this is the `%s' you wish to run.\n", Argv[0], user_cmnd, user_cmnd, user_cmnd);
+ (void) fprintf(stderr, "%s: ignoring `%s' found in '.'\nUse `sudo ./%s' if this is the `%s' you wish to run.\n", __progname, user_cmnd, user_cmnd, user_cmnd);
} else {
/* Just tell the user they are not allowed to run foo. */
log_auth(validated, 1);
@@ -468,7 +471,7 @@ init_vars(sudo_mode)
/* Sanity check command from user. */
if (user_cmnd == NULL && strlen(NewArgv[0]) >= MAXPATHLEN) {
- (void) fprintf(stderr, "%s: %s: Pathname too long\n", Argv[0],
+ (void) fprintf(stderr, "%s: %s: Pathname too long\n", __progname,
NewArgv[0]);
exit(1);
}
@@ -555,7 +558,7 @@ init_vars(sudo_mode)
set_perms(PERM_ROOT);
if (!getcwd(user_cwd, sizeof(user_cwd))) {
(void) fprintf(stderr, "%s: Can't get working directory!\n",
- Argv[0]);
+ __progname);
(void) strlcpy(user_cwd, "unknown", sizeof(user_cwd));
}
} else
@@ -572,7 +575,7 @@ init_vars(sudo_mode)
if (user_shell && *user_shell) {
NewArgv[0] = user_shell;
} else {
- (void) fprintf(stderr, "%s: Unable to determine shell.", Argv[0]);
+ (void) fprintf(stderr, "%s: Unable to determine shell.", __progname);
exit(1);
}
@@ -615,7 +618,7 @@ init_vars(sudo_mode)
n = strlcpy(to, *from, size - (to - user_args));
if (n >= size - (to - user_args)) {
(void) fprintf(stderr,
- "%s: internal error, init_vars() overflow\n", Argv[0]);
+ "%s: internal error, init_vars() overflow\n", __progname);
exit(1);
}
to += n;
@@ -649,7 +652,7 @@ parse_args()
while (NewArgc > 0 && NewArgv[0][0] == '-') {
if (NewArgv[0][1] != '\0' && NewArgv[0][2] != '\0') {
(void) fprintf(stderr, "%s: Please use single character options\n",
- Argv[0]);
+ __progname);
usage(1);
}
@@ -771,10 +774,10 @@ parse_args()
return(rval);
case '\0':
(void) fprintf(stderr, "%s: '-' requires an argument\n",
- Argv[0]);
+ __progname);
usage(1);
default:
- (void) fprintf(stderr, "%s: Illegal option %s\n", Argv[0],
+ (void) fprintf(stderr, "%s: Illegal option %s\n", __progname,
NewArgv[0]);
usage(1);
}
@@ -809,21 +812,21 @@ check_sudoers()
if (chmod(_PATH_SUDOERS, SUDOERS_MODE) == 0) {
(void) fprintf(stderr, "%s: fixed mode on %s\n",
- Argv[0], _PATH_SUDOERS);
+ __progname, _PATH_SUDOERS);
statbuf.st_mode |= SUDOERS_MODE;
if (statbuf.st_gid != SUDOERS_GID) {
if (!chown(_PATH_SUDOERS,(uid_t) -1,SUDOERS_GID)) {
(void) fprintf(stderr, "%s: set group on %s\n",
- Argv[0], _PATH_SUDOERS);
+ __progname, _PATH_SUDOERS);
statbuf.st_gid = SUDOERS_GID;
} else {
(void) fprintf(stderr,"%s: Unable to set group on %s: %s\n",
- Argv[0], _PATH_SUDOERS, strerror(errno));
+ __progname, _PATH_SUDOERS, strerror(errno));
}
}
} else {
(void) fprintf(stderr, "%s: Unable to fix mode on %s: %s\n",
- Argv[0], _PATH_SUDOERS, strerror(errno));
+ __progname, _PATH_SUDOERS, strerror(errno));
}
}
@@ -947,7 +950,7 @@ set_loginclass(pw)
if (login_class && strcmp(login_class, "-") != 0) {
if (strcmp(*user_runas, "root") != 0 && user_uid != 0) {
(void) fprintf(stderr, "%s: only root can use -c %s\n",
- Argv[0], login_class);
+ __progname, login_class);
exit(1);
}
} else {
diff -upk.orig sudo-1.6.7p2.orig/sudo.h sudo-1.6.7p2/sudo.h
--- sudo-1.6.7p2.orig/sudo.h 2003-03-15 23:31:02 +0300
+++ sudo-1.6.7p2/sudo.h 2003-04-09 14:53:22 +0400
@@ -250,4 +250,6 @@ extern void (*set_perms) __P((int));
#endif
extern int errno;
+extern const char *__progname;
+
#endif /* _SUDO_SUDO_H */
diff -upk.orig sudo-1.6.7p2.orig/testsudoers.c sudo-1.6.7p2/testsudoers.c
--- sudo-1.6.7p2.orig/testsudoers.c 2003-04-01 19:02:49 +0400
+++ sudo-1.6.7p2/testsudoers.c 2003-04-09 15:44:15 +0400
@@ -361,7 +361,7 @@ main(argc, argv)
NewArgc = Argc - 3;
} else {
(void) fprintf(stderr,
- "usage: %s [-u user] <user> <host> <command> [args]\n", Argv[0]);
+ "usage: %s [-u user] <user> <host> <command> [args]\n", __progname);
exit(1);
}
@@ -387,7 +387,7 @@ main(argc, argv)
n = strlcpy(to, *from, size - (to - user_args));
if (n >= size - (to - user_args)) {
(void) fprintf(stderr,
- "%s: internal error, init_vars() overflow\n", Argv[0]);
+ "%s: internal error, init_vars() overflow\n", __progname);
exit(1);
}
to += n;
diff -upk.orig sudo-1.6.7p2.orig/visudo.c sudo-1.6.7p2/visudo.c
--- sudo-1.6.7p2.orig/visudo.c 2003-03-15 23:31:02 +0300
+++ sudo-1.6.7p2/visudo.c 2003-04-09 15:40:59 +0400
@@ -108,7 +108,6 @@ extern int optind;
/*
* Globals
*/
-char **Argv;
char *sudoers = _PATH_SUDOERS;
char *stmp = _PATH_SUDOERS_TMP;
struct sudo_user sudo_user;
@@ -138,7 +137,8 @@ main(argc, argv)
/*
* Parse command line options
*/
- Argv = argv;
+ if (argc < 1)
+ usage();
/*
* Arg handling.
@@ -175,7 +175,7 @@ main(argc, argv)
user_host = user_shost = user_cmnd = "";
if ((sudo_user.pw = getpwuid(getuid())) == NULL) {
(void) fprintf(stderr, "%s: Can't find you in the passwd database.\n",
- Argv[0]);
+ __progname);
exit(1);
}
@@ -191,13 +191,13 @@ main(argc, argv)
*/
sudoers_fd = open(sudoers, O_RDWR | O_CREAT, SUDOERS_MODE);
if (sudoers_fd == -1) {
- (void) fprintf(stderr, "%s: %s: %s\n", Argv[0], sudoers,
+ (void) fprintf(stderr, "%s: %s: %s\n", __progname, sudoers,
strerror(errno));
exit(1);
}
if (!lock_file(sudoers_fd, SUDO_TLOCK)) {
(void) fprintf(stderr, "%s: sudoers file busy, try again later.\n",
- Argv[0]);
+ __progname);
exit(1);
}
#ifdef HAVE_FSTAT
@@ -206,7 +206,7 @@ main(argc, argv)
if (stat(sudoers, &sudoers_sb) == -1) {
#endif
(void) fprintf(stderr, "%s: can't stat %s: %s\n",
- Argv[0], sudoers, strerror(errno));
+ __progname, sudoers, strerror(errno));
exit(1);
}
@@ -215,7 +215,7 @@ main(argc, argv)
*/
stmp_fd = open(stmp, O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (stmp_fd < 0) {
- (void) fprintf(stderr, "%s: %s: %s\n", Argv[0], stmp, strerror(errno));
+ (void) fprintf(stderr, "%s: %s: %s\n", __progname, stmp, strerror(errno));
exit(1);
}
@@ -226,7 +226,7 @@ main(argc, argv)
if (sudoers_sb.st_size) {
while ((n = read(sudoers_fd, buf, sizeof(buf))) > 0)
if (write(stmp_fd, buf, n) != n) {
- (void) fprintf(stderr, "%s: Write failed: %s\n", Argv[0],
+ (void) fprintf(stderr, "%s: Write failed: %s\n", __progname,
strerror(errno));
Exit(-1);
}
@@ -272,7 +272,7 @@ main(argc, argv)
/* If we are honoring $EDITOR this is a fatal error. */
(void) fprintf(stderr,
"%s: specified editor (%s) doesn't exist!\n",
- Argv[0], UserEditor);
+ __progname, UserEditor);
Exit(-1);
} else {
/* Otherwise, just ignore $EDITOR. */
@@ -296,7 +296,7 @@ main(argc, argv)
if (stat(UserEditor, &user_editor_sb) != 0) {
/* Should never happen since we already checked above. */
(void) fprintf(stderr, "%s: unable to stat editor (%s): %s\n",
- Argv[0], UserEditor, strerror(errno));
+ __progname, UserEditor, strerror(errno));
Exit(-1);
}
EditorPath = estrdup(def_str(I_EDITOR));
@@ -345,7 +345,7 @@ main(argc, argv)
/* Bleah, none of the editors existed! */
if (Editor == NULL || *Editor == '\0') {
(void) fprintf(stderr, "%s: no editor found (editor path = %s)\n",
- Argv[0], def_str(I_EDITOR));
+ __progname, def_str(I_EDITOR));
Exit(-1);
}
}
@@ -383,13 +383,13 @@ main(argc, argv)
if (stat(stmp, &stmp_sb) < 0) {
(void) fprintf(stderr,
"%s: Can't stat temporary file (%s), %s unchanged.\n",
- Argv[0], stmp, sudoers);
+ __progname, stmp, sudoers);
Exit(-1);
}
if (stmp_sb.st_size == 0) {
(void) fprintf(stderr,
"%s: Zero length temporary file (%s), %s unchanged.\n",
- Argv[0], stmp, sudoers);
+ __progname, stmp, sudoers);
Exit(-1);
}
@@ -402,7 +402,7 @@ main(argc, argv)
if (yyin == NULL) {
(void) fprintf(stderr,
"%s: Can't re-open temporary file (%s), %s unchanged.\n",
- Argv[0], stmp, sudoers);
+ __progname, stmp, sudoers);
Exit(-1);
}
@@ -421,13 +421,13 @@ main(argc, argv)
if (yyparse() && parse_error != TRUE) {
(void) fprintf(stderr,
"%s: Failed to parse temporary file (%s), unknown error.\n",
- Argv[0], stmp);
+ __progname, stmp);
parse_error = TRUE;
}
fclose(yyin);
} else {
(void) fprintf(stderr,
- "%s: Editor (%s) failed, %s unchanged.\n", Argv[0],
+ "%s: Editor (%s) failed, %s unchanged.\n", __progname,
Editor, sudoers);
Exit(-1);
}
@@ -452,7 +452,7 @@ main(argc, argv)
*/
if (sudoers_sb.st_mtime != now && sudoers_sb.st_mtime == stmp_sb.st_mtime &&
sudoers_sb.st_size == stmp_sb.st_size) {
- (void) fprintf(stderr, "%s: sudoers file unchanged.\n", Argv[0]);
+ (void) fprintf(stderr, "%s: sudoers file unchanged.\n", __progname);
Exit(0);
}
@@ -463,13 +463,13 @@ main(argc, argv)
if (chown(stmp, SUDOERS_UID, SUDOERS_GID)) {
(void) fprintf(stderr,
"%s: Unable to set (uid, gid) of %s to (%d, %d): %s\n",
- Argv[0], stmp, SUDOERS_UID, SUDOERS_GID, strerror(errno));
+ __progname, stmp, SUDOERS_UID, SUDOERS_GID, strerror(errno));
Exit(-1);
}
if (chmod(stmp, SUDOERS_MODE)) {
(void) fprintf(stderr,
"%s: Unable to change mode of %s to %o: %s\n",
- Argv[0], stmp, SUDOERS_MODE, strerror(errno));
+ __progname, stmp, SUDOERS_MODE, strerror(errno));
Exit(-1);
}
@@ -482,7 +482,7 @@ main(argc, argv)
if (errno == EXDEV) {
(void) fprintf(stderr,
"%s: %s and %s not on the same filesystem, using mv to rename.\n",
- Argv[0], stmp, sudoers);
+ __progname, stmp, sudoers);
/* Build up argument vector for the command */
if ((av[0] = strrchr(_PATH_MV, '/')) != NULL)
@@ -497,12 +497,12 @@ main(argc, argv)
if (run_command(_PATH_MV, av)) {
(void) fprintf(stderr,
"%s: Command failed: '%s %s %s', %s unchanged.\n",
- Argv[0], _PATH_MV, stmp, sudoers, sudoers);
+ __progname, _PATH_MV, stmp, sudoers, sudoers);
Exit(-1);
}
} else {
(void) fprintf(stderr, "%s: Error renaming %s, %s unchanged: %s\n",
- Argv[0], stmp, sudoers, strerror(errno));
+ __progname, stmp, sudoers, strerror(errno));
Exit(-1);
}
}
@@ -638,14 +638,14 @@ run_command(path, argv)
switch (pid = fork()) {
case -1:
(void) fprintf(stderr,
- "%s: unable to run %s: %s\n", Argv[0], path, strerror(errno));
+ "%s: unable to run %s: %s\n", __progname, path, strerror(errno));
Exit(-1);
break; /* NOTREACHED */
case 0:
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
execv(path, argv);
(void) fprintf(stderr,
- "%s: unable to run %s: %s\n", Argv[0], path, strerror(errno));
+ "%s: unable to run %s: %s\n", __progname, path, strerror(errno));
_exit(127);
break; /* NOTREACHED */
}
@@ -669,7 +669,7 @@ check_syntax(quiet)
if ((yyin = fopen(sudoers, "r")) == NULL) {
if (!quiet)
- (void) fprintf(stderr, "%s: unable to open %s: %s\n", Argv[0],
+ (void) fprintf(stderr, "%s: unable to open %s: %s\n", __progname,
sudoers, strerror(errno));
exit(1);
}
@@ -679,7 +679,7 @@ check_syntax(quiet)
if (!quiet)
(void) fprintf(stderr,
"%s: failed to parse %s file, unknown error.\n",
- Argv[0], sudoers);
+ __progname, sudoers);
parse_error = TRUE;
}
if (!quiet){
@@ -707,7 +707,7 @@ Exit(sig)
(void) unlink(stmp);
if (sig > 0) {
- write(STDERR_FILENO, Argv[0], strlen(Argv[0]));
+ write(STDERR_FILENO, __progname, strlen(__progname));
write(STDERR_FILENO, emsg, sizeof(emsg) - 1);
_exit(-sig);
}
@@ -718,6 +718,6 @@ static void
usage()
{
(void) fprintf(stderr, "usage: %s [-c] [-f sudoers] [-q] [-s] [-V]\n",
- Argv[0]);
+ __progname);
exit(1);
}