From f03fa7361a140ebdac73e27f74b139d0a3d95bf5 Mon Sep 17 00:00:00 2001 From: brian Date: Wed, 16 Aug 2000 12:01:17 +0000 Subject: If the -p option is used, use setproctitle() to hide it's argument (a password) asap. --- usr.sbin/pppctl/Makefile | 4 ++-- usr.sbin/pppctl/pppctl.c | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) (limited to 'usr.sbin/pppctl') 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 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 #include #include +#ifdef __FreeBSD__ +#include +#endif #include #include #include @@ -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; -- cgit v1.1