Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP4:Update
openssh-testuser.26950
openssh-7.2p2-sftp_force_permissions.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File openssh-7.2p2-sftp_force_permissions.patch of Package openssh-testuser.26950
From 07bdbd5a1adf523c31bdafbc7e55c8c2acb13524 Mon Sep 17 00:00:00 2001 From: Old openssh patches <pcerny@suse.com> Date: Wed, 26 Oct 2022 09:53:09 +0200 Subject: [PATCH] openssh-7.2p2-sftp_force_permissions # HG changeset patch # Parent 1f423882de7d5cc6aa33a78dd0726727ac408954 additional option for sftp-server to force file mode for new files FATE#312774 http://lists.mindrot.org/pipermail/openssh-unix-dev/2010-November/029044.html http://marc.info/?l=openssh-unix-dev&m=128896838930893 --- sftp-server.8 | 5 +++++ sftp-server.c | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/sftp-server.8 b/sftp-server.8 index c117398e..80e27446 100644 --- a/sftp-server.8 +++ b/sftp-server.8 @@ -38,6 +38,7 @@ .Op Fl P Ar blacklisted_requests .Op Fl p Ar whitelisted_requests .Op Fl u Ar umask +.Op Fl m Ar force_file_permissions .Ek .Nm .Fl Q Ar protocol_feature @@ -138,6 +139,10 @@ Sets an explicit .Xr umask 2 to be applied to newly-created files and directories, instead of the user's default mask. +.It Fl m Ar force_file_permissions +Sets explicit file permissions to be applied to newly-created files instead +of the default or client requested mode. Numeric values include: +777, 755, 750, 666, 644, 640, etc. Option -u is ineffective if -m is set. .El .Pp On some systems, diff --git a/sftp-server.c b/sftp-server.c index e365512c..84cbb4b0 100644 --- a/sftp-server.c +++ b/sftp-server.c @@ -80,6 +80,10 @@ static int readonly; /* Requests that are allowed/denied */ static char *request_whitelist, *request_blacklist; +/* Force file permissions */ +int permforce = 0; +long permforcemode; + /* portable attributes, etc. */ typedef struct Stat Stat; @@ -694,6 +698,10 @@ process_open(u_int32_t id) debug3("request %u: open flags %d", id, pflags); flags = flags_from_portable(pflags); mode = (a.flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? a.perm : 0666; + if (permforce == 1) { + mode = permforcemode; + (void)umask(0); /* so umask does not interfere */ + } logit("open \"%s\" flags %s mode 0%o", name, string_from_portable(pflags), mode); if (readonly && @@ -1496,7 +1504,8 @@ sftp_server_usage(void) fprintf(stderr, "usage: %s [-ehR] [-d start_directory] [-f log_facility] " "[-l log_level]\n\t[-P blacklisted_requests] " - "[-p whitelisted_requests] [-u umask]\n" + "[-p whitelisted_requests] [-u umask]\n\t" + "[-m force_file_permissions]\n" " %s -Q protocol_feature\n", __progname, __progname); exit(1); @@ -1525,7 +1534,7 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw) pw = pwcopy(user_pw); while (!skipargs && (ch = getopt(argc, argv, - "d:f:l:P:p:Q:u:cehR")) != -1) { + "d:f:l:P:p:Q:u:m:cehR")) != -1) { switch (ch) { case 'Q': if (strcasecmp(optarg, "requests") != 0) { @@ -1585,6 +1594,13 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw) fatal("Invalid umask \"%s\"", optarg); (void)umask((mode_t)mask); break; + case 'm': + permforce = 1; + permforcemode = strtol(optarg, &cp, 8); + if (permforcemode < 0 || permforcemode > 0777 || *cp != '\0' || + cp == optarg || (permforcemode == 0 && errno != 0)) + fatal("Invalid umask \"%s\"", optarg); + break; case 'h': default: sftp_server_usage(); -- 2.38.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor