From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:55317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RTcSE-0008N6-QR for qemu-devel@nongnu.org; Thu, 24 Nov 2011 11:47:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RTcSD-0001yU-1Z for qemu-devel@nongnu.org; Thu, 24 Nov 2011 11:47:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:12999) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RTcSC-0001xw-JL for qemu-devel@nongnu.org; Thu, 24 Nov 2011 11:47:16 -0500 Message-ID: <4ECE750F.3070008@redhat.com> Date: Thu, 24 Nov 2011 18:47:11 +0200 From: Avi Kivity MIME-Version: 1.0 References: <4ECE74CB.7060001@redhat.com> In-Reply-To: <4ECE74CB.7060001@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] Allow -runas to be specified as UID:GID as well as USERNAME List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chris Webb Cc: qemu-devel@nongnu.org On 11/24/2011 06:46 PM, Avi Kivity wrote: > On 11/24/2011 06:29 PM, Chris Webb wrote: > > This allows qemu to drop privileges to a dynamically allocated, anonymous UID > > and GID without needing a temporary /etc/passwd entry for that UID. The > > UID:GID format is very standard, being (for example) the syntax used by > > chown(1) for numeric IDs. > > > @@ -179,6 +179,15 @@ void os_parse_cmd_args(int index, const char *optarg) > > case QEMU_OPTION_runas: > > user_pwd = getpwnam(optarg); > > if (!user_pwd) { > > + long uid, gid, tail; > > + if (sscanf(optarg, "%ld:%ld%ln", &uid, &gid, &tail) >= 2 > > + && !optarg[tail]) { > > + user_pwd = g_malloc0(sizeof(user_pwd)); > > g_new0() please. In fact this is a bug - you allocate a pointer instead of a struct passwd. -- error compiling committee.c: too many arguments to function