summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>2000-08-16 12:02:41 +0000
committerbrian <brian@cvs.openbsd.org>2000-08-16 12:02:41 +0000
commitbcea310294e7d6d3a67a5bff4be1d5bee0b3f82d (patch)
treee9853642fd77e27c6c554b919f9e5da19651da78 /usr.sbin
parent5a81138aa7cd6e24f34a387f1b58344b1b4d7030 (diff)
If the -p option is used, use setproctitle() to hide it's argument
(a password) asap.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/pppctl/pppctl.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/usr.sbin/ppp/pppctl/pppctl.c b/usr.sbin/ppp/pppctl/pppctl.c
index a8cabbb7bf5..a5c2d4dc7d4 100644
--- a/usr.sbin/ppp/pppctl/pppctl.c
+++ b/usr.sbin/ppp/pppctl/pppctl.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: pppctl.c,v 1.4 1999/08/02 17:00:25 brian Exp $
+ * $Id: pppctl.c,v 1.5 2000/08/16 12:02:40 brian Exp $
*/
#include <sys/types.h>
@@ -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;