diff options
author | David Schultz <das@FreeBSD.org> | 2003-03-17 02:12:55 +0000 |
---|---|---|
committer | David Schultz <das@FreeBSD.org> | 2003-03-17 02:12:55 +0000 |
commit | 169a7d34d53c0da1ef60b70fd97982f42a9556ba (patch) | |
tree | 516862311cbf2963c0d9f77d0bfecec4b8513609 /libutil/pw_util.c | |
parent | 4402a69620f91c7fa98ca7ea0289134f34b62dd2 (diff) | |
download | pw-darwin-169a7d34d53c0da1ef60b70fd97982f42a9556ba.tar.gz pw-darwin-169a7d34d53c0da1ef60b70fd97982f42a9556ba.tar.zst pw-darwin-169a7d34d53c0da1ef60b70fd97982f42a9556ba.zip |
Make pw_edit() use /bin/sh to interpret the EDITOR environment
variable.
PR: 48748
Reviewed by: mike (mentor)
Diffstat (limited to 'libutil/pw_util.c')
-rw-r--r-- | libutil/pw_util.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libutil/pw_util.c b/libutil/pw_util.c index d219917..5eb0953 100644 --- a/libutil/pw_util.c +++ b/libutil/pw_util.c @@ -62,7 +62,6 @@ static const char rcsid[] = #include <ctype.h> #include <fcntl.h> #include <inttypes.h> -#include <libgen.h> #include <paths.h> #include <pwd.h> #include <signal.h> @@ -290,6 +289,8 @@ pw_edit(int notsetuid) { struct stat st1, st2; const char *editor; + char *editcmd; + int editcmdlen; int pstat; if ((editor = getenv("EDITOR")) == NULL) @@ -305,8 +306,17 @@ pw_edit(int notsetuid) (void)setgid(getgid()); (void)setuid(getuid()); } + if ((editcmdlen = sysconf(_SC_ARG_MAX) - 6) <= 0 || + (editcmd = malloc(editcmdlen)) == NULL) + _exit(EXIT_FAILURE); + if (snprintf(editcmd, editcmdlen, "%s %s", + editor, tempname) >= editcmdlen) { + free(editcmd); /* pedantry */ + _exit(EXIT_FAILURE); + } errno = 0; - execlp(editor, basename(editor), tempname, NULL); + execl(_PATH_BSHELL, "sh", "-c", editcmd, NULL); + free(editcmd); _exit(errno); default: /* parent */ |