|
Jakub Jelen |
558fb7 |
--- openssh-5.3p1/sftp-server.8 2015-02-10 10:08:09.611849984 +0100
|
|
Jakub Jelen |
558fb7 |
+++ openssh-5.3p1/sftp-server.8.perms 2015-02-10 10:08:52.204120509 +0100
|
|
Jakub Jelen |
558fb7 |
@@ -33,6 +33,7 @@
|
|
Jakub Jelen |
558fb7 |
.Op Fl P Ar blacklisted_requests
|
|
Jakub Jelen |
558fb7 |
.Op Fl p Ar whitelisted_requests
|
|
Jakub Jelen |
558fb7 |
.Op Fl u Ar umask
|
|
Jakub Jelen |
558fb7 |
+.Op Fl m Ar force_file_perms
|
|
Jakub Jelen |
558fb7 |
.Ek
|
|
Jakub Jelen |
558fb7 |
.Nm
|
|
Jakub Jelen |
558fb7 |
.Fl Q Ar protocol_feature
|
|
Jakub Jelen |
558fb7 |
@@ -77,6 +78,10 @@ Sets an explicit
|
|
Jakub Jelen |
558fb7 |
.Xr umask 2
|
|
Jakub Jelen |
558fb7 |
to be applied to newly-created files and directories, instead of the
|
|
Jakub Jelen |
558fb7 |
user's default mask.
|
|
Jakub Jelen |
558fb7 |
+.It Fl m Ar force_file_perms
|
|
Jakub Jelen |
558fb7 |
+Sets explicit file permissions to be applied to newly-created files instead
|
|
Jakub Jelen |
558fb7 |
+of the default or client requested mode. Numeric values include:
|
|
Jakub Jelen |
558fb7 |
+777, 755, 750, 666, 644, 640, etc. Option -u is ineffective if -m is set.
|
|
Jakub Jelen |
558fb7 |
.El
|
|
Jakub Jelen |
558fb7 |
.Pp
|
|
Jakub Jelen |
558fb7 |
On some systems,
|
|
Jakub Jelen |
558fb7 |
--- openssh-5.3p1/sftp-server.c 2015-02-10 10:08:09.611849984 +0100
|
|
Jakub Jelen |
558fb7 |
+++ openssh-5.3p1/sftp-server.c.perms 2015-02-10 10:39:00.855453028 +0100
|
|
Jakub Jelen |
558fb7 |
@@ -70,6 +70,10 @@ Buffer oqueue;
|
|
Jakub Jelen |
558fb7 |
/* Version of client */
|
|
Jakub Jelen |
558fb7 |
static u_int version;
|
|
Jakub Jelen |
558fb7 |
|
|
Jakub Jelen |
558fb7 |
+/* Force file permissions */
|
|
Jakub Jelen |
558fb7 |
+int permforce = 0;
|
|
Jakub Jelen |
558fb7 |
+long permforcemode;
|
|
Jakub Jelen |
558fb7 |
+
|
|
Jakub Jelen |
558fb7 |
/* SSH2_FXP_INIT received */
|
|
Jakub Jelen |
558fb7 |
static int init_done;
|
|
Jakub Jelen |
558fb7 |
|
|
Jakub Jelen |
558fb7 |
@@ -551,6 +555,10 @@ process_open(void)
|
|
Jakub Jelen |
558fb7 |
a = get_attrib();
|
|
Jakub Jelen |
558fb7 |
flags = flags_from_portable(pflags);
|
|
Jakub Jelen |
558fb7 |
mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? a->perm : 0666;
|
|
Jakub Jelen |
558fb7 |
+ if (permforce == 1) { /* Force perm if -m is set */
|
|
Jakub Jelen |
558fb7 |
+ mode = permforcemode;
|
|
Jakub Jelen |
558fb7 |
+ (void)umask(0); /* so umask does not interfere */
|
|
Jakub Jelen |
558fb7 |
+ }
|
|
Jakub Jelen |
558fb7 |
logit("open \"%s\" flags %s mode 0%o",
|
|
Jakub Jelen |
558fb7 |
name, string_from_portable(pflags), mode);
|
|
Jakub Jelen |
558fb7 |
if (readonly &&
|
|
Jakub Jelen |
558fb7 |
@@ -1322,7 +1330,7 @@ sftp_server_usage(void)
|
|
Jakub Jelen |
558fb7 |
fprintf(stderr,
|
|
Jakub Jelen |
558fb7 |
"usage: %s [-ehR] [-d start_directory] [-f log_facility] "
|
|
Jakub Jelen |
558fb7 |
"[-l log_level]\n\t[-P blacklisted_requests] "
|
|
Jakub Jelen |
558fb7 |
- "[-p whitelisted_requests] [-u umask]\n"
|
|
Jakub Jelen |
558fb7 |
+ "[-p whitelisted_requests] [-u umask] [-m force_file_perms]\n"
|
|
Jakub Jelen |
558fb7 |
" %s -Q protocol_feature\n",
|
|
Jakub Jelen |
558fb7 |
__progname, __progname);
|
|
Jakub Jelen |
558fb7 |
exit(1);
|
|
Jakub Jelen |
558fb7 |
@@ -1343,7 +1351,7 @@ sftp_server_main(int argc, char **argv,
|
|
Jakub Jelen |
558fb7 |
pw = pwcopy(user_pw);
|
|
Jakub Jelen |
558fb7 |
|
|
Jakub Jelen |
558fb7 |
while (!skipargs && (ch = getopt(argc, argv,
|
|
Jakub Jelen |
558fb7 |
- "d:f:l:P:p:Q:u:cehR")) != -1) {
|
|
Jakub Jelen |
558fb7 |
+ "d:f:l:P:p:Q:u:m:cehR")) != -1) {
|
|
Jakub Jelen |
558fb7 |
switch (ch) {
|
|
Jakub Jelen |
558fb7 |
case 'Q':
|
|
Jakub Jelen |
558fb7 |
if (strcasecmp(optarg, "requests") != 0) {
|
|
Jakub Jelen |
558fb7 |
@@ -1373,6 +1381,15 @@ sftp_server_main(int argc, char **argv,
|
|
Jakub Jelen |
558fb7 |
fatal("Invalid umask \"%s\"", optarg);
|
|
Jakub Jelen |
558fb7 |
(void)umask((mode_t)mask);
|
|
Jakub Jelen |
558fb7 |
break;
|
|
Jakub Jelen |
558fb7 |
+ case 'm':
|
|
Jakub Jelen |
558fb7 |
+ /* Force permissions on file received via sftp */
|
|
Jakub Jelen |
558fb7 |
+ permforce = 1;
|
|
Jakub Jelen |
558fb7 |
+ permforcemode = strtol(optarg, &cp, 8);
|
|
Jakub Jelen |
558fb7 |
+ if (permforcemode < 0 || permforcemode > 0777 ||
|
|
Jakub Jelen |
558fb7 |
+ *cp != '\0' || (permforcemode == 0 &&
|
|
Jakub Jelen |
558fb7 |
+ errno != 0))
|
|
Jakub Jelen |
558fb7 |
+ fatal("Invalid file mode \"%s\"", optarg);
|
|
Jakub Jelen |
558fb7 |
+ break;
|
|
Jakub Jelen |
558fb7 |
case 'h':
|
|
Jakub Jelen |
558fb7 |
default:
|
|
Jakub Jelen |
558fb7 |
sftp_server_usage();
|