From patchwork Thu Nov 24 16:29:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Webb X-Patchwork-Id: 127555 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 603581007DE for ; Fri, 25 Nov 2011 03:30:19 +1100 (EST) Received: from localhost ([::1]:42939 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RTcBc-00063F-Ex for incoming@patchwork.ozlabs.org; Thu, 24 Nov 2011 11:30:08 -0500 Received: from eggs.gnu.org ([140.186.70.92]:34350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RTcBU-00062j-1g for qemu-devel@nongnu.org; Thu, 24 Nov 2011 11:30:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RTcBS-0006aG-Fm for qemu-devel@nongnu.org; Thu, 24 Nov 2011 11:30:00 -0500 Received: from alpha.arachsys.com ([91.203.57.7]:51732) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RTcBS-0006aC-AP for qemu-devel@nongnu.org; Thu, 24 Nov 2011 11:29:58 -0500 Received: from [81.2.114.212] (helo=miranda.arachsys.com) by alpha.arachsys.com with esmtpa (Exim 4.72) (envelope-from ) id 1RTcBQ-0003Sb-CI; Thu, 24 Nov 2011 16:29:56 +0000 From: Chris Webb To: qemu-devel@nongnu.org Date: Thu, 24 Nov 2011 16:29:48 +0000 Message-Id: X-Mailer: git-send-email 1.7.5.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 91.203.57.7 Cc: Chris Webb Subject: [Qemu-devel] [PATCH 1/2] Do not generate spurious error for -runas root X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org change_process_uid() checks that privileges have been successfully dropped by verifying that setuid(0) fails. However, if qemu is explicitly -runas root, the setuid(0) would correctly succeed, so we skip the test in that case. Signed-off-by: Chris Webb --- os-posix.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/os-posix.c b/os-posix.c index dc4a6bb..1b2061a 100644 --- a/os-posix.c +++ b/os-posix.c @@ -209,7 +209,7 @@ static void change_process_uid(void) fprintf(stderr, "Failed to setuid(%d)\n", user_pwd->pw_uid); exit(1); } - if (setuid(0) != -1) { + if (user_pwd->pw_uid != 0 && setuid(0) != -1) { fprintf(stderr, "Dropping privileges failed\n"); exit(1); }