qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: allow to use sudo in guest qemu must have suid/gid bit and root owner/group
@ 2012-12-08 15:22 Laurent Vivier
  0 siblings, 0 replies; only message in thread
From: Laurent Vivier @ 2012-12-08 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio, Laurent Vivier

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/linuxload.c |   12 +++++++-----
 linux-user/main.c      |    3 +++
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/linux-user/linuxload.c b/linux-user/linuxload.c
index 381ab89..0fccf58 100644
--- a/linux-user/linuxload.c
+++ b/linux-user/linuxload.c
@@ -58,11 +58,6 @@ static int prepare_binprm(struct linux_binprm *bprm)
     bprm->e_uid = geteuid();
     bprm->e_gid = getegid();
 
-    /* Set-uid? */
-    if(mode & S_ISUID) {
-    	bprm->e_uid = st.st_uid;
-    }
-
     /* Set-gid? */
     /*
      * If setgid is set but no group execute bit then this
@@ -72,6 +67,13 @@ static int prepare_binprm(struct linux_binprm *bprm)
     if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
 	bprm->e_gid = st.st_gid;
     }
+    setresgid(getgid(), bprm->e_gid, bprm->e_gid);
+
+    /* Set-uid? */
+    if(mode & S_ISUID) {
+    	bprm->e_uid = st.st_uid;
+    }
+    setresuid(getuid(), bprm->e_uid, bprm->e_uid);
 
     retval = read(bprm->fd, bprm->buf, BPRM_BUF_SIZE);
     if (retval < 0) {
diff --git a/linux-user/main.c b/linux-user/main.c
index 25e35cd..3cddb2e 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -3400,6 +3400,9 @@ int main(int argc, char **argv, char **envp)
     int i;
     int ret;
 
+    seteuid(getuid());
+    setegid(getgid());
+
     module_call_init(MODULE_INIT_QOM);
 
     qemu_cache_utils_init(envp);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-12-08 15:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-08 15:22 [Qemu-devel] [PATCH] linux-user: allow to use sudo in guest qemu must have suid/gid bit and root owner/group Laurent Vivier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).