summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-01-01 08:42:23 +0000
committerpeter <peter@FreeBSD.org>1996-01-01 08:42:23 +0000
commiteb8e89ecaf8d5bf63b246f1a592f7eed946aff7a (patch)
tree2acd911d5c23af222fa71003a7c8eeaadcff9a34 /usr.sbin
parentae296d31817ed7ad9749e5dcab3f2690d03dcb9c (diff)
downloadFreeBSD-src-eb8e89ecaf8d5bf63b246f1a592f7eed946aff7a.zip
FreeBSD-src-eb8e89ecaf8d5bf63b246f1a592f7eed946aff7a.tar.gz
Make inetd use setproctitle from libutil instead of it's own version.
The old code can probably still be compiled with #define OLD_SETPROCTITLE
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/inetd/Makefile3
-rw-r--r--usr.sbin/inetd/inetd.c37
2 files changed, 35 insertions, 5 deletions
diff --git a/usr.sbin/inetd/Makefile b/usr.sbin/inetd/Makefile
index 0eecd6b..7cb6c05 100644
--- a/usr.sbin/inetd/Makefile
+++ b/usr.sbin/inetd/Makefile
@@ -4,4 +4,7 @@ PROG= inetd
MAN8= inetd.8
MLINKS= inetd.8 inetd.conf.5
+DPADD+= ${LIBUTIL}
+LDADD+= -lutil
+
.include <bsd.prog.mk>
diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c
index 1f85655..c91f608 100644
--- a/usr.sbin/inetd/inetd.c
+++ b/usr.sbin/inetd/inetd.c
@@ -40,7 +40,7 @@ static char copyright[] =
#ifndef lint
/* from: @(#)inetd.c 8.4 (Berkeley) 4/13/94"; */
static char inetd_c_rcsid[] =
- "$Id: inetd.c,v 1.8 1995/10/30 14:03:00 adam Exp $";
+ "$Id: inetd.c,v 1.9 1995/11/03 09:30:13 peter Exp $";
#endif /* not lint */
/*
@@ -123,6 +123,7 @@ static char inetd_c_rcsid[] =
#include <string.h>
#include <syslog.h>
#include <unistd.h>
+#include <libutil.h>
#include "pathnames.h"
@@ -237,8 +238,11 @@ struct biltin {
#define NUMINT (sizeof(intab) / sizeof(struct inent))
char *CONFIG = _PATH_INETDCONF;
+
+#ifdef OLD_SETPROCTITLE
char **Argv;
char *LastArg;
+#endif
int
main(argc, argv, envp)
@@ -254,12 +258,15 @@ main(argc, argv, envp)
struct sockaddr_in peer;
int i;
+
+#ifdef OLD_SETPROCTITLE
Argv = argv;
if (envp == 0 || *envp == 0)
envp = argv;
while (*envp)
envp++;
LastArg = envp[-1] + strlen(envp[-1]);
+#endif
openlog("inetd", LOG_PID | LOG_NOWAIT, LOG_DAEMON);
@@ -1082,8 +1089,9 @@ newstr(cp)
exit(-1);
}
+#ifdef OLD_SETPROCTITLE
void
-setproctitle(a, s)
+inetd_setproctitle(a, s)
char *a;
int s;
{
@@ -1103,6 +1111,25 @@ setproctitle(a, s)
while (cp < LastArg)
*cp++ = ' ';
}
+#else
+void
+inetd_setproctitle(a, s)
+ char *a;
+ int s;
+{
+ int size;
+ struct sockaddr_in sin;
+ char buf[80];
+
+ size = sizeof(sin);
+ if (getpeername(s, (struct sockaddr *)&sin, &size) == 0)
+ (void) sprintf(buf, "%s [%s]", a, inet_ntoa(sin.sin_addr));
+ else
+ (void) sprintf(buf, "%s", a);
+ setproctitle("%s", buf);
+}
+#endif
+
/*
* Internet services provided internally by inetd:
@@ -1118,7 +1145,7 @@ echo_stream(s, sep) /* Echo service -- echo data back */
char buffer[BUFSIZE];
int i;
- setproctitle(sep->se_service, s);
+ inetd_setproctitle(sep->se_service, s);
while ((i = read(s, buffer, sizeof(buffer))) > 0 &&
write(s, buffer, i) > 0)
;
@@ -1178,7 +1205,7 @@ discard_stream(s, sep) /* Discard service -- ignore data */
int ret;
char buffer[BUFSIZE];
- setproctitle(sep->se_service, s);
+ inetd_setproctitle(sep->se_service, s);
while (1) {
while ((ret = read(s, buffer, sizeof(buffer))) > 0)
;
@@ -1225,7 +1252,7 @@ chargen_stream(s, sep) /* Character generator */
int len;
char *rs, text[LINESIZ+2];
- setproctitle(sep->se_service, s);
+ inetd_setproctitle(sep->se_service, s);
if (!endring) {
initring();
OpenPOWER on IntegriCloud