qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Internet Access for Browser in Qemu
@ 2005-11-13 22:40 Dave Feustel
  2005-11-14 11:41 ` [Qemu-devel] question about -n (TUN/TAP script option) swz
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Feustel @ 2005-11-13 22:40 UTC (permalink / raw)
  To: qemu-devel

Hi!

I now have Qemu 6.1 running on OpenBSD 3.7 release.
I now can successfully  ping 10.0.0.1 from within Qemu 
and also from the Host side. I have defined a bridge 
containing xl0 and tun0 and I have enabled packet 
forwarding by setting net.inet.ip.forwarding=1.
Pf is running but has no rules for traffic to/from Qemu.
What else do I need to do to be able to access the 
internet from a  browser running on Linux within Qemu?

Thanks,
Dave Feustel
-- 
Tired of having to defend against Malware?
You know: trojans, viruses, SPYWARE, ADWARE, 
KEYLOGGERS, rootkits, worms and popups.
Then Switch to OpenBSD with a KDE desktop!!!

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Qemu-devel] question about -n (TUN/TAP script option)
  2005-11-13 22:40 [Qemu-devel] Internet Access for Browser in Qemu Dave Feustel
@ 2005-11-14 11:41 ` swz
  0 siblings, 0 replies; 2+ messages in thread
From: swz @ 2005-11-14 11:41 UTC (permalink / raw)
  To: qemu-devel

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 <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>

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 <bridge> <device>    add interface to bridge

Thank you!
Regard
Zheng SW

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-11-14 11:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-13 22:40 [Qemu-devel] Internet Access for Browser in Qemu Dave Feustel
2005-11-14 11:41 ` [Qemu-devel] question about -n (TUN/TAP script option) swz

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).