summaryrefslogtreecommitdiff
path: root/libexec/ftpd
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1999-12-03 01:22:47 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1999-12-03 01:22:47 +0000
commit01f2a4d5770ee5ed88d26147c538b7319fb1f81c (patch)
tree195b397402923aea30f7e53102314121b624728b /libexec/ftpd
parentad56ffb686058ef528fd3022c420218ad8e8ba88 (diff)
Write pid to /var/run/ftpd.pid if running in daemon mode.
Diffstat (limited to 'libexec/ftpd')
-rw-r--r--libexec/ftpd/ftpd.86
-rw-r--r--libexec/ftpd/ftpd.c40
-rw-r--r--libexec/ftpd/pathnames.h3
3 files changed, 30 insertions, 19 deletions
diff --git a/libexec/ftpd/ftpd.8 b/libexec/ftpd/ftpd.8
index c29b7f83790..bf300beddcf 100644
--- a/libexec/ftpd/ftpd.8
+++ b/libexec/ftpd/ftpd.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ftpd.8,v 1.25 1999/09/30 08:28:52 downsj Exp $
+.\" $OpenBSD: ftpd.8,v 1.26 1999/12/03 01:22:46 millert Exp $
.\" $NetBSD: ftpd.8,v 1.8 1996/01/14 20:55:23 thorpej Exp $
.\"
.\" Copyright (c) 1985, 1988, 1991, 1993
@@ -410,7 +410,7 @@ with other
.Nm ftpd
implementations.
.Sh FILES
-.Bl -tag -width /etc/ftpwelcome -compact
+.Bl -tag -width /var/run/ftpd.pid -compact
.It Pa /etc/ftpusers
List of unwelcome/restricted users.
.It Pa /etc/ftpchroot
@@ -423,6 +423,8 @@ Welcome notice after login.
Displayed and access refused.
.It Pa /var/run/utmp
List of users on the system.
+.It Pa /var/run/ftpd.pid
+Process id if running in daemon mode.
.It Pa /var/log/ftpd
Log file for anonymous downloads.
.El
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index 4e3e30fd77b..23a1120a08a 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftpd.c,v 1.61 1999/12/02 17:34:08 millert Exp $ */
+/* $OpenBSD: ftpd.c,v 1.62 1999/12/03 01:22:46 millert Exp $ */
/* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */
/*
@@ -260,7 +260,7 @@ main(argc, argv, envp)
{
int addrlen, ch, on = 1, tos;
char *cp, line[LINE_MAX];
- FILE *fd;
+ FILE *fp;
struct hostent *hp;
tzset(); /* in case no timezone database in ~ftp */
@@ -393,6 +393,14 @@ main(argc, argv, envp)
syslog(LOG_ERR, "control listen: %m");
exit(1);
}
+ /* Stash pid in pidfile */
+ if ((fp = fopen(_PATH_FTPDPID, "w")) == NULL)
+ syslog(LOG_ERR, "can't open %s: %m", _PATH_FTPDPID);
+ else {
+ fprintf(fp, "%d\n", getpid());
+ fchmod(fileno(fp), S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
+ fclose(fp);
+ }
/*
* Loop forever accepting connection requests and forking off
* children to handle them.
@@ -471,25 +479,25 @@ main(argc, argv, envp)
tmpline[0] = '\0';
/* If logins are disabled, print out the message. */
- if ((fd = fopen(_PATH_NOLOGIN,"r")) != NULL) {
- while (fgets(line, sizeof(line), fd) != NULL) {
+ if ((fp = fopen(_PATH_NOLOGIN, "r")) != NULL) {
+ while (fgets(line, sizeof(line), fp) != NULL) {
if ((cp = strchr(line, '\n')) != NULL)
*cp = '\0';
lreply(530, "%s", line);
}
(void) fflush(stdout);
- (void) fclose(fd);
+ (void) fclose(fp);
reply(530, "System not available.");
exit(0);
}
- if ((fd = fopen(_PATH_FTPWELCOME, "r")) != NULL) {
- while (fgets(line, sizeof(line), fd) != NULL) {
+ if ((fp = fopen(_PATH_FTPWELCOME, "r")) != NULL) {
+ while (fgets(line, sizeof(line), fp) != NULL) {
if ((cp = strchr(line, '\n')) != NULL)
*cp = '\0';
lreply(220, "%s", line);
}
(void) fflush(stdout);
- (void) fclose(fd);
+ (void) fclose(fp);
/* reply(220,) must follow */
}
(void) gethostname(hostname, sizeof(hostname));
@@ -694,12 +702,12 @@ checkuser(fname, name)
char *fname;
char *name;
{
- FILE *fd;
+ FILE *fp;
int found = 0;
char *p, line[BUFSIZ];
- if ((fd = fopen(fname, "r")) != NULL) {
- while (fgets(line, sizeof(line), fd) != NULL)
+ if ((fp = fopen(fname, "r")) != NULL) {
+ while (fgets(line, sizeof(line), fp) != NULL)
if ((p = strchr(line, '\n')) != NULL) {
*p = '\0';
if (line[0] == '#')
@@ -709,7 +717,7 @@ checkuser(fname, name)
break;
}
}
- (void) fclose(fd);
+ (void) fclose(fp);
}
return (found);
}
@@ -741,7 +749,7 @@ pass(passwd)
char *passwd;
{
int rval;
- FILE *fd;
+ FILE *fp;
static char homedir[MAXPATHLEN];
char rootdir[MAXPATHLEN];
sigset_t allsigs;
@@ -894,16 +902,16 @@ skip:
* Display a login message, if it exists.
* N.B. reply(230,) must follow the message.
*/
- if ((fd = fopen(_PATH_FTPLOGINMESG, "r")) != NULL) {
+ if ((fp = fopen(_PATH_FTPLOGINMESG, "r")) != NULL) {
char *cp, line[LINE_MAX];
- while (fgets(line, sizeof(line), fd) != NULL) {
+ while (fgets(line, sizeof(line), fp) != NULL) {
if ((cp = strchr(line, '\n')) != NULL)
*cp = '\0';
lreply(230, "%s", line);
}
(void) fflush(stdout);
- (void) fclose(fd);
+ (void) fclose(fp);
}
if (guest) {
if (ident != NULL)
diff --git a/libexec/ftpd/pathnames.h b/libexec/ftpd/pathnames.h
index 345062eff6f..52ac8469df4 100644
--- a/libexec/ftpd/pathnames.h
+++ b/libexec/ftpd/pathnames.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pathnames.h,v 1.3 1997/03/25 22:47:08 millert Exp $ */
+/* $OpenBSD: pathnames.h,v 1.4 1999/12/03 01:22:46 millert Exp $ */
/* $NetBSD: pathnames.h,v 1.5 1995/04/11 02:44:59 cgd Exp $ */
/*
@@ -43,4 +43,5 @@
#define _PATH_FTPWELCOME "/etc/ftpwelcome"
#define _PATH_FTPLOGINMESG "/etc/motd"
#define _PATH_FTPDSTATFILE "/var/log/ftpd"
+#define _PATH_FTPDPID "/var/run/ftpd.pid"
#define _PATH_CWDMESG ".message"