summaryrefslogtreecommitdiff
path: root/sftp-server.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2009-10-07 08:44:42 +1100
committerDarren Tucker <dtucker@zip.com.au>2009-10-07 08:44:42 +1100
commit7dc4850ce85a676ede0c070db6e46e022bd852fe (patch)
tree6c03dcedf2d59889666fea760673641991d8dbfa /sftp-server.c
parent8ec4fd8e3cf5eaf4791d422df1137ecacebc2a34 (diff)
- djm@cvs.openbsd.org 2009/08/27 17:28:52
[sftp-server.c] allow setting an explicit umask on the commandline to override whatever default the user has. bz#1229; ok dtucker@ deraadt@ markus@
Diffstat (limited to 'sftp-server.c')
-rw-r--r--sftp-server.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/sftp-server.c b/sftp-server.c
index d984e604..d144001b 100644
--- a/sftp-server.c
+++ b/sftp-server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp-server.c,v 1.85 2009/04/14 16:33:42 stevesk Exp $ */
+/* $OpenBSD: sftp-server.c,v 1.86 2009/08/27 17:28:52 djm Exp $ */
/*
* Copyright (c) 2000-2004 Markus Friedl. All rights reserved.
*
@@ -1322,7 +1322,8 @@ sftp_server_usage(void)
extern char *__progname;
fprintf(stderr,
- "usage: %s [-he] [-l log_level] [-f log_facility]\n", __progname);
+ "usage: %s [-he] [-l log_level] [-f log_facility] [-u umask]\n",
+ __progname);
exit(1);
}
@@ -1334,6 +1335,8 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
ssize_t len, olen, set_size;
SyslogFacility log_facility = SYSLOG_FACILITY_AUTH;
char *cp, buf[4*4096];
+ const char *errmsg;
+ mode_t mask;
extern char *optarg;
extern char *__progname;
@@ -1341,7 +1344,7 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
__progname = ssh_get_progname(argv[0]);
log_init(__progname, log_level, log_facility, log_stderr);
- while (!skipargs && (ch = getopt(argc, argv, "f:l:che")) != -1) {
+ while (!skipargs && (ch = getopt(argc, argv, "f:l:u:che")) != -1) {
switch (ch) {
case 'c':
/*
@@ -1363,6 +1366,13 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
if (log_facility == SYSLOG_FACILITY_NOT_SET)
error("Invalid log facility \"%s\"", optarg);
break;
+ case 'u':
+ mask = (mode_t)strtonum(optarg, 0, 0777, &errmsg);
+ if (cp != NULL)
+ fatal("Invalid umask \"%s\": %s",
+ optarg, errmsg);
+ (void)umask(mask);
+ break;
case 'h':
default:
sftp_server_usage();