summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pppctl/pppctl.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2000-08-16 12:01:17 +0000
committerbrian <brian@FreeBSD.org>2000-08-16 12:01:17 +0000
commitf03fa7361a140ebdac73e27f74b139d0a3d95bf5 (patch)
treeb194049e8afaf4c449151d0359f7f5e4f11977e9 /usr.sbin/pppctl/pppctl.c
parent0a28a3436ddef5b200270a23d8de395cef74d655 (diff)
downloadFreeBSD-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/pppctl.c')
-rw-r--r--usr.sbin/pppctl/pppctl.c37
1 files changed, 35 insertions, 2 deletions
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;
OpenPOWER on IntegriCloud