diff options
author | brian <brian@FreeBSD.org> | 2000-08-16 12:01:17 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2000-08-16 12:01:17 +0000 |
commit | f03fa7361a140ebdac73e27f74b139d0a3d95bf5 (patch) | |
tree | b194049e8afaf4c449151d0359f7f5e4f11977e9 /usr.sbin/pppctl | |
parent | 0a28a3436ddef5b200270a23d8de395cef74d655 (diff) | |
download | FreeBSD-src-f03fa7361a140ebdac73e27f74b139d0a3d95bf5.zip FreeBSD-src-f03fa7361a140ebdac73e27f74b139d0a3d95bf5.tar.gz |
If the -p option is used, use setproctitle() to hide it's argument
(a password) asap.
Diffstat (limited to 'usr.sbin/pppctl')
-rw-r--r-- | usr.sbin/pppctl/Makefile | 4 | ||||
-rw-r--r-- | usr.sbin/pppctl/pppctl.c | 37 |
2 files changed, 37 insertions, 4 deletions
diff --git a/usr.sbin/pppctl/Makefile b/usr.sbin/pppctl/Makefile index 718d2f76..c20adad 100644 --- a/usr.sbin/pppctl/Makefile +++ b/usr.sbin/pppctl/Makefile @@ -3,8 +3,8 @@ PROG= pppctl SRCS= pppctl.c CFLAGS+=-Wall -LDADD+= -ledit -ltermcap -DPADD+= ${LIBEDIT} ${LIBTERMCAP} +LDADD+= -ledit -ltermcap -lutil +DPADD+= ${LIBEDIT} ${LIBTERMCAP} ${LIBUTIL} MAN8= pppctl.8 .include <bsd.prog.mk> diff --git a/usr.sbin/pppctl/pppctl.c b/usr.sbin/pppctl/pppctl.c index 7cb649e..ef6b414 100644 --- a/usr.sbin/pppctl/pppctl.c +++ b/usr.sbin/pppctl/pppctl.c @@ -38,6 +38,9 @@ #include <err.h> #include <errno.h> #include <histedit.h> +#ifdef __FreeBSD__ +#include <libutil.h> +#endif #include <setjmp.h> #include <signal.h> #include <stdio.h> @@ -199,13 +202,14 @@ main(int argc, char **argv) struct sockaddr *sock; struct sockaddr_in ifsin; struct sockaddr_un ifsun; - int socksz, arg, fd, len, verbose, save_errno; + int socksz, arg, fd, len, verbose, save_errno, hide1, hide1off, hide2; unsigned TimeoutVal; char *DoneWord = "x", *next, *start; struct sigaction act, oact; verbose = 0; TimeoutVal = 2; + hide1 = hide1off = hide2 = 0; for (arg = 1; arg < argc; arg++) if (*argv[arg] == '-') { @@ -222,7 +226,16 @@ main(int argc, char **argv) break; case 'p': - passwd = (start[1] ? start + 1 : argv[++arg]); + if (start[1]) { + hide1 = arg; + hide1off = start - argv[arg]; + passwd = start + 1; + } else { + hide1 = arg; + hide1off = start - argv[arg]; + passwd = argv[++arg]; + hide2 = arg; + } start = DoneWord; break; @@ -237,6 +250,26 @@ main(int argc, char **argv) if (argc < arg + 1) usage(); + if (hide1) { + char title[1024]; + int pos, harg; + + for (harg = pos = 0; harg < argc; harg++) + if (harg == 0 || harg != hide2) { + if (harg == 0 || harg != hide1) + pos += snprintf(title + pos, sizeof title - pos, "%s%s", + harg ? " " : "", argv[harg]); + else if (hide1off > 1) + pos += snprintf(title + pos, sizeof title - pos, " %.*s", + hide1off, argv[harg]); + } +#ifdef __FreeBSD__ + setproctitle("-%s", title); +#else + setproctitle("%s", title); +#endif + } + if (*argv[arg] == '/') { sock = (struct sockaddr *)&ifsun; socksz = sizeof ifsun; |