CVE-2019-3870 pysmbd: Move umask manipuations as close as possible to users
authorAndrew Bartlett <abartlet@samba.org>
Thu, 14 Mar 2019 05:20:06 +0000 (18:20 +1300)
committerKarolin Seeger <kseeger@samba.org>
Fri, 5 Apr 2019 08:14:36 +0000 (10:14 +0200)
commit9a4029b5d3be1f42da49d4e635f4637f76f01a22
treebc70b34c3460d4636331553323ae5cbcd7695b4e
parentebb9b7fa9ead90906ff71fed68c30d093ab9c15a
CVE-2019-3870 pysmbd: Move umask manipuations as close as possible to users

Umask manipulation was added to pysmbd with e146fe5ef96c1522175a8e81db15d1e8879e5652 in 2012
and init_files_struct was split out in 747c3f1fb379bb68cc7479501b85741493c05812 in 2018 for
Samba 4.9. (It was added to assist the smbd.create_file() routine used in the backup and
restore tools, which needed to write files with full metadata).

This in turn avoids leaving init_files_struct() without resetting the umask to
the original, saved, value.

Per umask(2) this is required before open() and mkdir() system calls (along
side other file-like things such as those for Unix domain socks and FIFOs etc).

Therefore for safety and clarify the additional 'belt and braces' umask
manipuations elsewhere are removed.

mkdir() will be protected by a umask() bracket, for correctness, in the next patch.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13834

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail.d/provision_fileperms [deleted file]
selftest/knownfail.d/umask-leak [deleted file]
source3/smbd/pysmbd.c