mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 20:48:55 +00:00
Only change uid/gid when it's not 0
Only change the device uid/gid in the sandbox when it is not 0. Otherwise, running crosvm as root makes minijail complain: libminijail[16370]: useless change to uid 0 BUG=none TEST=run crosvm as root Change-Id: Ida4b0e772ed000d3e42f77012af9d2505f64d92a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3141297 Auto-Submit: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Fergus Dall <sidereal@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
3eeaf6a339
commit
e1663eeae4
1 changed files with 6 additions and 2 deletions
|
@ -1692,8 +1692,12 @@ fn add_current_user_to_jail(jail: &mut Minijail) -> Result<Ids> {
|
|||
jail.gidmap(&format!("{0} {0} 1", crosvm_gid))
|
||||
.map_err(Error::SettingGidMap)?;
|
||||
|
||||
jail.change_uid(crosvm_uid);
|
||||
jail.change_gid(crosvm_gid);
|
||||
if crosvm_uid != 0 {
|
||||
jail.change_uid(crosvm_uid);
|
||||
}
|
||||
if crosvm_gid != 0 {
|
||||
jail.change_gid(crosvm_gid);
|
||||
}
|
||||
|
||||
Ok(Ids {
|
||||
uid: crosvm_uid,
|
||||
|
|
Loading…
Reference in a new issue