Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EbcnB-0003LB-2u for qemu-devel@nongnu.org; Mon, 14 Nov 2005 06:46:33 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ebchr-0002HS-JO for qemu-devel@nongnu.org; Mon, 14 Nov 2005 06:41:07 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ebcho-0002Gg-D6 for qemu-devel@nongnu.org; Mon, 14 Nov 2005 06:41:01 -0500 Received: from [221.122.43.98] (helo=fw.exoweb.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Ebcho-0001Y9-5b for qemu-devel@nongnu.org; Mon, 14 Nov 2005 06:41:00 -0500 Received: from [192.168.0.126] (helo=exo126.exoweb.net ident=shunwen) by fw.exoweb.net with esmtp (Exim 3.36 #1 (Debian)) id 1EbchV-0006A9-00 for ; Mon, 14 Nov 2005 19:40:41 +0800 From: swz In-Reply-To: <200511131740.09439.dfeustel@verizon.net> References: <200511131740.09439.dfeustel@verizon.net> Content-Type: text/plain Date: Mon, 14 Nov 2005 19:41:01 +0800 Message-Id: <1131968461.4940.12.camel@localhost.localdomain> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] question about -n (TUN/TAP script option) Reply-To: swzhengst@gmail.com, 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 When I run qemu as root, it work ok. Now I want to no use root, and I have find that only the script(default is /etc/qemu-ifup) want root. So I write another script qemu-ifup-wrapper, source code(use c): #include #include #include #include const char* script = "/etc/qemu-ifup"; const char* cmdname = "qemu-ifup-wrapper"; int main(int ac, char* av[]) { const char** new_av = NULL; if (setuid(0) == -1) { const char* reason = strerror(errno); fprintf(stderr, "%s: cannot setuid root (%s)\n", cmdname, reason); exit(1); } new_av = malloc(sizeof(char*) * (ac + 1)); memcpy(new_av, av, sizeof(char*) * ac); new_av[ac] = NULL; new_av[0] = script; execv(script, new_av); const char* reason = strerror(errno); fprintf(stderr, "%s: cannot execute '%s' (%s)\n", cmdname, script, reason); exit(1); } and ls -al qemu-ifup-wrapper is: -rwsr-sr-x 1 root root 8505 2005-11-14 19:04 qemu-ifup-wrapper The problem is when I use qemu -n qemu-ifup-wrapper to start qemu, the script unwork. but when I use sudo qemu -n qemu-ifup-wrapper, the script work ok. I don't know why. And in commandline, I run /etc/qemu-ifup, sudo /etc/qemu-ifup and ./qemu-ifup-wrapper, sudo ./qemu-ifup-wrapper, the result of them is same: 0.0.0.0: ERROR while getting interface flags: No such device 0.0.0.0: ERROR while getting interface flags: No such device Incorrect number of arguments for command Usage: brctl addif add interface to bridge Thank you! Regard Zheng SW