From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KIw02-0006jV-Ah for qemu-devel@nongnu.org; Tue, 15 Jul 2008 21:40:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KIw00-0006j3-Pw for qemu-devel@nongnu.org; Tue, 15 Jul 2008 21:40:10 -0400 Received: from [199.232.76.173] (port=59859 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KIw00-0006j0-N6 for qemu-devel@nongnu.org; Tue, 15 Jul 2008 21:40:08 -0400 Received: from wr-out-0506.google.com ([64.233.184.236]:31856) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KIw00-0002MZ-C9 for qemu-devel@nongnu.org; Tue, 15 Jul 2008 21:40:08 -0400 Received: by wr-out-0506.google.com with SMTP id c46so4870214wra.18 for ; Tue, 15 Jul 2008 18:40:06 -0700 (PDT) Message-ID: <487D515A.90903@codemonkey.ws> Date: Tue, 15 Jul 2008 20:39:38 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] Setting new user:group with -daemonize? References: <487D2E27.1060809@quinthar.com> In-Reply-To: <487D2E27.1060809@quinthar.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org David Barrett wrote: > Is there any way to make the qemu process change users after daemonizing? > > Basically, I want to start it as root so I can have it "-redir" with a > low port (80), and then change to a non-root user after daemonizing. > Is there any way to do this currently? > > Thankfully it opens the -redir port before forking, so it looks like a > straightforward change to vc.c: basically adding a call to "setuid()" > and "setgid()" after the call to "chdir()" on line 8711. > > I'd update the -daemonize syntax as follows: > > -daemonize [user[:group]] > > Is there any interest in such a patch? If you introduced two new options to specify the user and the group. Also, I would be interested in a chroot option too :-) > -david > > PS: Why does it fork twice? It makes sure QEMU is an orphan process (it's parent is pid 1). It's a pretty typical thing to do when daemonizing. Regards, Anthony Liguori > >