summaryrefslogtreecommitdiff
path: root/usr/src/cmd/pfexec/pfexec.c
diff options
context:
space:
mode:
authorGary Mills <gary_mills@fastmail.fm>2014-06-18 15:22:57 -0500
committerRobert Mustacchi <rm@joyent.com>2014-06-21 10:24:43 -0700
commit511ef1d6e74f3d1db7bd854375a0926d87bdd7e6 (patch)
tree086e2d985dd7270879d787e4126519a941555add /usr/src/cmd/pfexec/pfexec.c
parentd13ebad84494334e3654def3c0634c4bcc8e4b18 (diff)
downloadillumos-joyent-511ef1d6e74f3d1db7bd854375a0926d87bdd7e6.tar.gz
4577 pfexec's error reporting is (at least sometimes) awful
Reviewed by: Jason King <jason.brian.king@gmail.com> Reviewed by: Adam Števko <adam.stevko@gmail.com> Approved by: Robert Mustacchi <rm@joyent.com>
Diffstat (limited to 'usr/src/cmd/pfexec/pfexec.c')
-rw-r--r--usr/src/cmd/pfexec/pfexec.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/usr/src/cmd/pfexec/pfexec.c b/usr/src/cmd/pfexec/pfexec.c
index a0025d26a7..f06e1c3806 100644
--- a/usr/src/cmd/pfexec/pfexec.c
+++ b/usr/src/cmd/pfexec/pfexec.c
@@ -19,6 +19,7 @@
* CDDL HEADER END
*/
/*
+ * Copyright 2014 Gary Mills
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
*/
@@ -102,7 +103,9 @@ main(int argc, char **argv)
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);
}
@@ -126,7 +129,9 @@ main(int argc, char **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:
@@ -148,18 +153,26 @@ main(int argc, char **argv)
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);