p9: Fix file and directory creation mode

Don't allow clients to create files and directories that are writable by
anyone other than the user.  This is equivalent to having a umask of
022.

BUG=chromium:703939
TEST=change the umask in the container, mkdir, and see that it has 0755

Change-Id: I0622fcd89935512969bcd25a9b1fece1e72e1f38
Signed-off-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1112869
Reviewed-by: Dylan Reid <dgreid@chromium.org>
This commit is contained in:
Chirantan Ekbote 2018-06-21 12:14:41 -07:00 committed by chrome-bot
parent f2fb37e669
commit d678784ae1

View file

@ -541,7 +541,7 @@ impl Server {
.append((lcreate.flags & P9_APPEND) != 0)
.create_new((lcreate.flags & P9_EXCL) != 0)
.custom_flags(custom_flags)
.mode(lcreate.mode & 0o777)
.mode(lcreate.mode & 0o755)
.open(&path)?;
fid.metadata = file.metadata()?;
@ -842,7 +842,7 @@ impl Server {
fs::DirBuilder::new()
.recursive(false)
.mode(mkdir.mode & 0o777)
.mode(mkdir.mode & 0o755)
.create(&newpath)?;
Ok(Rmessage::Mkdir(Rmkdir {