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>
Mon, 8 Apr 2019 10:27:34 +0000 (10:27 +0000)
commit1899e16e6f552d0ab504d19f74aa5c42ab84504a
tree535f281b2f052bc8297c6ff21bcbd49571f8597d
parentd7580706e9ac75187ba5d926fd0e37a468a6da86
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