Print this page
4577 pfexec's error reporting is (at least sometimes) awful
@@ -17,10 +17,11 @@
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
+ * Copyright 2014 Gary Mills
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
* New implementation of pfexec(1) and all of the profile shells.
@@ -100,11 +101,13 @@
priv_set_t *wanted;
int oflag;
oflag = getpflags(PRIV_PFEXEC);
if (setpflags(PRIV_PFEXEC, 1) != 0) {
- perror("setpflags(PRIV_PFEXEC)");
+ (void) fprintf(stderr,
+ gettext("pfexec: unable to set PFEXEC flag: %s\n"),
+ strerror(errno));
exit(1);
}
if (*argv[0] == '-')
cmd = argv[0] + 1;
@@ -124,11 +127,13 @@
(void) execv(pathbuf, argv);
switch (shellname(cmd, pathbuf)) {
case RES_OK:
(void) execv(pathbuf, argv);
- perror(pathbuf);
+ (void) fprintf(stderr,
+ gettext("pfexec: unable to execute %s: %s\n"),
+ pathbuf, strerror(errno));
return (1);
case RES_PFEXEC:
case RES_FAILURE:
while ((c = getopt(argc, argv, "P:")) != EOF) {
switch (c) {
@@ -146,21 +151,29 @@
argv += optind;
if (argc < 1)
usage();
if (pset != NULL) {
- wanted = priv_str_to_set(pset, ",", NULL);
+ if ((wanted = priv_str_to_set(pset, ",", NULL)) ==
+ NULL) {
+ (void) fprintf(stderr,
+ gettext("pfexec: error parsing "
+ "privileges: %s\n"), strerror(errno));
+ exit(EXIT_FAILURE);
+ }
if (setppriv(PRIV_ON, PRIV_INHERITABLE, wanted) != 0) {
(void) fprintf(stderr,
- gettext("setppriv(): %s\n"),
- strerror(errno));
+ gettext("pfexec: error setting "
+ "privileges: %s\n"), strerror(errno));
exit(EXIT_FAILURE);
}
(void) setpflags(PRIV_PFEXEC, oflag);
}
(void) execvp(argv[0], argv);
- perror(argv[0]);
+ (void) fprintf(stderr,
+ gettext("pfexec: unable to execute %s: %s\n"),
+ argv[0], strerror(errno));
return (1);
}
return (1);
}