summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2000-12-02 18:01:12 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2000-12-02 18:01:12 +0000
commitd3f5b73d37e8d643ed68422293872a2715cd7fe9 (patch)
tree1016233d95142149fb5babc8450a5ebf5e9cf763
parentc75134bf5e5afb3bd52f9a911441588e6b26da2d (diff)
The man page says the default umask is 027 but it is really 022 since
that is the value of CMASK. Have setusercontext() set the umask unless the -u flag was specified. This allows the admin to set the umask either via -u or via a login class in login.conf.
-rw-r--r--libexec/ftpd/ftpd.86
-rw-r--r--libexec/ftpd/ftpd.c17
2 files changed, 15 insertions, 8 deletions
diff --git a/libexec/ftpd/ftpd.8 b/libexec/ftpd/ftpd.8
index fdc599f2c3d..2a20ac2c690 100644
--- a/libexec/ftpd/ftpd.8
+++ b/libexec/ftpd/ftpd.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ftpd.8,v 1.35 2000/09/08 18:03:27 aaron Exp $
+.\" $OpenBSD: ftpd.8,v 1.36 2000/12/02 18:01:11 millert Exp $
.\" $NetBSD: ftpd.8,v 1.8 1996/01/14 20:55:23 thorpej Exp $
.\"
.\" Copyright (c) 1985, 1988, 1991, 1993
@@ -153,7 +153,9 @@ seconds (the default is 15 minutes).
.It Fl u Ar mask
Force the umask to
.Ar mask .
-instead of the default 027.
+instead of the default specified in
+.Pa /etc/login.conf
+(usually 022).
Also disallows chmod.
.El
.Pp
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index 1748e86b5bd..5e36a269c3f 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftpd.c,v 1.82 2000/11/26 19:52:56 millert Exp $ */
+/* $OpenBSD: ftpd.c,v 1.83 2000/12/02 18:01:11 millert Exp $ */
/* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */
/*
@@ -178,7 +178,7 @@ off_t file_size;
off_t byte_count;
#if !defined(CMASK) || CMASK == 0
#undef CMASK
-#define CMASK 027
+#define CMASK 022
#endif
int defumask = CMASK; /* default umask value */
int umaskchange = 1; /* allow user to change umask value. */
@@ -838,6 +838,7 @@ end_login()
logout(utmp.ut_line);
}
pw = NULL;
+ /* umask is restored in ftpcmd.y */
setusercontext(NULL, getpwuid(0), (uid_t)0,
LOGIN_SETPRIORITY|LOGIN_SETRESOURCES);
logged_in = 0;
@@ -849,7 +850,7 @@ void
pass(passwd)
char *passwd;
{
- int rval;
+ int rval, flags;
FILE *fp;
static char homedir[MAXPATHLEN];
char *dir, rootdir[MAXPATHLEN];
@@ -922,9 +923,13 @@ skip:
reply(550, "Can't set gid.");
return;
}
- (void) umask(defumask);
- setusercontext(lc, pw, (uid_t)0,
- LOGIN_SETGROUP|LOGIN_SETPRIORITY|LOGIN_SETRESOURCES);
+ /* set umask via setusercontext() unless -u flag was given. */
+ flags = LOGIN_SETGROUP|LOGIN_SETPRIORITY|LOGIN_SETRESOURCES;
+ if (umaskchange)
+ flags |= LOGIN_SETUMASK;
+ else
+ (void) umask(defumask);
+ setusercontext(lc, pw, (uid_t)0, flags);
/* open wtmp before chroot */
ftpdlogwtmp(ttyline, pw->pw_name, remotehost);