summaryrefslogtreecommitdiff
path: root/libexec/ftpd/ftpd.c
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/ftpd.c
parentad56ffb686058ef528fd3022c420218ad8e8ba88 (diff)
Write pid to /var/run/ftpd.pid if running in daemon mode.
Diffstat (limited to 'libexec/ftpd/ftpd.c')
-rw-r--r--libexec/ftpd/ftpd.c40
1 files changed, 24 insertions, 16 deletions
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)