summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-11-17 21:12:35 +0000
committerbrian <brian@FreeBSD.org>1999-11-17 21:12:35 +0000
commit23eed7f7102ef9456a9439cb6bc98763c375d65b (patch)
treee9a6cb680ab641034bfd98b66123c4e69198cbfe /usr.sbin
parenta6dfb66b8f373dfb4e877586559df92a05a6cea1 (diff)
downloadFreeBSD-src-23eed7f7102ef9456a9439cb6bc98763c375d65b.zip
FreeBSD-src-23eed7f7102ef9456a9439cb6bc98763c375d65b.tar.gz
Fix ``set proctitle'' by using setproctitle().
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/bundle.c14
-rw-r--r--usr.sbin/ppp/bundle.h5
-rw-r--r--usr.sbin/ppp/command.c12
-rw-r--r--usr.sbin/ppp/id.c14
-rw-r--r--usr.sbin/ppp/id.h1
-rw-r--r--usr.sbin/ppp/main.c8
6 files changed, 34 insertions, 20 deletions
diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c
index dcc07f2..18a0ff1 100644
--- a/usr.sbin/ppp/bundle.c
+++ b/usr.sbin/ppp/bundle.c
@@ -39,6 +39,11 @@
#include <errno.h>
#include <fcntl.h>
+#ifdef __OpenBSD__
+#include <util.h>
+#else
+#include <libutil.h>
+#endif
#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
@@ -603,7 +608,7 @@ bundle_UnlockTun(struct bundle *bundle)
}
struct bundle *
-bundle_Create(const char *prefix, int type, int unit, const char **argv)
+bundle_Create(const char *prefix, int type, int unit)
{
static struct bundle bundle; /* there can be only one */
int enoentcount, err, minunit, maxunit;
@@ -673,9 +678,6 @@ bundle_Create(const char *prefix, int type, int unit, const char **argv)
}
log_SetTun(bundle.unit);
- bundle.argv = argv;
- bundle.argv0 = argv[0];
- bundle.argv1 = argv[1];
ifname = strrchr(bundle.dev.Name, '/');
if (ifname == NULL)
@@ -1097,7 +1099,6 @@ bundle_ShowStatus(struct cmdargs const *arg)
int remaining;
prompt_Printf(arg->prompt, "Phase %s\n", bundle_PhaseName(arg->bundle));
- prompt_Printf(arg->prompt, " Title: %s\n", arg->bundle->argv[0]);
prompt_Printf(arg->prompt, " Device: %s\n", arg->bundle->dev.Name);
prompt_Printf(arg->prompt, " Interface: %s @ %lubps",
arg->bundle->iface->name, arg->bundle->bandwidth);
@@ -1660,8 +1661,7 @@ bundle_setsid(struct bundle *bundle, int holdsession)
*/
waitpid(pid, &status, 0);
/* Tweak our process arguments.... */
- bundle->argv[0] = "session owner";
- bundle->argv[1] = NULL;
+ ID0setproctitle("session owner");
/*
* Hang around for a HUP. This should happen as soon as the
* ppp that we passed our ctty descriptor to closes it.
diff --git a/usr.sbin/ppp/bundle.h b/usr.sbin/ppp/bundle.h
index b2e59ce..a56860b 100644
--- a/usr.sbin/ppp/bundle.h
+++ b/usr.sbin/ppp/bundle.h
@@ -63,9 +63,6 @@ struct iface;
struct bundle {
struct descriptor desc; /* really all our datalinks */
int unit; /* The device/interface unit number */
- const char **argv; /* From main() */
- const char *argv0; /* Original */
- const char *argv1; /* Original */
struct {
char Name[20]; /* The /dev/XXXX name */
@@ -142,7 +139,7 @@ struct bundle {
#define descriptor2bundle(d) \
((d)->type == BUNDLE_DESCRIPTOR ? (struct bundle *)(d) : NULL)
-extern struct bundle *bundle_Create(const char *, int, int, const char **);
+extern struct bundle *bundle_Create(const char *, int, int);
extern void bundle_Destroy(struct bundle *);
extern const char *bundle_PhaseName(struct bundle *);
#define bundle_Phase(b) ((b)->phase)
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index 47a83e0..4096597 100644
--- a/usr.sbin/ppp/command.c
+++ b/usr.sbin/ppp/command.c
@@ -33,6 +33,11 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
+#ifdef __OpenBSD__
+#include <util.h>
+#else
+#include <libutil.h>
+#endif
#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
@@ -87,6 +92,7 @@
#include "cbcp.h"
#include "datalink.h"
#include "iface.h"
+#include "id.h"
/* ``set'' values */
#define VAR_AUTHKEY 0
@@ -2609,8 +2615,7 @@ SetProcTitle(struct cmdargs const *arg)
int len, remaining, f, argc = arg->argc - arg->argn;
if (arg->argc == arg->argn) {
- arg->bundle->argv[0] = arg->bundle->argv0;
- arg->bundle->argv[1] = arg->bundle->argv1;
+ ID0setproctitle(NULL);
return 0;
}
@@ -2636,8 +2641,7 @@ SetProcTitle(struct cmdargs const *arg)
}
*ptr = '\0';
- arg->bundle->argv[0] = title;
- arg->bundle->argv[1] = NULL;
+ ID0setproctitle(title);
return 0;
}
diff --git a/usr.sbin/ppp/id.c b/usr.sbin/ppp/id.c
index 06aad02..0d15c92 100644
--- a/usr.sbin/ppp/id.c
+++ b/usr.sbin/ppp/id.c
@@ -269,6 +269,20 @@ ID0kill(pid_t pid, int sig)
return result;
}
+void
+ID0setproctitle(const char *title)
+{
+ ID0set0();
+ if (title == NULL) {
+ setproctitle(NULL);
+ log_Printf(LogID0, "setproctitle(NULL)\n");
+ } else {
+ setproctitle("%s", title);
+ log_Printf(LogID0, "setproctitle(\"%%s\", \"%s\")\n", title);
+ }
+ ID0setuser();
+}
+
#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
int
ID0kldload(const char *dev)
diff --git a/usr.sbin/ppp/id.h b/usr.sbin/ppp/id.h
index 3254f64..57344cf 100644
--- a/usr.sbin/ppp/id.h
+++ b/usr.sbin/ppp/id.h
@@ -45,6 +45,7 @@ extern void ID0logout(const char *, int);
extern int ID0bind_un(int, const struct sockaddr_un *);
extern int ID0connect_un(int, const struct sockaddr_un *);
extern int ID0kill(pid_t, int);
+extern void ID0setproctitle(const char *);
#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
extern int ID0kldload(const char *);
#endif
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index cbe0f55..a108f93 100644
--- a/usr.sbin/ppp/main.c
+++ b/usr.sbin/ppp/main.c
@@ -367,8 +367,7 @@ main(int argc, char **argv)
if (!sw.quiet)
prompt_Printf(prompt, "Working in %s mode\n", mode2Nam(sw.mode));
- if ((bundle = bundle_Create(TUN_PREFIX, sw.mode, sw.unit,
- (const char **)argv)) == NULL)
+ if ((bundle = bundle_Create(TUN_PREFIX, sw.mode, sw.unit)) == NULL)
return EX_START;
/* NOTE: We may now have changed argv[1] via a ``set proctitle'' */
@@ -398,12 +397,11 @@ main(int argc, char **argv)
sig_signal(SIGUSR2, BringDownServer);
- lastlabel = argc == 2 ? bundle->argv1 : argv[argc - 1];
+ lastlabel = argv[argc - 1];
for (arg = label; arg < argc; arg++) {
/* In case we use LABEL or ``set enddisc label'' */
bundle_SetLabel(bundle, lastlabel);
- system_Select(bundle, arg == 1 ? bundle->argv1 : argv[arg],
- CONFFILE, prompt, NULL);
+ system_Select(bundle, argv[arg], CONFFILE, prompt, NULL);
}
if (label < argc)
OpenPOWER on IntegriCloud