use setproctitle
This commit is contained in:
parent
e9b31046c9
commit
d7e56d367a
@ -1,8 +1,8 @@
|
||||
# from: @(#)Makefile 5.15 (Berkeley) 7/1/90
|
||||
# $Id: Makefile,v 1.6 1994/03/30 02:50:15 cgd Exp $
|
||||
# $Id: Makefile,v 1.7 1994/04/14 03:15:37 cgd Exp $
|
||||
|
||||
PROG= ftpd
|
||||
CFLAGS+=-I${.CURDIR}/../../usr.bin/ftp -DSETPROCTITLE
|
||||
CFLAGS+=-I${.CURDIR}/../../usr.bin/ftp -DHASSETPROCTITLE
|
||||
SRCS= ftpd.c ftpcmd.c glob.c logwtmp.c popen.c vers.c klogin.c
|
||||
MAN8= ftpd.0
|
||||
CLEANFILES+=ftpcmd.c y.tab.h
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)ftpcmd.y 5.24 (Berkeley) 2/25/91";*/
|
||||
static char rcsid[] = "$Id: ftpcmd.y,v 1.2 1993/08/01 18:30:49 mycroft Exp $";
|
||||
static char rcsid[] = "$Id: ftpcmd.y,v 1.3 1994/04/14 03:15:40 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -875,10 +875,10 @@ yylex()
|
||||
dologout(0);
|
||||
}
|
||||
(void) alarm(0);
|
||||
#ifdef SETPROCTITLE
|
||||
#ifdef HASSETPROCTITLE
|
||||
if (strncasecmp(cbuf, "PASS", 4) != NULL)
|
||||
setproctitle("%s: %s", proctitle, cbuf);
|
||||
#endif /* SETPROCTITLE */
|
||||
#endif /* HASSETPROCTITLE */
|
||||
if ((cp = index(cbuf, '\r'))) {
|
||||
*cp++ = '\n';
|
||||
*cp = '\0';
|
||||
|
@ -39,7 +39,7 @@ char copyright[] =
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)ftpd.c 5.40 (Berkeley) 7/2/91";*/
|
||||
static char rcsid[] = "$Id: ftpd.c,v 1.5 1994/04/06 20:50:05 cgd Exp $";
|
||||
static char rcsid[] = "$Id: ftpd.c,v 1.6 1994/04/14 03:15:41 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -145,11 +145,9 @@ int swaitint = SWAITINT;
|
||||
void lostconn(), myoob();
|
||||
FILE *getdatasock(), *dataconn();
|
||||
|
||||
#ifdef SETPROCTITLE
|
||||
char **Argv = NULL; /* pointer to argument vector */
|
||||
char *LastArgv = NULL; /* end of argv */
|
||||
#ifdef HASSETPROCTITLE
|
||||
char proctitle[BUFSIZ]; /* initial part of title */
|
||||
#endif /* SETPROCTITLE */
|
||||
#endif /* HASSETPROCTITLE */
|
||||
|
||||
main(argc, argv, envp)
|
||||
int argc;
|
||||
@ -181,15 +179,6 @@ main(argc, argv, envp)
|
||||
#endif
|
||||
data_source.sin_port = htons(ntohs(ctrl_addr.sin_port) - 1);
|
||||
debug = 0;
|
||||
#ifdef SETPROCTITLE
|
||||
/*
|
||||
* Save start and extent of argv for setproctitle.
|
||||
*/
|
||||
Argv = argv;
|
||||
while (*envp)
|
||||
envp++;
|
||||
LastArgv = envp[-1] + strlen(envp[-1]);
|
||||
#endif /* SETPROCTITLE */
|
||||
|
||||
argc--, argv++;
|
||||
while (argc > 0 && *argv[0] == '-') {
|
||||
@ -527,21 +516,21 @@ pass(passwd)
|
||||
}
|
||||
if (guest) {
|
||||
reply(230, "Guest login ok, access restrictions apply.");
|
||||
#ifdef SETPROCTITLE
|
||||
#ifdef HASSETPROCTITLE
|
||||
sprintf(proctitle, "%s: anonymous/%.*s", remotehost,
|
||||
sizeof(proctitle) - sizeof(remotehost) -
|
||||
sizeof(": anonymous/"), passwd);
|
||||
setproctitle(proctitle);
|
||||
#endif /* SETPROCTITLE */
|
||||
#endif /* HASSETPROCTITLE */
|
||||
if (logging)
|
||||
syslog(LOG_INFO, "ANONYMOUS FTP LOGIN FROM %s, %s",
|
||||
remotehost, passwd);
|
||||
} else {
|
||||
reply(230, "User %s logged in.", pw->pw_name);
|
||||
#ifdef SETPROCTITLE
|
||||
#ifdef HASSETPROCTITLE
|
||||
sprintf(proctitle, "%s: %s", remotehost, pw->pw_name);
|
||||
setproctitle(proctitle);
|
||||
#endif /* SETPROCTITLE */
|
||||
#endif /* HASSETPROCTITLE */
|
||||
if (logging)
|
||||
syslog(LOG_INFO, "FTP LOGIN FROM %s, %s",
|
||||
remotehost, pw->pw_name);
|
||||
@ -1195,10 +1184,10 @@ dolog(sin)
|
||||
else
|
||||
(void) strncpy(remotehost, inet_ntoa(sin->sin_addr),
|
||||
sizeof (remotehost));
|
||||
#ifdef SETPROCTITLE
|
||||
#ifdef HASSETPROCTITLE
|
||||
sprintf(proctitle, "%s: connected", remotehost);
|
||||
setproctitle(proctitle);
|
||||
#endif /* SETPROCTITLE */
|
||||
#endif /* HASSETPROCTITLE */
|
||||
|
||||
if (logging) {
|
||||
t = time((time_t *) 0);
|
||||
@ -1470,39 +1459,3 @@ send_file_list(whichfiles)
|
||||
data = -1;
|
||||
pdata = -1;
|
||||
}
|
||||
|
||||
#ifdef SETPROCTITLE
|
||||
/*
|
||||
* clobber argv so ps will show what we're doing.
|
||||
* (stolen from sendmail)
|
||||
* warning, since this is usually started from inetd.conf, it
|
||||
* often doesn't have much of an environment or arglist to overwrite.
|
||||
*/
|
||||
|
||||
/*VARARGS1*/
|
||||
setproctitle(fmt, a, b, c)
|
||||
char *fmt;
|
||||
{
|
||||
register char *p, *bp, ch;
|
||||
register int i;
|
||||
char buf[BUFSIZ];
|
||||
|
||||
(void) sprintf(buf, fmt, a, b, c);
|
||||
|
||||
/* make ps print our process name */
|
||||
p = Argv[0];
|
||||
*p++ = '-';
|
||||
|
||||
i = strlen(buf);
|
||||
if (i > LastArgv - p - 2) {
|
||||
i = LastArgv - p - 2;
|
||||
buf[i] = '\0';
|
||||
}
|
||||
bp = buf;
|
||||
while (ch = *bp++)
|
||||
if (ch != '\n' && ch != '\r')
|
||||
*p++ = ch;
|
||||
while (p < LastArgv)
|
||||
*p++ = ' ';
|
||||
}
|
||||
#endif /* SETPROCTITLE */
|
||||
|
@ -42,7 +42,7 @@ char copyright[] =
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)nfsd.c 5.10 (Berkeley) 4/24/91";*/
|
||||
static char rcsid[] = "$Id: nfsd.c,v 1.9 1993/12/05 13:41:07 deraadt Exp $";
|
||||
static char rcsid[] = "$Id: nfsd.c,v 1.10 1994/04/14 03:16:39 cgd Exp $";
|
||||
#endif not lint
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -64,9 +64,6 @@ static char rcsid[] = "$Id: nfsd.c,v 1.9 1993/12/05 13:41:07 deraadt Exp $";
|
||||
#include <nfs/rpcv2.h>
|
||||
#include <nfs/nfsv2.h>
|
||||
|
||||
#include <machine/vmparam.h> /* these are for PS_STRINGS */
|
||||
#include <sys/exec.h>
|
||||
|
||||
/* Global defs */
|
||||
#ifdef DEBUG
|
||||
#define syslog(e, s) fprintf(stderr,(s))
|
||||
@ -79,8 +76,6 @@ struct hadr {
|
||||
struct hadr *ha_next;
|
||||
};
|
||||
struct hadr hphead;
|
||||
char **Argv = NULL; /* pointer to argument vector */
|
||||
char *LastArg = NULL; /* end of argv */
|
||||
void reapchild(),not_nfsserver();;
|
||||
|
||||
/*
|
||||
@ -116,16 +111,6 @@ main(argc, argv, envp)
|
||||
bzero((char *)&msk, sizeof msk);
|
||||
bzero((char *)&mtch, sizeof mtch);
|
||||
|
||||
/*
|
||||
* Save start and extent of argv for setproctitle.
|
||||
*/
|
||||
|
||||
Argv = argv;
|
||||
if (envp == 0 || *envp == 0)
|
||||
envp = argv;
|
||||
while (*envp)
|
||||
envp++;
|
||||
LastArg = envp[-1] + strlen(envp[-1]);
|
||||
while ((opt = getopt(argc, argv, "rt:u:")) != EOF)
|
||||
switch (opt) {
|
||||
case 'r':
|
||||
@ -254,8 +239,7 @@ main(argc, argv, envp)
|
||||
*/
|
||||
for (i = 0; i < udpcnt; i++)
|
||||
if (fork() == 0) {
|
||||
setproctitle("nfsd-udp",
|
||||
(struct sockaddr_in *)NULL);
|
||||
setproctitle("udp");
|
||||
ret = nfssvc(sock, &msk, sizeof(msk),
|
||||
&mtch, sizeof(mtch));
|
||||
if (ret < 0)
|
||||
@ -293,7 +277,7 @@ main(argc, argv, envp)
|
||||
syslog(LOG_ERR, "Can't register with portmap");
|
||||
exit(1);
|
||||
}
|
||||
setproctitle("nfsd-listen", (struct sockaddr_in *)NULL);
|
||||
setproctitle("listen");
|
||||
/*
|
||||
* Loop forever accepting connections and sending the children
|
||||
* into the kernel to service the mounts.
|
||||
@ -322,7 +306,8 @@ main(argc, argv, envp)
|
||||
}
|
||||
if (fork() == 0) {
|
||||
close(sock);
|
||||
setproctitle("nfsd-tcp", &peername);
|
||||
setproctitle("tcp [%s]",
|
||||
inet_ntoa(peername.sin_addr));
|
||||
if (setsockopt(msgsock, SOL_SOCKET,
|
||||
SO_KEEPALIVE, (char *) &on, sizeof(on)) < 0)
|
||||
syslog(LOG_ERR,
|
||||
@ -354,21 +339,6 @@ reapchild()
|
||||
;
|
||||
}
|
||||
|
||||
setproctitle(a, sin)
|
||||
char *a;
|
||||
struct sockaddr_in *sin;
|
||||
{
|
||||
register char *cp;
|
||||
static char buf[80];
|
||||
|
||||
if (sin)
|
||||
(void) sprintf(buf, "%s [%s]", a, inet_ntoa(sin->sin_addr));
|
||||
else
|
||||
(void) sprintf(buf, "%s", a);
|
||||
PS_STRINGS->ps_nargvstr = 1;
|
||||
PS_STRINGS->ps_argvstr = buf;
|
||||
}
|
||||
|
||||
void not_nfsserver()
|
||||
{
|
||||
syslog(LOG_ERR, "not configured as NFS server");
|
||||
|
@ -42,7 +42,7 @@ char copyright[] =
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)nfsd.c 5.10 (Berkeley) 4/24/91";*/
|
||||
static char rcsid[] = "$Id: nfsd.c,v 1.9 1993/12/05 13:41:07 deraadt Exp $";
|
||||
static char rcsid[] = "$Id: nfsd.c,v 1.10 1994/04/14 03:16:39 cgd Exp $";
|
||||
#endif not lint
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -64,9 +64,6 @@ static char rcsid[] = "$Id: nfsd.c,v 1.9 1993/12/05 13:41:07 deraadt Exp $";
|
||||
#include <nfs/rpcv2.h>
|
||||
#include <nfs/nfsv2.h>
|
||||
|
||||
#include <machine/vmparam.h> /* these are for PS_STRINGS */
|
||||
#include <sys/exec.h>
|
||||
|
||||
/* Global defs */
|
||||
#ifdef DEBUG
|
||||
#define syslog(e, s) fprintf(stderr,(s))
|
||||
@ -79,8 +76,6 @@ struct hadr {
|
||||
struct hadr *ha_next;
|
||||
};
|
||||
struct hadr hphead;
|
||||
char **Argv = NULL; /* pointer to argument vector */
|
||||
char *LastArg = NULL; /* end of argv */
|
||||
void reapchild(),not_nfsserver();;
|
||||
|
||||
/*
|
||||
@ -116,16 +111,6 @@ main(argc, argv, envp)
|
||||
bzero((char *)&msk, sizeof msk);
|
||||
bzero((char *)&mtch, sizeof mtch);
|
||||
|
||||
/*
|
||||
* Save start and extent of argv for setproctitle.
|
||||
*/
|
||||
|
||||
Argv = argv;
|
||||
if (envp == 0 || *envp == 0)
|
||||
envp = argv;
|
||||
while (*envp)
|
||||
envp++;
|
||||
LastArg = envp[-1] + strlen(envp[-1]);
|
||||
while ((opt = getopt(argc, argv, "rt:u:")) != EOF)
|
||||
switch (opt) {
|
||||
case 'r':
|
||||
@ -254,8 +239,7 @@ main(argc, argv, envp)
|
||||
*/
|
||||
for (i = 0; i < udpcnt; i++)
|
||||
if (fork() == 0) {
|
||||
setproctitle("nfsd-udp",
|
||||
(struct sockaddr_in *)NULL);
|
||||
setproctitle("udp");
|
||||
ret = nfssvc(sock, &msk, sizeof(msk),
|
||||
&mtch, sizeof(mtch));
|
||||
if (ret < 0)
|
||||
@ -293,7 +277,7 @@ main(argc, argv, envp)
|
||||
syslog(LOG_ERR, "Can't register with portmap");
|
||||
exit(1);
|
||||
}
|
||||
setproctitle("nfsd-listen", (struct sockaddr_in *)NULL);
|
||||
setproctitle("listen");
|
||||
/*
|
||||
* Loop forever accepting connections and sending the children
|
||||
* into the kernel to service the mounts.
|
||||
@ -322,7 +306,8 @@ main(argc, argv, envp)
|
||||
}
|
||||
if (fork() == 0) {
|
||||
close(sock);
|
||||
setproctitle("nfsd-tcp", &peername);
|
||||
setproctitle("tcp [%s]",
|
||||
inet_ntoa(peername.sin_addr));
|
||||
if (setsockopt(msgsock, SOL_SOCKET,
|
||||
SO_KEEPALIVE, (char *) &on, sizeof(on)) < 0)
|
||||
syslog(LOG_ERR,
|
||||
@ -354,21 +339,6 @@ reapchild()
|
||||
;
|
||||
}
|
||||
|
||||
setproctitle(a, sin)
|
||||
char *a;
|
||||
struct sockaddr_in *sin;
|
||||
{
|
||||
register char *cp;
|
||||
static char buf[80];
|
||||
|
||||
if (sin)
|
||||
(void) sprintf(buf, "%s [%s]", a, inet_ntoa(sin->sin_addr));
|
||||
else
|
||||
(void) sprintf(buf, "%s", a);
|
||||
PS_STRINGS->ps_nargvstr = 1;
|
||||
PS_STRINGS->ps_argvstr = buf;
|
||||
}
|
||||
|
||||
void not_nfsserver()
|
||||
{
|
||||
syslog(LOG_ERR, "not configured as NFS server");
|
||||
|
Loading…
Reference in New Issue
Block a user