From abcc50f26e4f464929b35b9381581539f1723abd Mon Sep 17 00:00:00 2001 From: Julien Iguchi-Cartigny Date: Fri, 20 May 2011 13:32:13 +0200 Subject: [PATCH] using uml utilities src from ubuntu repo insted of the sourceforge CVS --- src/tools-20070815/.pc/.version | 1 + src/tools-20070815/.pc/applied-patches | 1 + .../.pc/tunctl-setgroup/.timestamp | 0 .../.pc/tunctl-setgroup}/tunctl/tunctl.c | 0 src/{uml-tools => tools-20070815}/COPYING | 0 src/tools-20070815/CVS/Entries | 21 + src/tools-20070815/CVS/Repository | 1 + src/tools-20070815/CVS/Root | 1 + src/tools-20070815/Changelog | 32 + src/{uml-tools => tools-20070815}/Makefile | 21 +- src/tools-20070815/Makefile.orig | 35 + src/tools-20070815/Makefile.rej | 11 + src/{uml-tools => tools-20070815}/gdb/gdbinit | 0 src/tools-20070815/gdbbot/CVS/Entries | 2 + src/tools-20070815/gdbbot/CVS/Repository | 1 + src/tools-20070815/gdbbot/CVS/Root | 1 + .../gdbbot/gdbbot.pl | 0 src/tools-20070815/honeypot/CVS/CVS/Entries | 1 + .../honeypot/CVS/CVS/Repository | 1 + src/tools-20070815/honeypot/CVS/CVS/Root | 1 + src/tools-20070815/honeypot/CVS/Entries | 4 + src/tools-20070815/honeypot/CVS/Repository | 1 + src/tools-20070815/honeypot/CVS/Root | 1 + .../honeypot/honeypot.pl | 24 +- .../honeypot/hppfs.pm | 0 .../honeypot/hppfslib.pm | 8 +- src/tools-20070815/humfsify/Makefile | 10 + src/tools-20070815/humfsify/humfsify | 427 +++++++++++++ src/tools-20070815/jail/CVS/Entries | 10 + src/tools-20070815/jail/CVS/Repository | 1 + src/tools-20070815/jail/CVS/Root | 1 + src/tools-20070815/jail/Makefile | 17 + .../jail/cell.tar | Bin .../jail/db_out.pm | 0 src/tools-20070815/jail/jail_uml.c | 81 +++ .../jail/jailer.pl | 0 .../jail/playlog.pl | 0 .../jail/tty_log.pl | 0 .../jail/tty_log.pm | 0 .../jail/tty_out.pm | 0 src/tools-20070815/jailtest/CVS/CVS/Entries | 1 + .../jailtest/CVS/CVS/Repository | 1 + src/tools-20070815/jailtest/CVS/CVS/Root | 1 + src/tools-20070815/jailtest/CVS/Entries | 3 + src/tools-20070815/jailtest/CVS/Repository | 1 + src/tools-20070815/jailtest/CVS/Root | 1 + .../jailtest/Makefile | 2 +- .../jailtest/jailtest.c | 0 src/tools-20070815/lib/Makefile | 13 + src/tools-20070815/lib/rights.c | 45 ++ .../mconsole/.cvsignore | 0 src/tools-20070815/mconsole/CVS/Entries | 5 + src/tools-20070815/mconsole/CVS/Repository | 1 + src/tools-20070815/mconsole/CVS/Root | 1 + src/tools-20070815/mconsole/Makefile | 18 + .../mconsole/notify.pl | 0 .../mconsole/uml_mconsole.c | 288 ++++++--- .../mconsole/uml_mconsole.c.orig | 572 +++++++++++++++++ .../mconsole/uml_mconsole.c.rej | 25 + .../moo/.cvsignore | 0 src/tools-20070815/moo/CVS/Entries | 8 + src/tools-20070815/moo/CVS/Repository | 1 + src/tools-20070815/moo/CVS/Root | 1 + .../moo/Makefile | 3 +- src/{uml-tools => tools-20070815}/moo/cow.c | 194 ++++-- src/{uml-tools => tools-20070815}/moo/cow.h | 19 +- .../moo/cow_sys.h | 27 +- .../moo/uml_mkcow.c | 9 +- .../moo/uml_moo.c | 38 +- src/tools-20070815/patches/series | 1 + src/tools-20070815/patches/tunctl-setgroup | 103 +++ .../port-helper/CVS/CVS/Entries | 1 + .../port-helper/CVS/CVS/Repository | 1 + src/tools-20070815/port-helper/CVS/CVS/Root | 1 + src/tools-20070815/port-helper/CVS/Entries | 3 + src/tools-20070815/port-helper/CVS/Repository | 1 + src/tools-20070815/port-helper/CVS/Root | 1 + .../port-helper/Makefile | 5 +- .../port-helper/port-helper.c | 49 +- src/tools-20070815/tunctl/CVS/Entries | 3 + src/tools-20070815/tunctl/CVS/Repository | 1 + src/tools-20070815/tunctl/CVS/Root | 1 + .../tunctl/Makefile | 2 +- src/tools-20070815/tunctl/tunctl.c | 156 +++++ .../uml_dump}/Makefile | 6 +- src/tools-20070815/uml_dump/uml_dump.c | 276 ++++++++ .../uml_net/.cvsignore | 0 src/tools-20070815/uml_net/CVS/Entries | 11 + src/tools-20070815/uml_net/CVS/Repository | 1 + src/tools-20070815/uml_net/CVS/Root | 1 + .../uml_net/Makefile | 3 +- .../uml_net/ethertap.c | 0 .../uml_net/host.c | 2 +- .../uml_net/host.h | 0 .../uml_net/output.c | 0 .../uml_net/output.h | 0 .../uml_net/slip.c | 11 +- .../uml_net/tuntap.c | 0 .../uml_net/uml_net.c | 0 src/tools-20070815/uml_router/Makefile.orig | 0 src/tools-20070815/uml_router/Makefile.rej | 10 + src/tools-20070815/uml_router/port.c.orig | 0 src/tools-20070815/uml_router/port.c.rej | 102 +++ src/tools-20070815/uml_router/port.h.orig | 0 src/tools-20070815/uml_router/port.h.rej | 37 ++ src/tools-20070815/uml_router/tuntap.c.orig | 0 src/tools-20070815/uml_router/tuntap.c.rej | 19 + .../uml_router/uml_switch.c.orig | 0 .../uml_router/uml_switch.c.rej | 141 ++++ src/tools-20070815/uml_router/uml_switch.h | 67 ++ .../uml_switch}/.cvsignore | 0 src/tools-20070815/uml_switch/CVS/Entries | 11 + src/tools-20070815/uml_switch/CVS/Repository | 1 + src/tools-20070815/uml_switch/CVS/Root | 1 + .../uml_switch}/Makefile | 3 +- .../uml_switch}/hash.c | 12 +- src/tools-20070815/uml_switch/hash.h | 15 + .../uml_switch}/port.c | 3 +- .../uml_switch}/port.h | 0 .../uml_switch}/switch.h | 0 .../uml_switch}/tuntap.c | 0 .../uml_switch}/tuntap.h | 0 .../uml_switch}/uml_switch.c | 11 +- src/tools-20070815/uml_util.spec | 46 ++ .../uml_util.spec.in | 2 +- src/tools-20070815/umlfs/Makefile | 19 + src/tools-20070815/umlfs/uml_mount.c | 36 ++ src/tools-20070815/umlgdb/CVS/CVS/Entries | 1 + src/tools-20070815/umlgdb/CVS/CVS/Repository | 1 + src/tools-20070815/umlgdb/CVS/CVS/Root | 1 + src/tools-20070815/umlgdb/CVS/Entries | 3 + src/tools-20070815/umlgdb/CVS/Repository | 1 + src/tools-20070815/umlgdb/CVS/Root | 1 + .../umlgdb/Makefile | 0 .../umlgdb/umlgdb | 0 src/tools-20070815/watchdog/CVS/Entries | 3 + src/tools-20070815/watchdog/CVS/Repository | 1 + src/tools-20070815/watchdog/CVS/Root | 1 + .../watchdog/Makefile | 2 +- .../watchdog/uml_watchdog.c | 0 src/uml-tools/humfsify/Makefile | 4 - src/uml-tools/humfsify/humfsify | 58 -- src/uml-tools/jail/Makefile | 9 - src/uml-tools/jail/jail_uml.c | 48 -- src/uml-tools/net/Makefile | 16 - src/uml-tools/net/README | 66 -- src/uml-tools/net/ethertap_helper.c | 112 ---- src/uml-tools/net/input.c | 131 ---- src/uml-tools/net/output.c | 84 --- src/uml-tools/net/um_eth.h | 57 -- src/uml-tools/net/um_eth_serv.c | 135 ---- src/uml-tools/net/um_eth_tool.c | 123 ---- src/uml-tools/rpm/Makefile | 28 - src/uml-tools/rpm/uml.spec.in | 600 ------------------ src/uml-tools/test/COPYING | 340 ---------- src/uml-tools/test/Makefile | 1 - src/uml-tools/test/README | 11 - src/uml-tools/test/UML.pm | 220 ------- src/uml-tools/test/tsuite.pl | 74 --- src/uml-tools/uml_router/hash.h | 15 - 160 files changed, 2898 insertions(+), 2419 deletions(-) create mode 100644 src/tools-20070815/.pc/.version create mode 100644 src/tools-20070815/.pc/applied-patches create mode 100644 src/tools-20070815/.pc/tunctl-setgroup/.timestamp rename src/{uml-tools => tools-20070815/.pc/tunctl-setgroup}/tunctl/tunctl.c (100%) rename src/{uml-tools => tools-20070815}/COPYING (100%) create mode 100644 src/tools-20070815/CVS/Entries create mode 100644 src/tools-20070815/CVS/Repository create mode 100644 src/tools-20070815/CVS/Root create mode 100644 src/tools-20070815/Changelog rename src/{uml-tools => tools-20070815}/Makefile (51%) create mode 100644 src/tools-20070815/Makefile.orig create mode 100644 src/tools-20070815/Makefile.rej rename src/{uml-tools => tools-20070815}/gdb/gdbinit (100%) create mode 100644 src/tools-20070815/gdbbot/CVS/Entries create mode 100644 src/tools-20070815/gdbbot/CVS/Repository create mode 100644 src/tools-20070815/gdbbot/CVS/Root rename src/{uml-tools => tools-20070815}/gdbbot/gdbbot.pl (100%) create mode 100644 src/tools-20070815/honeypot/CVS/CVS/Entries create mode 100644 src/tools-20070815/honeypot/CVS/CVS/Repository create mode 100644 src/tools-20070815/honeypot/CVS/CVS/Root create mode 100644 src/tools-20070815/honeypot/CVS/Entries create mode 100644 src/tools-20070815/honeypot/CVS/Repository create mode 100644 src/tools-20070815/honeypot/CVS/Root rename src/{uml-tools => tools-20070815}/honeypot/honeypot.pl (51%) rename src/{uml-tools => tools-20070815}/honeypot/hppfs.pm (100%) rename src/{uml-tools => tools-20070815}/honeypot/hppfslib.pm (86%) create mode 100644 src/tools-20070815/humfsify/Makefile create mode 100644 src/tools-20070815/humfsify/humfsify create mode 100644 src/tools-20070815/jail/CVS/Entries create mode 100644 src/tools-20070815/jail/CVS/Repository create mode 100644 src/tools-20070815/jail/CVS/Root create mode 100644 src/tools-20070815/jail/Makefile rename src/{uml-tools => tools-20070815}/jail/cell.tar (100%) rename src/{uml-tools => tools-20070815}/jail/db_out.pm (100%) create mode 100644 src/tools-20070815/jail/jail_uml.c rename src/{uml-tools => tools-20070815}/jail/jailer.pl (100%) rename src/{uml-tools => tools-20070815}/jail/playlog.pl (100%) rename src/{uml-tools => tools-20070815}/jail/tty_log.pl (100%) rename src/{uml-tools => tools-20070815}/jail/tty_log.pm (100%) rename src/{uml-tools => tools-20070815}/jail/tty_out.pm (100%) create mode 100644 src/tools-20070815/jailtest/CVS/CVS/Entries create mode 100644 src/tools-20070815/jailtest/CVS/CVS/Repository create mode 100644 src/tools-20070815/jailtest/CVS/CVS/Root create mode 100644 src/tools-20070815/jailtest/CVS/Entries create mode 100644 src/tools-20070815/jailtest/CVS/Repository create mode 100644 src/tools-20070815/jailtest/CVS/Root rename src/{uml-tools => tools-20070815}/jailtest/Makefile (92%) rename src/{uml-tools => tools-20070815}/jailtest/jailtest.c (100%) create mode 100644 src/tools-20070815/lib/Makefile create mode 100644 src/tools-20070815/lib/rights.c rename src/{uml-tools => tools-20070815}/mconsole/.cvsignore (100%) create mode 100644 src/tools-20070815/mconsole/CVS/Entries create mode 100644 src/tools-20070815/mconsole/CVS/Repository create mode 100644 src/tools-20070815/mconsole/CVS/Root create mode 100644 src/tools-20070815/mconsole/Makefile rename src/{uml-tools => tools-20070815}/mconsole/notify.pl (100%) rename src/{uml-tools => tools-20070815}/mconsole/uml_mconsole.c (62%) create mode 100644 src/tools-20070815/mconsole/uml_mconsole.c.orig create mode 100644 src/tools-20070815/mconsole/uml_mconsole.c.rej rename src/{uml-tools => tools-20070815}/moo/.cvsignore (100%) create mode 100644 src/tools-20070815/moo/CVS/Entries create mode 100644 src/tools-20070815/moo/CVS/Repository create mode 100644 src/tools-20070815/moo/CVS/Root rename src/{uml-tools => tools-20070815}/moo/Makefile (82%) rename src/{uml-tools => tools-20070815}/moo/cow.c (65%) rename src/{uml-tools => tools-20070815}/moo/cow.h (72%) rename src/{uml-tools => tools-20070815}/moo/cow_sys.h (76%) rename src/{uml-tools => tools-20070815}/moo/uml_mkcow.c (84%) rename src/{uml-tools => tools-20070815}/moo/uml_moo.c (88%) create mode 100644 src/tools-20070815/patches/series create mode 100644 src/tools-20070815/patches/tunctl-setgroup create mode 100644 src/tools-20070815/port-helper/CVS/CVS/Entries create mode 100644 src/tools-20070815/port-helper/CVS/CVS/Repository create mode 100644 src/tools-20070815/port-helper/CVS/CVS/Root create mode 100644 src/tools-20070815/port-helper/CVS/Entries create mode 100644 src/tools-20070815/port-helper/CVS/Repository create mode 100644 src/tools-20070815/port-helper/CVS/Root rename src/{uml-tools => tools-20070815}/port-helper/Makefile (72%) rename src/{uml-tools => tools-20070815}/port-helper/port-helper.c (58%) create mode 100644 src/tools-20070815/tunctl/CVS/Entries create mode 100644 src/tools-20070815/tunctl/CVS/Repository create mode 100644 src/tools-20070815/tunctl/CVS/Root rename src/{uml-tools => tools-20070815}/tunctl/Makefile (92%) create mode 100644 src/tools-20070815/tunctl/tunctl.c rename src/{uml-tools/mconsole => tools-20070815/uml_dump}/Makefile (68%) create mode 100644 src/tools-20070815/uml_dump/uml_dump.c rename src/{uml-tools => tools-20070815}/uml_net/.cvsignore (100%) create mode 100644 src/tools-20070815/uml_net/CVS/Entries create mode 100644 src/tools-20070815/uml_net/CVS/Repository create mode 100644 src/tools-20070815/uml_net/CVS/Root rename src/{uml-tools => tools-20070815}/uml_net/Makefile (89%) rename src/{uml-tools => tools-20070815}/uml_net/ethertap.c (100%) rename src/{uml-tools => tools-20070815}/uml_net/host.c (99%) rename src/{uml-tools => tools-20070815}/uml_net/host.h (100%) rename src/{uml-tools => tools-20070815}/uml_net/output.c (100%) rename src/{uml-tools => tools-20070815}/uml_net/output.h (100%) rename src/{uml-tools => tools-20070815}/uml_net/slip.c (88%) rename src/{uml-tools => tools-20070815}/uml_net/tuntap.c (100%) rename src/{uml-tools => tools-20070815}/uml_net/uml_net.c (100%) create mode 100644 src/tools-20070815/uml_router/Makefile.orig create mode 100644 src/tools-20070815/uml_router/Makefile.rej create mode 100644 src/tools-20070815/uml_router/port.c.orig create mode 100644 src/tools-20070815/uml_router/port.c.rej create mode 100644 src/tools-20070815/uml_router/port.h.orig create mode 100644 src/tools-20070815/uml_router/port.h.rej create mode 100644 src/tools-20070815/uml_router/tuntap.c.orig create mode 100644 src/tools-20070815/uml_router/tuntap.c.rej create mode 100644 src/tools-20070815/uml_router/uml_switch.c.orig create mode 100644 src/tools-20070815/uml_router/uml_switch.c.rej create mode 100644 src/tools-20070815/uml_router/uml_switch.h rename src/{uml-tools/uml_router => tools-20070815/uml_switch}/.cvsignore (100%) create mode 100644 src/tools-20070815/uml_switch/CVS/Entries create mode 100644 src/tools-20070815/uml_switch/CVS/Repository create mode 100644 src/tools-20070815/uml_switch/CVS/Root rename src/{uml-tools/uml_router => tools-20070815/uml_switch}/Makefile (88%) rename src/{uml-tools/uml_router => tools-20070815/uml_switch}/hash.c (92%) create mode 100644 src/tools-20070815/uml_switch/hash.h rename src/{uml-tools/uml_router => tools-20070815/uml_switch}/port.c (99%) rename src/{uml-tools/uml_router => tools-20070815/uml_switch}/port.h (100%) rename src/{uml-tools/uml_router => tools-20070815/uml_switch}/switch.h (100%) rename src/{uml-tools/uml_router => tools-20070815/uml_switch}/tuntap.c (100%) rename src/{uml-tools/uml_router => tools-20070815/uml_switch}/tuntap.h (100%) rename src/{uml-tools/uml_router => tools-20070815/uml_switch}/uml_switch.c (98%) create mode 100644 src/tools-20070815/uml_util.spec rename src/{uml-tools => tools-20070815}/uml_util.spec.in (95%) create mode 100644 src/tools-20070815/umlfs/Makefile create mode 100644 src/tools-20070815/umlfs/uml_mount.c create mode 100644 src/tools-20070815/umlgdb/CVS/CVS/Entries create mode 100644 src/tools-20070815/umlgdb/CVS/CVS/Repository create mode 100644 src/tools-20070815/umlgdb/CVS/CVS/Root create mode 100644 src/tools-20070815/umlgdb/CVS/Entries create mode 100644 src/tools-20070815/umlgdb/CVS/Repository create mode 100644 src/tools-20070815/umlgdb/CVS/Root rename src/{uml-tools => tools-20070815}/umlgdb/Makefile (100%) rename src/{uml-tools => tools-20070815}/umlgdb/umlgdb (100%) mode change 100755 => 100644 create mode 100644 src/tools-20070815/watchdog/CVS/Entries create mode 100644 src/tools-20070815/watchdog/CVS/Repository create mode 100644 src/tools-20070815/watchdog/CVS/Root rename src/{uml-tools => tools-20070815}/watchdog/Makefile (92%) rename src/{uml-tools => tools-20070815}/watchdog/uml_watchdog.c (100%) delete mode 100644 src/uml-tools/humfsify/Makefile delete mode 100755 src/uml-tools/humfsify/humfsify delete mode 100644 src/uml-tools/jail/Makefile delete mode 100644 src/uml-tools/jail/jail_uml.c delete mode 100644 src/uml-tools/net/Makefile delete mode 100644 src/uml-tools/net/README delete mode 100644 src/uml-tools/net/ethertap_helper.c delete mode 100644 src/uml-tools/net/input.c delete mode 100644 src/uml-tools/net/output.c delete mode 100644 src/uml-tools/net/um_eth.h delete mode 100644 src/uml-tools/net/um_eth_serv.c delete mode 100644 src/uml-tools/net/um_eth_tool.c delete mode 100644 src/uml-tools/rpm/Makefile delete mode 100644 src/uml-tools/rpm/uml.spec.in delete mode 100644 src/uml-tools/test/COPYING delete mode 100644 src/uml-tools/test/Makefile delete mode 100644 src/uml-tools/test/README delete mode 100644 src/uml-tools/test/UML.pm delete mode 100644 src/uml-tools/test/tsuite.pl delete mode 100644 src/uml-tools/uml_router/hash.h diff --git a/src/tools-20070815/.pc/.version b/src/tools-20070815/.pc/.version new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/src/tools-20070815/.pc/.version @@ -0,0 +1 @@ +2 diff --git a/src/tools-20070815/.pc/applied-patches b/src/tools-20070815/.pc/applied-patches new file mode 100644 index 0000000..12891c0 --- /dev/null +++ b/src/tools-20070815/.pc/applied-patches @@ -0,0 +1 @@ +tunctl-setgroup diff --git a/src/tools-20070815/.pc/tunctl-setgroup/.timestamp b/src/tools-20070815/.pc/tunctl-setgroup/.timestamp new file mode 100644 index 0000000..e69de29 diff --git a/src/uml-tools/tunctl/tunctl.c b/src/tools-20070815/.pc/tunctl-setgroup/tunctl/tunctl.c similarity index 100% rename from src/uml-tools/tunctl/tunctl.c rename to src/tools-20070815/.pc/tunctl-setgroup/tunctl/tunctl.c diff --git a/src/uml-tools/COPYING b/src/tools-20070815/COPYING similarity index 100% rename from src/uml-tools/COPYING rename to src/tools-20070815/COPYING diff --git a/src/tools-20070815/CVS/Entries b/src/tools-20070815/CVS/Entries new file mode 100644 index 0000000..cc654d0 --- /dev/null +++ b/src/tools-20070815/CVS/Entries @@ -0,0 +1,21 @@ +/COPYING/1.1/Tue Oct 9 02:22:36 2001// +D/gdbbot//// +D/mconsole//// +D/moo//// +D/net//// +D/redhat//// +D/rpm//// +D/test//// +D/transformiix//// +D/uml_net//// +D/uml_router//// +D/umn//// +D/port-helper//// +D/jailtest//// +D/tunctl//// +D/umlgdb//// +D/watchdog//// +D/jail//// +D/honeypot//// +/Makefile/1.13/Sat Feb 8 04:01:52 2003// +/uml_util.spec.in/1.4/Wed Jan 14 09:56:31 2004// diff --git a/src/tools-20070815/CVS/Repository b/src/tools-20070815/CVS/Repository new file mode 100644 index 0000000..ef1aab0 --- /dev/null +++ b/src/tools-20070815/CVS/Repository @@ -0,0 +1 @@ +tools diff --git a/src/tools-20070815/CVS/Root b/src/tools-20070815/CVS/Root new file mode 100644 index 0000000..4f921bb --- /dev/null +++ b/src/tools-20070815/CVS/Root @@ -0,0 +1 @@ +jdike@cvs.user-mode-linux.sourceforge.net:/cvsroot/user-mode-linux diff --git a/src/tools-20070815/Changelog b/src/tools-20070815/Changelog new file mode 100644 index 0000000..dbcef91 --- /dev/null +++ b/src/tools-20070815/Changelog @@ -0,0 +1,32 @@ +BB - + shebangs added where needed + fixed the command line handling in honeypot.pl + the jail Makefile installs things now + jail_uml handles user names as well as uids and sets its group + CFLAGS is now settable at the top level + cleanups in uml_mconsole + 64-bit fixes, fixing of broken 64-bit COW files, and other +cleanups in uml_moo + bug fix in uml_net's handling of a SLIP interface going down + moved the uml_router directory to uml_switch + cleanups in uml_switch + added a spec file + +Me - + BB's tarball contained a tools-$DATE with a tools subdirectory - the + subdirectory had newer stuff, so I started with that. + + Cleaned up the honeypot.pl changes + + Spurious tab in jail/Makefile + + Ignored BB's redeclaration of jailtest main - I prefer correct +declarations even when the arguments aren't used. + + Removed uml_util.spec, which is generated + + Added a lib directory which contains send_fd() + + Added umlfs and umlfs support to uml_mconsole + +From dgraves - mconsole int diff --git a/src/uml-tools/Makefile b/src/tools-20070815/Makefile similarity index 51% rename from src/uml-tools/Makefile rename to src/tools-20070815/Makefile index 742bdc6..fd00f6a 100644 --- a/src/uml-tools/Makefile +++ b/src/tools-20070815/Makefile @@ -1,19 +1,30 @@ TUNCTL = $(shell [ -e /usr/include/linux/if_tun.h ] && echo tunctl) -SUBDIRS = jail jailtest humfsify mconsole moo port-helper $(TUNCTL) uml_net \ - uml_router watchdog +SUBDIRS = lib jail jailtest humfsify mconsole moo port-helper $(TUNCTL) \ + uml_net uml_switch watchdog umlfs UMLVER = $(shell date +%Y%m%d) -TARBALL = uml_utilities_$(UMLVER).tar +TARBALL = uml_utilities_$(UMLVER).tar.bz2 BIN_DIR = /usr/bin + +ifeq ($(shell uname -m),x86_64) +LIB_DIR = /usr/lib64/uml +else LIB_DIR = /usr/lib/uml +endif + +CFLAGS = -g -Wall +#CFLAGS = -g -O2 -Wall -export BIN_DIR LIB_DIR +export BIN_DIR LIB_DIR CFLAGS all install: set -e ; for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@; done tarball : clean spec - cd .. ; tar cf $(TARBALL) tools ; bzip2 -f $(TARBALL) + cd .. ; \ + mv tools tools-$(UMLVER); \ + tar cjf $(TARBALL) tools-$(UMLVER); \ + mv tools-$(UMLVER) tools clean: rm -rf *~ diff --git a/src/tools-20070815/Makefile.orig b/src/tools-20070815/Makefile.orig new file mode 100644 index 0000000..fd00f6a --- /dev/null +++ b/src/tools-20070815/Makefile.orig @@ -0,0 +1,35 @@ +TUNCTL = $(shell [ -e /usr/include/linux/if_tun.h ] && echo tunctl) + +SUBDIRS = lib jail jailtest humfsify mconsole moo port-helper $(TUNCTL) \ + uml_net uml_switch watchdog umlfs +UMLVER = $(shell date +%Y%m%d) +TARBALL = uml_utilities_$(UMLVER).tar.bz2 +BIN_DIR = /usr/bin + +ifeq ($(shell uname -m),x86_64) +LIB_DIR = /usr/lib64/uml +else +LIB_DIR = /usr/lib/uml +endif + +CFLAGS = -g -Wall +#CFLAGS = -g -O2 -Wall + +export BIN_DIR LIB_DIR CFLAGS + +all install: + set -e ; for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@; done + +tarball : clean spec + cd .. ; \ + mv tools tools-$(UMLVER); \ + tar cjf $(TARBALL) tools-$(UMLVER); \ + mv tools-$(UMLVER) tools + +clean: + rm -rf *~ + rm -f uml_util.spec + set -e ; for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@; done + +spec: + sed -e 's/__UMLVER__/$(UMLVER)/' < uml_util.spec.in > uml_util.spec diff --git a/src/tools-20070815/Makefile.rej b/src/tools-20070815/Makefile.rej new file mode 100644 index 0000000..e563012 --- /dev/null +++ b/src/tools-20070815/Makefile.rej @@ -0,0 +1,11 @@ +--- Makefile 2004-04-08 03:42:59.000000000 +0200 ++++ Makefile 2009-05-01 23:31:00.106571852 +0200 +@@ -1,7 +1,7 @@ + TUNCTL = $(shell [ -e /usr/include/linux/if_tun.h ] && echo tunctl) + + SUBDIRS = jail jailtest humfsify mconsole moo port-helper $(TUNCTL) uml_net \ +- uml_router watchdog ++ uml_router watchdog uml_dump + UMLVER = $(shell date +%Y%m%d) + TARBALL = uml_utilities_$(UMLVER).tar + BIN_DIR = /usr/bin diff --git a/src/uml-tools/gdb/gdbinit b/src/tools-20070815/gdb/gdbinit similarity index 100% rename from src/uml-tools/gdb/gdbinit rename to src/tools-20070815/gdb/gdbinit diff --git a/src/tools-20070815/gdbbot/CVS/Entries b/src/tools-20070815/gdbbot/CVS/Entries new file mode 100644 index 0000000..9da40eb --- /dev/null +++ b/src/tools-20070815/gdbbot/CVS/Entries @@ -0,0 +1,2 @@ +/gdbbot.pl/1.3/Thu Jul 5 19:18:58 2001// +D diff --git a/src/tools-20070815/gdbbot/CVS/Repository b/src/tools-20070815/gdbbot/CVS/Repository new file mode 100644 index 0000000..4ac6723 --- /dev/null +++ b/src/tools-20070815/gdbbot/CVS/Repository @@ -0,0 +1 @@ +tools/gdbbot diff --git a/src/tools-20070815/gdbbot/CVS/Root b/src/tools-20070815/gdbbot/CVS/Root new file mode 100644 index 0000000..4f921bb --- /dev/null +++ b/src/tools-20070815/gdbbot/CVS/Root @@ -0,0 +1 @@ +jdike@cvs.user-mode-linux.sourceforge.net:/cvsroot/user-mode-linux diff --git a/src/uml-tools/gdbbot/gdbbot.pl b/src/tools-20070815/gdbbot/gdbbot.pl similarity index 100% rename from src/uml-tools/gdbbot/gdbbot.pl rename to src/tools-20070815/gdbbot/gdbbot.pl diff --git a/src/tools-20070815/honeypot/CVS/CVS/Entries b/src/tools-20070815/honeypot/CVS/CVS/Entries new file mode 100644 index 0000000..1784810 --- /dev/null +++ b/src/tools-20070815/honeypot/CVS/CVS/Entries @@ -0,0 +1 @@ +D diff --git a/src/tools-20070815/honeypot/CVS/CVS/Repository b/src/tools-20070815/honeypot/CVS/CVS/Repository new file mode 100644 index 0000000..f24a78e --- /dev/null +++ b/src/tools-20070815/honeypot/CVS/CVS/Repository @@ -0,0 +1 @@ +tools/honeypot/CVS diff --git a/src/tools-20070815/honeypot/CVS/CVS/Root b/src/tools-20070815/honeypot/CVS/CVS/Root new file mode 100644 index 0000000..4f921bb --- /dev/null +++ b/src/tools-20070815/honeypot/CVS/CVS/Root @@ -0,0 +1 @@ +jdike@cvs.user-mode-linux.sourceforge.net:/cvsroot/user-mode-linux diff --git a/src/tools-20070815/honeypot/CVS/Entries b/src/tools-20070815/honeypot/CVS/Entries new file mode 100644 index 0000000..7cda625 --- /dev/null +++ b/src/tools-20070815/honeypot/CVS/Entries @@ -0,0 +1,4 @@ +D/CVS//// +/hppfs.pm/1.3/Wed Jan 22 20:40:26 2003// +/honeypot.pl/1.6/Thu Jul 31 18:10:52 2003// +/hppfslib.pm/1.4/Thu Jul 31 18:12:39 2003// diff --git a/src/tools-20070815/honeypot/CVS/Repository b/src/tools-20070815/honeypot/CVS/Repository new file mode 100644 index 0000000..c4cc7f6 --- /dev/null +++ b/src/tools-20070815/honeypot/CVS/Repository @@ -0,0 +1 @@ +tools/honeypot diff --git a/src/tools-20070815/honeypot/CVS/Root b/src/tools-20070815/honeypot/CVS/Root new file mode 100644 index 0000000..4f921bb --- /dev/null +++ b/src/tools-20070815/honeypot/CVS/Root @@ -0,0 +1 @@ +jdike@cvs.user-mode-linux.sourceforge.net:/cvsroot/user-mode-linux diff --git a/src/uml-tools/honeypot/honeypot.pl b/src/tools-20070815/honeypot/honeypot.pl similarity index 51% rename from src/uml-tools/honeypot/honeypot.pl rename to src/tools-20070815/honeypot/honeypot.pl index 63cb07e..b2a2e90 100644 --- a/src/uml-tools/honeypot/honeypot.pl +++ b/src/tools-20070815/honeypot/honeypot.pl @@ -1,3 +1,4 @@ +#!/usr/bin/perl # # Copyright (C) 2002, 2003 Jeff Dike (jdike@karaya.com) # Licensed under the GPL @@ -9,7 +10,10 @@ my $dir; -@ARGV and $dir = $ARGV[0]; +@ARGV and $dir = $ARGV[0] or die "Not enough arguments - pass dir where UML will be running"; + +# !mkdir $dir and warn "Couldn't create '$dir' : $!"; +!mkdir "$dir/proc" and warn "Couldn't create '$dir/proc' : $!"; my $hppfs = hppfs->new($dir); @@ -19,20 +23,20 @@ # partitions needs work # slabinfo if UML ever uses the slab cache for anything -$hppfs->add("cmdline" => proc("cmdline"), - "cpuinfo" => proc("cpuinfo"), - "dma" => proc("dma"), +$hppfs->add("cmdline" => host_proc("cmdline"), + "cpuinfo" => host_proc("cpuinfo"), + "dma" => host_proc("dma"), "devices" => remove_lines("ubd"), "exitcode" => "remove", "filesystems" => $remove_filesystems, - "interrupts" => proc("interrupts"), - "iomem" => proc("iomem"), - "ioports" => proc("ioports"), + "interrupts" => host_proc("interrupts"), + "iomem" => host_proc("iomem"), + "ioports" => host_proc("ioports"), "mounts" => $remove_filesystems, "pid/mounts" => $remove_filesystems, - "stat" => proc("stat"), - "uptime" => proc("uptime"), - "version" => proc("version"), + "stat" => host_proc("stat"), + "uptime" => host_proc("uptime"), + "version" => host_proc("version"), dup_proc_dir("bus", $dir) ); $hppfs->handler(); diff --git a/src/uml-tools/honeypot/hppfs.pm b/src/tools-20070815/honeypot/hppfs.pm similarity index 100% rename from src/uml-tools/honeypot/hppfs.pm rename to src/tools-20070815/honeypot/hppfs.pm diff --git a/src/uml-tools/honeypot/hppfslib.pm b/src/tools-20070815/honeypot/hppfslib.pm similarity index 86% rename from src/uml-tools/honeypot/hppfslib.pm rename to src/tools-20070815/honeypot/hppfslib.pm index 75e93fa..a43af24 100644 --- a/src/uml-tools/honeypot/hppfslib.pm +++ b/src/tools-20070815/honeypot/hppfslib.pm @@ -11,7 +11,7 @@ use vars qw(@ISA @EXPORT); use strict; @ISA = qw(Exporter); -@EXPORT = qw(&remove_lines &host &proc &dup_proc_dir); +@EXPORT = qw(&remove_lines &host &host_proc &dup_proc_dir); sub remove_lines { my @remove = @_; @@ -32,7 +32,7 @@ sub host { "r" ] ); } -sub proc { +sub host_proc { my $file = shift; return(host("/proc/$file")); @@ -41,7 +41,7 @@ sub proc { sub dup_proc_dir { my $to = shift; my $root = shift; - my $new = "$root/$to"; + my $new = "$root/proc/$to"; -e $new and `rm -rf $new`; !mkdir $new and warn "Couldn't create '$new' : $!"; @@ -58,7 +58,7 @@ sub dup_proc_dir { my @files = `cd /proc ; find $to -type f -print`; chomp @files; - return(map { $_ => proc($_) } @files); + return(map { $_ => host_proc($_) } @files); } 1; diff --git a/src/tools-20070815/humfsify/Makefile b/src/tools-20070815/humfsify/Makefile new file mode 100644 index 0000000..61a283f --- /dev/null +++ b/src/tools-20070815/humfsify/Makefile @@ -0,0 +1,10 @@ +BIN = humfsify + +all: + +install: + install -d $(DESTDIR)$(BIN_DIR) + install -o 0755 $(BIN) $(DESTDIR)$(BIN_DIR) + +clean: + rm -f *~ diff --git a/src/tools-20070815/humfsify/humfsify b/src/tools-20070815/humfsify/humfsify new file mode 100644 index 0000000..fd6defe --- /dev/null +++ b/src/tools-20070815/humfsify/humfsify @@ -0,0 +1,427 @@ +#!/usr/bin/perl +use strict; + +my $VERSION = 2; + +if(@ARGV[0] eq "-r"){ + unhumfsify(); +} +else { + meta_fs(@ARGV); +} + +exit 0; + +sub meta_fs { + my ($user, $group, $size) = @_; + if(!defined($user) || !defined($group) || !defined($size)){ + print "Usage: $0 user group size\n"; + exit(1); + } + + my $save_user = $user; + $user !~ /^[0-9]+$/ and $user = getpwnam($user); + if(!defined($user)){ + print "User '$save_user' not present in the password file\n"; + exit(1); + } + + my $save_group = $group; + $group !~ /^[0-9]+$/ and $group = getgrnam($group); + if(!defined($group)){ + print "Group '$save_group' not present in the groups file\n"; + exit(1); + } + + my %mult = ( K => 1024, M => 1024 * 1024, G => 1024 * 1024 * 1024 ); + + my $sizeb = $size; + $sizeb =~ s/^([0-9]+)([KMG])$/$1*$mult{$2}/e; + + if ($sizeb !~ /^[0-9]+$/) { + print "Bad filesystem size - '$size'\n"; + exit(1); + } + + # Do this here so we bomb out quickly if there are any problems writing + # the superblock file + open SUPER, "> superblock" || die "Couldn't open superblock : $!"; + + my $used = `du -sk data`; + chomp $used; + $used =~ s/^([0-9]+)\s*data$/$1*1024/e; + + if($used > $sizeb){ + print "Current disk usage greater than the requested size - " . + "$used vs $sizeb\n"; + exit(1); + } + + my $pwd = `pwd`; + chomp $pwd; + $pwd !~ /\/$/ and $pwd .= "/"; + chdir "data"; + + if(!(open FILES, "find . | ")){ + print "Couldn't start a find in 'data' - error = $!\n"; + exit(1); + } + + my %links = (); + + while(){ + my $file = $_; + chomp $file; + + my ($mode, $uid, $gid, $dev, $links, $inode, $fsdev) = + (lstat($file))[2, 4, 5, 6, 3, 1, 0 ]; + + my $which = (! -l $file && -d $file ? "dir" : "file"); + + $mode &= 0777; + + my @segments = split(/\//, $file); + my $last = pop @segments; + my $dir = join("/", @segments); + + my $meta_dir = "${pwd}${which}_metadata/$dir"; + my $meta = "$meta_dir/$last"; + + if($which eq "dir"){ + my $out = `mkdir -p "${pwd}file_metadata/$dir/$last" 2>&1`; + if($? != 0){ + print "mkdir -p '${pwd}file_metadata/$dir/$last' failed, " . + "exit status = $?, output = '$out'\n"; + exit(1); + } + + $meta_dir = $meta; + $meta .= "/metadata"; + } + + my $extra = ""; + + my $out = `mkdir -p "$meta_dir" 2>&1`; + if($? != 0){ + print "mkdir -p '$meta_dir' failed, exit status = $?, " . + "output = '$out'\n"; + exit(1); + } + chown $user, $group, $meta_dir; + + if($links > 1){ + if(defined($links{"$inode $fsdev"})){ + my $from = "${pwd}${which}_metadata/$file"; + my $to = "${pwd}${which}_metadata/" . $links{"$inode $fsdev"}; + !link $to, $from and + warn "linking '$from' to '$to' failed - $!"; + next; + } + else { + $links{"$inode $fsdev"} = $file; + } + } + + if(-c $file || -b $file){ + my $major = $dev >> 8; + my $minor = $dev % 0x100; + $extra = (-c $file) ? " c" : " b"; + $extra .= " $major $minor"; + } + + ! -l $file and chmod 0755, $file; + chown_file($file, $user, $group); + + open META, ">$meta" or die "Can't open metadata file '$meta': $!"; + print META "$mode $uid $gid$extra\n"; + close META; + chown $user, $group, $meta; + } + + chdir $pwd; + + my $out = `find file_metadata -type d | xargs chown $user.$group 2>&1`; + if($? != 0){ + print "'find file_metadata -type d | xargs chown $user.$group' " . + "failed, exit status = $?, output = '$out'\n"; + exit(1); + } + + print SUPER <){ + my $line = $_; + if($line =~ /^version\s+([0-9]+)$/){ + $version = $1; + } + elsif($line =~ /used\s+([0-9]+)$/){ + $used = $1; + } + elsif($line =~ /total\s+([0-9]+)$/){ + $total = $1; + } + elsif($line =~ /metadata\s+([\w-]+)$/){ + $metadata = $1; + } + } + + ($version == 1) && !defined($metadata) and $metadata = "shadow_fs"; + + !defined($version) and die "Bogus superblock - version not defined"; + !defined($metadata) and die "Bogus superblock - metadata not defined"; + !defined($used) and die "Bogus superblock - used not defined"; + !defined($total) and die "Bogus superblock - total not defined"; + + $used > $total and die "Bogus superblock - used > total"; + + if($version == 1){ + $metadata ne "shadow_fs" and + die "Metadata format '$metadata' isn't supported by version 1"; + unhumfsify_shadow_fs_v1(); + } + elsif($version == 2){ + $metadata ne "shadow_fs" and + die "Metadata format '$metadata' isn't supported by version 2"; + unhumfsify_shadow_fs_v2(); + } + else { + die "Unsupported version - $version"; + } +} + +sub validate_number { + my $number = shift; + my $name = shift; + my $file = shift; + + $number =~ /[0-9]+/ and return(0); + + warn "Bogus $name ('$number') in $file"; + return(1); +} + +sub unhumfsify_shadow_fs_v1 { + my $problems = 0; + my $pwd = `pwd`; + chomp $pwd; + $pwd !~ /\/$/ and $pwd .= "/"; + chdir "metadata"; + + if(!(open FILES, "find . | ")){ + print "Couldn't start a find in 'data' - error = $!\n"; + exit(1); + } + + while(){ + my $bad = 0; + my $file = $_; + chomp $file; + + $file =~ /\/metadata$/ and next; + + my $meta = "${pwd}metadata/$file"; + if(-d $file){ + $meta .= "/metadata"; + } + + open META, "<$meta" or die "Can't open metadata file '$meta': $!"; + my @fields = split(" ", ); + my ($uid, $gid, $major, $type, $major, $minor) = @fields; + close META; + + $bad += validate_number($uid, "uid", $meta); + $bad += validate_number($gid, "gid", $meta); + + if(($type eq "c") || ($type eq "b")){ + $bad += validate_number($major, "major", $meta); + $bad += validate_number($minor, "minor", $meta); + } + elsif(defined($type) && ($type ne "s")){ + warn "Bogus file type ('$type') in '$meta'"; + $bad++; + } + + $problems += $bad; + $bad != 0 and next; + + my $data = "${pwd}/data/$file"; + if(($type eq "c") || ($type eq "b")){ + if(!unlink $data){ + warn "Couldn't delete '$data' - $!"; + $problems++; + } + + my $out = `mknod $data $type $major $minor 2>&1`; + if($? != 0){ + warn "Couldn't 'mknod $data $type $major $minor' - " . + "exit status = $?, output = '$out'\n"; + $problems++; + } + } + elsif($type eq "s"){ + warn "Can't make Unix socket '$data' from perl"; + $problems++; + } + else { + my $out = `chown -h $uid.$gid $data 2>&1`; + if($? != 0){ + warn "Couldn't chown '$data' to $uid, $gid - " . + "exit status $?, output - '$out'"; + $problems++; + } + } + } + + if($problems != 0){ + print <&1`; + $? != 0 and + die "Couldn't remove the metadata directory - " . + "exit status of rm = $?, output = '$out'"; + } +} + +sub chown_file { + my $file = shift; + my $uid = shift; + my $gid = shift; + + my $out = `chown -h $uid.$gid $file 2>&1`; + if($? != 0){ + warn "Couldn't chown '$file' to $uid, $gid - exit status $?, " . + "output - '$out'"; + return(1); + } + + return(0); +} + +sub unhumfsify_shadow_fs_v2 { + my $problems = 0; + my $pwd = `pwd`; + chomp $pwd; + $pwd !~ /\/$/ and $pwd .= "/"; + chdir "dir_metadata"; + + if(!(open FILES, "find . \! -type d | ")){ + print "Couldn't start a find in 'data' - error = $!\n"; + exit(1); + } + + while(){ + my $bad = 0; + my $file = $_; + chomp $file; + + open META, "<$file" or die "Can't open metadata file '$file': $!"; + my @fields = split(" ", ); + my ($mode, $uid, $gid) = @fields; + close META; + + $bad += validate_number($mode, "mode", $file); + $bad += validate_number($uid, "uid", $file); + $bad += validate_number($gid, "gid", $file); + + $problems += $bad; + $bad != 0 and next; + + my $data = `dirname ${pwd}/data/$file`; + chomp $data; + + $problems += chown_file($data, $uid, $gid); + $problems += chmod $data, $mode; + } + + + chdir "../file_metadata"; + if(!(open FILES, "find . \! -type d | ")){ + print "Couldn't start a find in 'data' - error = $!\n"; + exit(1); + } + + while(){ + my $bad = 0; + my $file = $_; + chomp $file; + + my $meta = "${pwd}file_metadata/$file"; + + open META, "<$meta" or die "Can't open metadata file '$meta': $!"; + my @fields = split(" ", ); + my ($mode, $uid, $gid, $type, $major, $minor) = @fields; + close META; + + $bad += validate_number($mode, "mode", $meta); + $bad += validate_number($uid, "uid", $meta); + $bad += validate_number($gid, "gid", $meta); + + if(($type eq "c") || ($type eq "b")){ + $bad += validate_number($major, "major", $meta); + $bad += validate_number($minor, "minor", $meta); + } + elsif(defined($type) && ($type ne "s")){ + warn "Bogus file type ('$type') in '$meta'"; + $bad++; + } + + $problems += $bad; + $bad != 0 and next; + + my $data = "${pwd}/data/$file"; + if(($type eq "c") || ($type eq "b")){ + if(!unlink $data){ + warn "Couldn't delete '$data' - $!"; + $problems++; + } + + my $out = `mknod $data $type $major $minor 2>&1`; + if($? != 0){ + warn "Couldn't 'mknod $data $type $major $minor' - " . + "exit status = $?, output = '$out'\n"; + $problems++; + } + } + elsif($type eq "s"){ + warn "Can't make Unix socket '$data' from perl"; + $problems++; + } + + $problems += chown_file($data, $uid, $gid); + ! -l $data and chmod $mode, $data; + } + + if($problems != 0){ + print <&1`; + $? != 0 and + die "Couldn't remove the metadata directories - " . + "exit status of rm = $?, output = '$out'"; + } +} diff --git a/src/tools-20070815/jail/CVS/Entries b/src/tools-20070815/jail/CVS/Entries new file mode 100644 index 0000000..7196269 --- /dev/null +++ b/src/tools-20070815/jail/CVS/Entries @@ -0,0 +1,10 @@ +/cell.tar/1.1/Fri Jun 14 01:08:18 2002// +/jail_uml.c/1.2/Mon Jul 22 17:37:43 2002// +/Makefile/1.3/Wed Jan 22 18:23:54 2003// +/tty_log.pl/1.2/Wed Jan 29 18:14:40 2003// +/tty_log.pm/1.3/Thu Jun 12 17:10:50 2003// +/db_out.pm/1.1/Wed Nov 19 10:46:34 2003// +/playlog.pl/1.4/Wed Nov 19 10:47:41 2003// +/tty_out.pm/1.1/Wed Nov 19 10:46:28 2003// +/jailer.pl/1.7/Thu Sep 25 20:43:37 2003// +D diff --git a/src/tools-20070815/jail/CVS/Repository b/src/tools-20070815/jail/CVS/Repository new file mode 100644 index 0000000..b843fdb --- /dev/null +++ b/src/tools-20070815/jail/CVS/Repository @@ -0,0 +1 @@ +tools/jail diff --git a/src/tools-20070815/jail/CVS/Root b/src/tools-20070815/jail/CVS/Root new file mode 100644 index 0000000..4f921bb --- /dev/null +++ b/src/tools-20070815/jail/CVS/Root @@ -0,0 +1 @@ +jdike@cvs.user-mode-linux.sourceforge.net:/cvsroot/user-mode-linux diff --git a/src/tools-20070815/jail/Makefile b/src/tools-20070815/jail/Makefile new file mode 100644 index 0000000..4419d1e --- /dev/null +++ b/src/tools-20070815/jail/Makefile @@ -0,0 +1,17 @@ +OBJS = jail_uml.o +BIN = jail_uml +CFLAGS ?= -g -Wall + +SBIN_DIR ?= /usr/sbin + +all : $(BIN) + +$(BIN) : $(OBJS) + $(CC) $(CFLAGS) -o $(BIN) $(OBJS) + +install : $(BIN) + install -d $(DESTDIR)$(SBIN_DIR) + install -s $(BIN) $(DESTDIR)$(SBIN_DIR) + +clean : + rm -rf *~ $(BIN) $(OBJS) cell[0-9]* core* tty_log_cell* diff --git a/src/uml-tools/jail/cell.tar b/src/tools-20070815/jail/cell.tar similarity index 100% rename from src/uml-tools/jail/cell.tar rename to src/tools-20070815/jail/cell.tar diff --git a/src/uml-tools/jail/db_out.pm b/src/tools-20070815/jail/db_out.pm similarity index 100% rename from src/uml-tools/jail/db_out.pm rename to src/tools-20070815/jail/db_out.pm diff --git a/src/tools-20070815/jail/jail_uml.c b/src/tools-20070815/jail/jail_uml.c new file mode 100644 index 0000000..33d7b5d --- /dev/null +++ b/src/tools-20070815/jail/jail_uml.c @@ -0,0 +1,81 @@ +/* jail a uml into a directory. + +*/ + +#include +#include +#include +#include +#include +#include +#include + +static void Usage(void) +{ + fprintf(stderr, "Usage : jail_uml jail-directory user " + "uml-command-line ...\n"); + fprintf(stderr, " or: jail_uml jail-directory uid " + "uml-command-line ...\n\n"); + fprintf(stderr, "If the user is not found, it's assumed to be a uid.\n"); + exit(1); +} + +int main(int argc, char **argv) +{ + char *dir, *end; + char *user; + struct passwd *pw; + int uid, gid=99; + gid_t gidset[1]; + gidset[0]=gid; + + if(geteuid() != 0){ + fprintf(stderr, "jail_uml must be run as root\n"); + exit(1); + } + + if(argc < 3) Usage(); + dir = argv[1]; + user = argv[2]; + + // get users password information + pw = getpwnam (user); + if (pw == NULL){ + uid = strtoul(argv[2], &end, 0); + if(*end != '\0') Usage(); + setgroups(1, gidset); + } else { + // try to init groups + initgroups (pw->pw_name, pw->pw_gid); + uid = pw->pw_uid; + gid = pw->pw_gid; + } + + // if(*end != '\0') Usage(); + argc -= 3; + argv += 3; + + if(chdir(dir)){ + perror("chdir"); + exit(1); + } + + if(chroot(".")){ + perror("chroot"); + exit(1); + } + + if(setgid(gid)){ + perror("setgid"); + exit(1); + } + if(setuid(uid)){ + perror("setuid"); + exit(1); + } + + execv(argv[0], argv); + fprintf(stderr, "execve of %s failed : ", argv[0]); + perror(""); + exit(1); +} diff --git a/src/uml-tools/jail/jailer.pl b/src/tools-20070815/jail/jailer.pl similarity index 100% rename from src/uml-tools/jail/jailer.pl rename to src/tools-20070815/jail/jailer.pl diff --git a/src/uml-tools/jail/playlog.pl b/src/tools-20070815/jail/playlog.pl similarity index 100% rename from src/uml-tools/jail/playlog.pl rename to src/tools-20070815/jail/playlog.pl diff --git a/src/uml-tools/jail/tty_log.pl b/src/tools-20070815/jail/tty_log.pl similarity index 100% rename from src/uml-tools/jail/tty_log.pl rename to src/tools-20070815/jail/tty_log.pl diff --git a/src/uml-tools/jail/tty_log.pm b/src/tools-20070815/jail/tty_log.pm similarity index 100% rename from src/uml-tools/jail/tty_log.pm rename to src/tools-20070815/jail/tty_log.pm diff --git a/src/uml-tools/jail/tty_out.pm b/src/tools-20070815/jail/tty_out.pm similarity index 100% rename from src/uml-tools/jail/tty_out.pm rename to src/tools-20070815/jail/tty_out.pm diff --git a/src/tools-20070815/jailtest/CVS/CVS/Entries b/src/tools-20070815/jailtest/CVS/CVS/Entries new file mode 100644 index 0000000..1784810 --- /dev/null +++ b/src/tools-20070815/jailtest/CVS/CVS/Entries @@ -0,0 +1 @@ +D diff --git a/src/tools-20070815/jailtest/CVS/CVS/Repository b/src/tools-20070815/jailtest/CVS/CVS/Repository new file mode 100644 index 0000000..244ccc6 --- /dev/null +++ b/src/tools-20070815/jailtest/CVS/CVS/Repository @@ -0,0 +1 @@ +tools/jailtest/CVS diff --git a/src/tools-20070815/jailtest/CVS/CVS/Root b/src/tools-20070815/jailtest/CVS/CVS/Root new file mode 100644 index 0000000..4f921bb --- /dev/null +++ b/src/tools-20070815/jailtest/CVS/CVS/Root @@ -0,0 +1 @@ +jdike@cvs.user-mode-linux.sourceforge.net:/cvsroot/user-mode-linux diff --git a/src/tools-20070815/jailtest/CVS/Entries b/src/tools-20070815/jailtest/CVS/Entries new file mode 100644 index 0000000..6ea96e2 --- /dev/null +++ b/src/tools-20070815/jailtest/CVS/Entries @@ -0,0 +1,3 @@ +D/CVS//// +/jailtest.c/1.1/Fri Jan 25 19:59:48 2002// +/Makefile/1.2/Sat Feb 8 04:10:27 2003// diff --git a/src/tools-20070815/jailtest/CVS/Repository b/src/tools-20070815/jailtest/CVS/Repository new file mode 100644 index 0000000..9dac754 --- /dev/null +++ b/src/tools-20070815/jailtest/CVS/Repository @@ -0,0 +1 @@ +tools/jailtest diff --git a/src/tools-20070815/jailtest/CVS/Root b/src/tools-20070815/jailtest/CVS/Root new file mode 100644 index 0000000..4f921bb --- /dev/null +++ b/src/tools-20070815/jailtest/CVS/Root @@ -0,0 +1 @@ +jdike@cvs.user-mode-linux.sourceforge.net:/cvsroot/user-mode-linux diff --git a/src/uml-tools/jailtest/Makefile b/src/tools-20070815/jailtest/Makefile similarity index 92% rename from src/uml-tools/jailtest/Makefile rename to src/tools-20070815/jailtest/Makefile index 3a92c94..1029df8 100644 --- a/src/uml-tools/jailtest/Makefile +++ b/src/tools-20070815/jailtest/Makefile @@ -1,6 +1,6 @@ OBJS = jailtest.o BIN = jailtest -CFLAGS = -g -Wall +CFLAGS ?= -g -Wall BIN_DIR ?= /usr/bin diff --git a/src/uml-tools/jailtest/jailtest.c b/src/tools-20070815/jailtest/jailtest.c similarity index 100% rename from src/uml-tools/jailtest/jailtest.c rename to src/tools-20070815/jailtest/jailtest.c diff --git a/src/tools-20070815/lib/Makefile b/src/tools-20070815/lib/Makefile new file mode 100644 index 0000000..6efdcc4 --- /dev/null +++ b/src/tools-20070815/lib/Makefile @@ -0,0 +1,13 @@ +LIB = libuml.a +OBJS = rights.o +CFLAGS = -g -Wall + +all : $(LIB) + +$(LIB) : $(OBJS) + $(AR) r $@ $< + +clean : + rm -f $(LIB) $(OBJS) + +install : diff --git a/src/tools-20070815/lib/rights.c b/src/tools-20070815/lib/rights.c new file mode 100644 index 0000000..30bff6e --- /dev/null +++ b/src/tools-20070815/lib/rights.c @@ -0,0 +1,45 @@ +#include +#include +#include + +/* pass the fd over an fd that is already connected to a socket */ +int send_fd(int fd, int target, struct sockaddr *to, int to_len, void *msg, + int msg_len) +{ + /* File descriptors are specific to a process and normally only + sharable with another process by inheritence with fork(). The + alternative is to use sendmsg with a special flag that says + "I'm knowingly giving another process information from my private + file descriptor table" (SCM_RIGHTS) + */ + + char anc[CMSG_SPACE(sizeof(fd))]; + struct msghdr hdr; + struct cmsghdr *cmsg; + struct iovec iov; + int *fd_ptr; + + hdr.msg_name = to; + hdr.msg_namelen = to_len; + iov = ((struct iovec) { iov_base : msg, + iov_len : msg_len }); + hdr.msg_iov = &iov; + hdr.msg_iovlen = 1; + hdr.msg_flags = 0; + hdr.msg_control = anc; + hdr.msg_controllen = sizeof(anc); + + cmsg = CMSG_FIRSTHDR(&hdr); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + cmsg->cmsg_len = CMSG_LEN(sizeof(fd)); + + fd_ptr = (int *) CMSG_DATA(cmsg); + *fd_ptr = fd; + + hdr.msg_controllen = cmsg->cmsg_len; + + if(sendmsg(target, &hdr, 0) < 0) + return -errno; + return 0; +} diff --git a/src/uml-tools/mconsole/.cvsignore b/src/tools-20070815/mconsole/.cvsignore similarity index 100% rename from src/uml-tools/mconsole/.cvsignore rename to src/tools-20070815/mconsole/.cvsignore diff --git a/src/tools-20070815/mconsole/CVS/Entries b/src/tools-20070815/mconsole/CVS/Entries new file mode 100644 index 0000000..b8abc1a --- /dev/null +++ b/src/tools-20070815/mconsole/CVS/Entries @@ -0,0 +1,5 @@ +/.cvsignore/1.1/Fri Jan 11 05:21:31 2002// +/notify.pl/1.1/Tue Feb 4 20:11:39 2003// +/Makefile/1.6/Sat Feb 8 04:10:08 2003// +/uml_mconsole.c/1.14/Fri Aug 29 20:47:14 2003// +D diff --git a/src/tools-20070815/mconsole/CVS/Repository b/src/tools-20070815/mconsole/CVS/Repository new file mode 100644 index 0000000..309fdaf --- /dev/null +++ b/src/tools-20070815/mconsole/CVS/Repository @@ -0,0 +1 @@ +tools/mconsole diff --git a/src/tools-20070815/mconsole/CVS/Root b/src/tools-20070815/mconsole/CVS/Root new file mode 100644 index 0000000..4f921bb --- /dev/null +++ b/src/tools-20070815/mconsole/CVS/Root @@ -0,0 +1 @@ +jdike@cvs.user-mode-linux.sourceforge.net:/cvsroot/user-mode-linux diff --git a/src/tools-20070815/mconsole/Makefile b/src/tools-20070815/mconsole/Makefile new file mode 100644 index 0000000..d015a34 --- /dev/null +++ b/src/tools-20070815/mconsole/Makefile @@ -0,0 +1,18 @@ +BIN = uml_mconsole +OBJS = $(BIN).o +CFLAGS ?= -g -Wall +LIBS = ../lib/libuml.a -lreadline -lncurses + +BIN_DIR ?= /usr/bin + +all : $(BIN) + +$(BIN) : $(OBJS) + $(CC) $(CFLAGS) -o $(BIN) $(OBJS) $(LIBS) + +clean : + rm -f $(BIN) $(OBJS) *~ + +install : $(BIN) + install -d $(DESTDIR)$(BIN_DIR) + install -s $(BIN) $(DESTDIR)$(BIN_DIR) diff --git a/src/uml-tools/mconsole/notify.pl b/src/tools-20070815/mconsole/notify.pl similarity index 100% rename from src/uml-tools/mconsole/notify.pl rename to src/tools-20070815/mconsole/notify.pl diff --git a/src/uml-tools/mconsole/uml_mconsole.c b/src/tools-20070815/mconsole/uml_mconsole.c similarity index 62% rename from src/uml-tools/mconsole/uml_mconsole.c rename to src/tools-20070815/mconsole/uml_mconsole.c index 47f48d6..3142b9f 100644 --- a/src/uml-tools/mconsole/uml_mconsole.c +++ b/src/tools-20070815/mconsole/uml_mconsole.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -40,44 +41,76 @@ static char uml_name[11]; static struct sockaddr_un sun; +static long uml_pid; -static int do_switch(char *file, char *name) +static int do_switch(char *dir, char *file, char *name) { - struct stat buf; - - if(stat(file, &buf) == -1){ - fprintf(stderr, "Warning: couldn't stat file: %s - ", file); - perror(""); - return(1); - } - sun.sun_family = AF_UNIX; - strncpy(sun.sun_path, file, sizeof(sun.sun_path)); - strncpy(uml_name, name, sizeof(uml_name)); - return(0); + struct stat buf; + char pid_path[MAXPATHLEN + 1]; + FILE *fp; + char pid[sizeof("12345\0")], *end; + int n, x = -1; + + if(stat(file, &buf) == -1){ + fprintf(stderr, "Warning: couldn't stat file: %s - ", file); + perror(""); + return 1; + } + sun.sun_family = AF_UNIX; + strncpy(sun.sun_path, file, sizeof(sun.sun_path)); + strncpy(uml_name, name, sizeof(uml_name)); + + /* Open and read PID file */ + uml_pid = -1; + + snprintf(pid_path, sizeof(pid_path), "%s/%s/pid", dir, name); + fp = fopen(pid_path, "r"); + if(fp == NULL) + return 0; + + while (!feof(fp) && !ferror(fp)) + fread(&pid[++x], sizeof(char), 1, fp); + + /* Convert read PID to number, or set PID to known error number */ + if (feof(fp) && !ferror(fp)){ + n = strtol(pid, &end, 10); + if(end != pid) + uml_pid = n; + } + + return 0; } static int switch_common(char *name) { - char file[MAXPATHLEN + 1], dir[MAXPATHLEN + 1], tmp[MAXPATHLEN + 1], *home; - int try_file = 1; - - if((home = getenv("HOME")) != NULL){ - snprintf(dir, sizeof(dir), "%s/.uml", home); - snprintf(file, sizeof(file), "%s/%s/mconsole", dir, name); - if(strncmp(name, dir, strlen(dir))){ - if(!do_switch(file, name)) return(0); - try_file = 0; - } - } - - snprintf(tmp, sizeof(tmp), "/tmp/uml/%s/mconsole", name); - if(strncmp(name, "/tmp/uml/", strlen("/tmp/uml/"))){ - if(!do_switch(tmp, name)) return(0); - } - - if(!do_switch(name, name)) return(0); - if(!try_file) return(-1); - return(do_switch(file, name)); + char file[MAXPATHLEN + 1], dir[MAXPATHLEN + 1], tmp[MAXPATHLEN + 1]; + char *home; + int try_file = 1; + + if((home = getenv("HOME")) != NULL){ + snprintf(dir, sizeof(dir), "%s/.uml", home); + snprintf(file, sizeof(file), "%s/%s/mconsole", dir, name); + if(strncmp(name, dir, strlen(dir))){ + if(!do_switch(dir, file, name)) return(0); + try_file = 0; + } + } + + snprintf(dir, sizeof(dir), "/tmp/uml/%s", name); + snprintf(tmp, sizeof(tmp), "/tmp/uml/%s/mconsole", name); + if(strncmp(name, "/tmp/uml/", strlen("/tmp/uml/"))){ + if(!do_switch(dir, tmp, name)) + return 0; + } + + snprintf(dir, sizeof(dir), "./"); + if(!do_switch(dir, name, name)) + return 0; + + if(!try_file) + return -1; + + return do_switch(dir, file, name); } #define MCONSOLE_MAGIC (0xcafebabe) @@ -98,10 +131,10 @@ struct mconsole_reply { char data[MCONSOLE_MAX_DATA]; }; -static char *absolutize(char *to, int size, char *from) +static char *absolutize(char *to, size_t size, char *from) { char save_cwd[MAXPATHLEN + 1], *slash; - int remaining; + size_t remaining; if(getcwd(save_cwd, sizeof(save_cwd)) == NULL) { perror("absolutize : unable to get cwd"); @@ -124,7 +157,7 @@ static char *absolutize(char *to, int size, char *from) } remaining = size - strlen(to); if(strlen(slash) + 1 > remaining){ - fprintf(stderr, "absolutize : unable to fit '%s' into %d chars\n", from, + fprintf(stderr, "absolutize : unable to fit '%s' into %zd chars\n", from, size); return(NULL); } @@ -132,7 +165,7 @@ static char *absolutize(char *to, int size, char *from) } else { if(strlen(save_cwd) + 1 + strlen(from) + 1 > size){ - fprintf(stderr, "absolutize : unable to fit '%s' into %d chars\n", from, + fprintf(stderr, "absolutize : unable to fit '%s' into %zd chars\n", from, size); return(NULL); } @@ -204,59 +237,87 @@ static int fix_filenames(char **cmd_ptr) return(1); } -static int default_cmd(int fd, char *command) +static int rcv_output(int fd, char **output) { - struct mconsole_request request; - struct mconsole_reply reply; - char name[128]; - int n, free_command, first; - - if((sscanf(command, "%128[^: \f\n\r\t\v]:", name) == 1) && - (*(name + 1) == ':')){ - if(switch_common(name)) - return(1); - command = strchr(command, ':'); - *command++ = '\0'; - while(isspace(*command)) command++; - } + struct mconsole_reply reply; + int n, err = 0, first = 1, len = 0; + + do { + n = recvfrom(fd, &reply, sizeof(reply), 0, NULL, 0); + if(n < 0){ + perror("recvmsg"); + return(1); + } + + err = reply.err ? 1 : err; + + *output = realloc(*output, len + strlen(reply.data) + 1); + if(*output == NULL){ + perror("realloc failed"); + return 1; + } + + if(first) + **output = '\0'; + strcat(*output, reply.data); + len += strlen(reply.data); + first = 0; + } while(reply.more); + + return reply.err; +} - free_command = fix_filenames(&command); +static void format_cmd(char *command, struct mconsole_request *request) +{ + *request = ((struct mconsole_request) + { .magic = MCONSOLE_MAGIC, + .version = MCONSOLE_VERSION, + .len = MIN(strlen(command), + sizeof(request->data) - 1) }); + strncpy(request->data, command, request->len); + request->data[request->len] = '\0'; +} - request.magic = MCONSOLE_MAGIC; - request.version = MCONSOLE_VERSION; - request.len = MIN(strlen(command), sizeof(reply.data) - 1); - strncpy(request.data, command, request.len); - request.data[request.len] = '\0'; +static int send_cmd(int fd, char *command, char **output) +{ + struct mconsole_request request; - if(free_command) free(command); + format_cmd(command, &request); + if(sendto(fd, &request, sizeof(request), 0, (struct sockaddr *) &sun, + sizeof(sun)) < 0){ + fprintf(stderr, "Sending command to '%s' : ", sun.sun_path); + perror(""); + return 1; + } - if(sendto(fd, &request, sizeof(request), 0, (struct sockaddr *) &sun, - sizeof(sun)) < 0){ - fprintf(stderr, "Sending command to '%s' : ", sun.sun_path); - perror(""); - return(1); - } + return rcv_output(fd, output); +} - first = 1; - do { - n = recvfrom(fd, &reply, sizeof(reply), 0, NULL, 0); - if(n < 0){ - perror("recvmsg"); - return(1); - } +static int default_cmd(int fd, char *command) +{ + char name[128], *output = NULL; + int free_command, err; - if(first){ - if(reply.err) printf("ERR "); - else printf("OK "); + if((sscanf(command, "%128[^: \f\n\r\t\v]:", name) == 1) && + (*(name + 1) == ':')){ + if(switch_common(name)) + return(1); + command = strchr(command, ':'); + *command++ = '\0'; + while(isspace(*command)) command++; + } - first = 0; - } + free_command = fix_filenames(&command); - printf("%s", reply.data); - } while(reply.more); + err = send_cmd(fd, command, &output); + if(output != NULL){ + printf("%s %s\n", err ? "ERR" : "OK", output); + free(output); + } - printf("\n"); - return(reply.err); + if(free_command) free(command); + + return err; } char *local_help = @@ -264,7 +325,8 @@ char *local_help = quit - Quit mconsole\n\ switch - Switch control to the given machine\n\ log -f - use contents of as UML log messages\n\ - mconsole-version - version of this mconsole program\n"; + mconsole-version - version of this mconsole program\n\ + int - Interrupt UML session\n"; static int help_cmd(int fd, char *command) { @@ -333,6 +395,40 @@ static int log_cmd(int fd, char *command) return(0); } +extern int send_fd(int fd, int target, struct sockaddr *to, int to_len, + void *msg, int msg_len); + +static int umlfs_cmd(int fd, char *command) +{ + struct mconsole_request request; + char *end, *output, *fd_ptr; + int fuse_fd, err; + + fd_ptr = command; + fd_ptr += strlen("umlfs"); + while(isspace(*fd_ptr)) fd_ptr++; + + fuse_fd = strtoul(fd_ptr, &end, 0); + if(*end != '\0'){ + output = "Failed to parse file descriptor"; + err = -EINVAL; + goto out; + } + + format_cmd(command, &request); + err = send_fd(fuse_fd, fd, (struct sockaddr *) &sun, sizeof(sun), + &request, sizeof(request)); + if(err){ + output = "Failed to send FUSE file descriptor"; + goto out; + } + + err = rcv_output(fd, &output); +out: + printf("%s %s\n", err ? "ERR" : "OK", output); + return err; +} + static int quit_cmd(int fd, char *command) { exit(0); @@ -344,26 +440,42 @@ static int mversion_cmd(int fd, char *command) return(0); } +static int int_cmd(int fd, char *command) +{ + + if(uml_pid == -1){ + printf("Cannot determine the PID of your UML session, not " + "sending signal.\n"); + return 0; + } + + kill(uml_pid, SIGINT); + + return 0; +} + struct cmd { char *command; int (*proc)(int, char *); }; static struct cmd cmds[] = { - { "quit", quit_cmd }, - { "help", help_cmd }, - { "switch", switch_cmd }, - { "log", log_cmd }, - { "mconsole-version", mversion_cmd }, - { NULL, default_cmd } - /* default_cmd means "send it to the UML" */ + { "quit", quit_cmd }, + { "help", help_cmd }, + { "switch", switch_cmd }, + { "log", log_cmd }, + { "umlfs", umlfs_cmd }, + { "mconsole-version", mversion_cmd }, + { "int", int_cmd }, + { NULL, default_cmd } + /* default_cmd means "send it to the UML" */ }; /* sends a command */ int issue_command(int fd, char *command) { char *ptr; - int i = 0; + unsigned int i = 0; /* Trim trailing spaces left by readline's filename completion */ ptr = &command[strlen(command) - 1]; diff --git a/src/tools-20070815/mconsole/uml_mconsole.c.orig b/src/tools-20070815/mconsole/uml_mconsole.c.orig new file mode 100644 index 0000000..3142b9f --- /dev/null +++ b/src/tools-20070815/mconsole/uml_mconsole.c.orig @@ -0,0 +1,572 @@ +/* (c) Copyright 2001-2004 Jeff Dike and others + * Licensed under the GPL, see file COPYING + * + * This is uml_console version 2, a tool for querying a User Mode Linux + * instance over a local pipe connection. This tool needs to be in sync + * with the version of the UML kernel. + * + * There are a very few local commands that this program knows + * about, but by default everything gets processed by UML. + * + * The uml_mconsole documentation distributed with covers all mconsole + * commands, so the docs have to be kept in sync with the kernel. + * In future it should be possible for the docs to come from (or be + * in common with) something over in the kernel source. + * + * If you are looking for the command implementation, go to the + * files mconsole_kern.c in the Linux kernel source under arch/um. + * + * The program exits with error values of: + * + * 0 No error + * 1 Error (need better breakdown of error type in future) + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static char uml_name[11]; +static struct sockaddr_un sun; +static long uml_pid; + +static int do_switch(char *dir, char *file, char *name) +{ + struct stat buf; + char pid_path[MAXPATHLEN + 1]; + FILE *fp; + char pid[sizeof("12345\0")], *end; + int n, x = -1; + + if(stat(file, &buf) == -1){ + fprintf(stderr, "Warning: couldn't stat file: %s - ", file); + perror(""); + return 1; + } + sun.sun_family = AF_UNIX; + strncpy(sun.sun_path, file, sizeof(sun.sun_path)); + strncpy(uml_name, name, sizeof(uml_name)); + + /* Open and read PID file */ + uml_pid = -1; + + snprintf(pid_path, sizeof(pid_path), "%s/%s/pid", dir, name); + fp = fopen(pid_path, "r"); + if(fp == NULL) + return 0; + + while (!feof(fp) && !ferror(fp)) + fread(&pid[++x], sizeof(char), 1, fp); + + /* Convert read PID to number, or set PID to known error number */ + if (feof(fp) && !ferror(fp)){ + n = strtol(pid, &end, 10); + if(end != pid) + uml_pid = n; + } + + return 0; +} + +static int switch_common(char *name) +{ + char file[MAXPATHLEN + 1], dir[MAXPATHLEN + 1], tmp[MAXPATHLEN + 1]; + char *home; + int try_file = 1; + + if((home = getenv("HOME")) != NULL){ + snprintf(dir, sizeof(dir), "%s/.uml", home); + snprintf(file, sizeof(file), "%s/%s/mconsole", dir, name); + if(strncmp(name, dir, strlen(dir))){ + if(!do_switch(dir, file, name)) return(0); + try_file = 0; + } + } + + snprintf(dir, sizeof(dir), "/tmp/uml/%s", name); + snprintf(tmp, sizeof(tmp), "/tmp/uml/%s/mconsole", name); + if(strncmp(name, "/tmp/uml/", strlen("/tmp/uml/"))){ + if(!do_switch(dir, tmp, name)) + return 0; + } + + snprintf(dir, sizeof(dir), "./"); + if(!do_switch(dir, name, name)) + return 0; + + if(!try_file) + return -1; + + return do_switch(dir, file, name); +} + +#define MCONSOLE_MAGIC (0xcafebabe) +#define MCONSOLE_MAX_DATA (512) +#define MCONSOLE_VERSION (2) + +struct mconsole_request { + uint32_t magic; + uint32_t version; + uint32_t len; + char data[MCONSOLE_MAX_DATA]; +}; + +struct mconsole_reply { + uint32_t err; + uint32_t more; + uint32_t len; + char data[MCONSOLE_MAX_DATA]; +}; + +static char *absolutize(char *to, size_t size, char *from) +{ + char save_cwd[MAXPATHLEN + 1], *slash; + size_t remaining; + + if(getcwd(save_cwd, sizeof(save_cwd)) == NULL) { + perror("absolutize : unable to get cwd"); + return(NULL); + } + slash = strrchr(from, '/'); + if(slash != NULL){ + *slash = '\0'; + if(chdir(from)){ + fprintf(stderr, "absolutize : Can't cd to '%s', ", from); + *slash = '/'; + perror(""); + return(NULL); + } + *slash = '/'; + if(getcwd(to, size) == NULL){ + fprintf(stderr, "absolutize : unable to get cwd of '%s'", from); + perror(""); + return(NULL); + } + remaining = size - strlen(to); + if(strlen(slash) + 1 > remaining){ + fprintf(stderr, "absolutize : unable to fit '%s' into %zd chars\n", from, + size); + return(NULL); + } + strcat(to, slash); + } + else { + if(strlen(save_cwd) + 1 + strlen(from) + 1 > size){ + fprintf(stderr, "absolutize : unable to fit '%s' into %zd chars\n", from, + size); + return(NULL); + } + strcpy(to, save_cwd); + strcat(to, "/"); + strcat(to, from); + } + chdir(save_cwd); + return(to); +} + +static int fix_filenames(char **cmd_ptr) +{ + char *cow_file, *backing_file, *equal, *new, *ptr = *cmd_ptr; + char full_backing[MAXPATHLEN + 1], full_cow[MAXPATHLEN + 1]; + int len; + + if(strncmp(ptr, "config", strlen("config"))) return(0); + ptr += strlen("config"); + + while(isspace(*ptr) && (*ptr != '\0')) ptr++; + if(*ptr == '\0') return(0); + + if(strncmp(ptr, "ubd", strlen("ubd"))) return(0); + + while((*ptr != '=') && (*ptr != '\0')) ptr++; + if(*ptr == '\0') return(0); + + equal = ptr; + cow_file = ptr + 1; + while((*ptr != ',') && (*ptr != '\0')) ptr++; + if(*ptr == '\0'){ + backing_file = cow_file; + cow_file = NULL; + } + else { + *ptr = '\0'; + backing_file = ptr + 1; + } + + ptr = absolutize(full_backing, sizeof(full_backing), backing_file); + backing_file = ptr ? ptr : backing_file; + + if(cow_file != NULL){ + ptr = absolutize(full_cow, sizeof(full_cow), cow_file); + cow_file = ptr ? ptr : cow_file; + } + + len = equal - *cmd_ptr; + len += strlen("=") + strlen(backing_file) + 1; + if(cow_file != NULL){ + len += strlen(",") + strlen(cow_file); + } + + new = malloc(len * sizeof(char)); + if(new == NULL) return(0); + + strncpy(new, *cmd_ptr, equal - *cmd_ptr); + ptr = new + (equal - *cmd_ptr); + *ptr++ = '='; + + if(cow_file != NULL){ + sprintf(ptr, "%s,", cow_file); + ptr += strlen(ptr); + } + strcpy(ptr, backing_file); + + *cmd_ptr = new; + return(1); +} + +static int rcv_output(int fd, char **output) +{ + struct mconsole_reply reply; + int n, err = 0, first = 1, len = 0; + + do { + n = recvfrom(fd, &reply, sizeof(reply), 0, NULL, 0); + if(n < 0){ + perror("recvmsg"); + return(1); + } + + err = reply.err ? 1 : err; + + *output = realloc(*output, len + strlen(reply.data) + 1); + if(*output == NULL){ + perror("realloc failed"); + return 1; + } + + if(first) + **output = '\0'; + strcat(*output, reply.data); + len += strlen(reply.data); + first = 0; + } while(reply.more); + + return reply.err; +} + +static void format_cmd(char *command, struct mconsole_request *request) +{ + *request = ((struct mconsole_request) + { .magic = MCONSOLE_MAGIC, + .version = MCONSOLE_VERSION, + .len = MIN(strlen(command), + sizeof(request->data) - 1) }); + strncpy(request->data, command, request->len); + request->data[request->len] = '\0'; +} + +static int send_cmd(int fd, char *command, char **output) +{ + struct mconsole_request request; + + format_cmd(command, &request); + if(sendto(fd, &request, sizeof(request), 0, (struct sockaddr *) &sun, + sizeof(sun)) < 0){ + fprintf(stderr, "Sending command to '%s' : ", sun.sun_path); + perror(""); + return 1; + } + + return rcv_output(fd, output); +} + +static int default_cmd(int fd, char *command) +{ + char name[128], *output = NULL; + int free_command, err; + + if((sscanf(command, "%128[^: \f\n\r\t\v]:", name) == 1) && + (*(name + 1) == ':')){ + if(switch_common(name)) + return(1); + command = strchr(command, ':'); + *command++ = '\0'; + while(isspace(*command)) command++; + } + + free_command = fix_filenames(&command); + + err = send_cmd(fd, command, &output); + if(output != NULL){ + printf("%s %s\n", err ? "ERR" : "OK", output); + free(output); + } + + if(free_command) free(command); + + return err; +} + +char *local_help = +"Additional local mconsole commands:\n\ + quit - Quit mconsole\n\ + switch - Switch control to the given machine\n\ + log -f - use contents of as UML log messages\n\ + mconsole-version - version of this mconsole program\n\ + int - Interrupt UML session\n"; + +static int help_cmd(int fd, char *command) +{ + default_cmd(fd, command); + printf("%s", local_help); + return(0); +} + +static int switch_cmd(int fd, char *command) +{ + char *ptr; + + ptr = &command[strlen("switch")]; + while(isspace(*ptr)) ptr++; + if(switch_common(ptr)) return(1); + printf("Switched to '%s'\n", ptr); + return(0); +} + +static int log_cmd(int fd, char *command) +{ + int len, max, chunk, input_fd, newline = 0; + char *ptr, buf[sizeof(((struct mconsole_request *) NULL)->data)]; + + ptr = &command[strlen("log")]; + while(isspace(*ptr)) ptr++; + + max = sizeof(((struct mconsole_request *) NULL)->data) - sizeof("log ") - 1; + + if(!strncmp(ptr, "-f", strlen("-f"))){ + ptr = &ptr[strlen("-f")]; + while(isspace(*ptr)) ptr++; + input_fd = open(ptr, O_RDONLY); + if(input_fd < 0){ + perror("opening file"); + exit(1); + } + strcpy(buf, "log "); + ptr = buf + strlen(buf); + while((len = read(input_fd, ptr, max)) > 0){ + ptr[len] = '\0'; + default_cmd(fd, buf); + newline = (ptr[len - 1] == '\n'); + } + if(len < 0){ + perror("reading file"); + exit(1); + } + } + else { + len = strlen(ptr); + while(len > 0){ + chunk = MIN(len, max); + sprintf(buf, "log %.*s", chunk, ptr); + default_cmd(fd, buf); + newline = (ptr[chunk - 1] == '\n'); + + len -= chunk; + ptr += chunk; + } + } + if(!newline){ + sprintf(buf, "log \n"); + default_cmd(fd, buf); + } + return(0); +} + +extern int send_fd(int fd, int target, struct sockaddr *to, int to_len, + void *msg, int msg_len); + +static int umlfs_cmd(int fd, char *command) +{ + struct mconsole_request request; + char *end, *output, *fd_ptr; + int fuse_fd, err; + + fd_ptr = command; + fd_ptr += strlen("umlfs"); + while(isspace(*fd_ptr)) fd_ptr++; + + fuse_fd = strtoul(fd_ptr, &end, 0); + if(*end != '\0'){ + output = "Failed to parse file descriptor"; + err = -EINVAL; + goto out; + } + + format_cmd(command, &request); + err = send_fd(fuse_fd, fd, (struct sockaddr *) &sun, sizeof(sun), + &request, sizeof(request)); + if(err){ + output = "Failed to send FUSE file descriptor"; + goto out; + } + + err = rcv_output(fd, &output); +out: + printf("%s %s\n", err ? "ERR" : "OK", output); + return err; +} + +static int quit_cmd(int fd, char *command) +{ + exit(0); +} + +static int mversion_cmd(int fd, char *command) +{ + printf("uml_mconsole client version %d\n", MCONSOLE_VERSION); + return(0); +} + +static int int_cmd(int fd, char *command) +{ + + if(uml_pid == -1){ + printf("Cannot determine the PID of your UML session, not " + "sending signal.\n"); + return 0; + } + + kill(uml_pid, SIGINT); + + return 0; +} + +struct cmd { + char *command; + int (*proc)(int, char *); +}; + +static struct cmd cmds[] = { + { "quit", quit_cmd }, + { "help", help_cmd }, + { "switch", switch_cmd }, + { "log", log_cmd }, + { "umlfs", umlfs_cmd }, + { "mconsole-version", mversion_cmd }, + { "int", int_cmd }, + { NULL, default_cmd } + /* default_cmd means "send it to the UML" */ +}; + +/* sends a command */ +int issue_command(int fd, char *command) +{ + char *ptr; + unsigned int i = 0; + + /* Trim trailing spaces left by readline's filename completion */ + ptr = &command[strlen(command) - 1]; + while(isspace(*ptr)) *ptr-- = '\0'; + + for(i = 0; i < sizeof(cmds)/sizeof(cmds[0]); i++){ + if((cmds[i].command == NULL) || + !strncmp(cmds[i].command, command, strlen(cmds[i].command))){ + return((*cmds[i].proc)(fd, command)); + } + } + + /* Should never get here, considering the NULL test above will match the last + * entry of cmds */ + return(0); +} + +/* sends a command in argv style array */ +int issue_commandv(int fd, char **argv) +{ + char *command; + int len = -1, i = 0, status; + + len = 1; /* space for trailing null */ + for(i = 0; argv[i] != NULL; i++) + len += strlen(argv[i]) + 1; /* space for space */ + + command = malloc(len); + if(command == NULL){ + perror("issue_command"); + return(1); + } + command[0] = '\0'; + + for(i = 0; argv[i] != NULL; i++) { + strcat(command, argv[i]); + if(argv[i+1] != NULL) strcat(command, " "); + } + + status = issue_command(fd, command); + + free(command); + + return(status); +} + +static void Usage(void) +{ + fprintf(stderr, "Usage : uml_mconsole socket-name [command]\n"); + exit(1); +} + +int main(int argc, char **argv) +{ + struct sockaddr_un here; + char *sock; + int fd; + + if(argc < 2) Usage(); + strcpy(uml_name, "[None]"); + sock = argv[1]; + switch_common(sock); + + if((fd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0){ + perror("socket"); + exit(1); + } + here.sun_family = AF_UNIX; + memset(here.sun_path, 0, sizeof(here.sun_path)); + + sprintf(&here.sun_path[1], "%5d", getpid()); + if(bind(fd, (struct sockaddr *) &here, sizeof(here)) < 0){ + perror("bind"); + exit(1); + } + + if(argc>2) + exit(issue_commandv(fd, argv+2)); + + while(1){ + char *command, prompt[1 + sizeof(uml_name) + 2 + 1]; + + sprintf(prompt, "(%s) ", uml_name); + command = readline(prompt); + if(command == NULL) break; + + if(*command) add_history(command); + + issue_command(fd, command); + free(command); + } + printf("\n"); + exit(0); +} diff --git a/src/tools-20070815/mconsole/uml_mconsole.c.rej b/src/tools-20070815/mconsole/uml_mconsole.c.rej new file mode 100644 index 0000000..bcc03ed --- /dev/null +++ b/src/tools-20070815/mconsole/uml_mconsole.c.rej @@ -0,0 +1,25 @@ +--- mconsole/uml_mconsole.c 2004-04-08 03:43:29.000000000 +0200 ++++ mconsole/uml_mconsole.c 2011-05-20 12:16:00.044639001 +0200 +@@ -62,6 +62,22 @@ + int try_file = 1; + + if((home = getenv("HOME")) != NULL){ ++ ++ /*****************************************/ ++ /* Changed for compatibility with Netkit */ ++ /*****************************************/ ++ ++ /* Management consoles are made available inside .netkit ++ in the user's home directory. Look there first and ++ everywhere else only in case of failure. */ ++ ++ snprintf(dir, sizeof(dir), "%s/.netkit/mconsole", home); ++ snprintf(file, sizeof(file), "%s/%s/mconsole", dir, name); ++ if(strncmp(name, dir, strlen(dir))){ ++ if(!do_switch(dir, file, name)) return(0); ++ try_file = 0; ++ } ++ + snprintf(dir, sizeof(dir), "%s/.uml", home); + snprintf(file, sizeof(file), "%s/%s/mconsole", dir, name); + if(strncmp(name, dir, strlen(dir))){ diff --git a/src/uml-tools/moo/.cvsignore b/src/tools-20070815/moo/.cvsignore similarity index 100% rename from src/uml-tools/moo/.cvsignore rename to src/tools-20070815/moo/.cvsignore diff --git a/src/tools-20070815/moo/CVS/Entries b/src/tools-20070815/moo/CVS/Entries new file mode 100644 index 0000000..b3b21da --- /dev/null +++ b/src/tools-20070815/moo/CVS/Entries @@ -0,0 +1,8 @@ +/.cvsignore/1.1/Fri Jan 11 05:21:31 2002// +/Makefile/1.7/Thu Jun 26 16:27:00 2003// +/cow.c/1.2/Wed Sep 3 16:35:07 2003// +/cow.h/1.2/Wed Sep 3 16:35:52 2003// +/cow_sys.h/1.2/Thu Aug 28 01:44:05 2003// +/uml_mkcow.c/1.2/Mon Sep 8 21:20:29 2003// +/uml_moo.c/1.10/Mon Sep 8 21:39:46 2003// +D diff --git a/src/tools-20070815/moo/CVS/Repository b/src/tools-20070815/moo/CVS/Repository new file mode 100644 index 0000000..760a193 --- /dev/null +++ b/src/tools-20070815/moo/CVS/Repository @@ -0,0 +1 @@ +tools/moo diff --git a/src/tools-20070815/moo/CVS/Root b/src/tools-20070815/moo/CVS/Root new file mode 100644 index 0000000..4f921bb --- /dev/null +++ b/src/tools-20070815/moo/CVS/Root @@ -0,0 +1 @@ +jdike@cvs.user-mode-linux.sourceforge.net:/cvsroot/user-mode-linux diff --git a/src/uml-tools/moo/Makefile b/src/tools-20070815/moo/Makefile similarity index 82% rename from src/uml-tools/moo/Makefile rename to src/tools-20070815/moo/Makefile index 1923d37..ee4c44f 100644 --- a/src/uml-tools/moo/Makefile +++ b/src/tools-20070815/moo/Makefile @@ -3,7 +3,8 @@ BIN = uml_moo uml_mkcow uml_moo_OBJS = uml_moo.o cow.o uml_mkcow_OBJS = uml_mkcow.o cow.o -CFLAGS = -g -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE +CFLAGS ?= -g -Wall +override CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_GNU_SOURCE BIN_DIR ?= /usr/bin diff --git a/src/uml-tools/moo/cow.c b/src/tools-20070815/moo/cow.c similarity index 65% rename from src/uml-tools/moo/cow.c rename to src/tools-20070815/moo/cow.c index 3951642..61f0701 100644 --- a/src/uml-tools/moo/cow.c +++ b/src/tools-20070815/moo/cow.c @@ -14,32 +14,36 @@ #define PATH_LEN_V1 256 +typedef __u32 time32_t; + struct cow_header_v1 { - int magic; - int version; + __s32 magic; + __s32 version; char backing_file[PATH_LEN_V1]; - time_t mtime; + time32_t mtime; __u64 size; - int sectorsize; -}; - -#define PATH_LEN_V2 MAXPATHLEN + __s32 sectorsize; +} __attribute__((packed)); + +/* Define PATH_LEN_V3 as the usual value of MAXPATHLEN, just hard-code it in + * case other systems have different values for MAXPATHLEN. + * + * The same must hold for V2 - we want file format compatibility, not anything + * else. + */ +#define PATH_LEN_V3 4096 +#define PATH_LEN_V2 PATH_LEN_V3 struct cow_header_v2 { - unsigned long magic; - unsigned long version; + __u32 magic; + __u32 version; char backing_file[PATH_LEN_V2]; - time_t mtime; + time32_t mtime; __u64 size; - int sectorsize; -}; + __s32 sectorsize; +} __attribute__((packed)); -/* Define PATH_LEN_V3 as the usual value of MAXPATHLEN, just hard-code it in - * case other systems have different values for MAXPATHLEN - */ -#define PATH_LEN_V3 4096 - -/* Changes from V2 - +/* Changes from V2 - * PATH_LEN_V3 as described above * Explicitly specify field bit lengths for systems with different * lengths for the usual C types. Not sure whether char or @@ -63,10 +67,31 @@ struct cow_header_v2 { * Fixed (finally!) the rounding bug */ +/* Until Dec2005, __attribute__((packed)) was left out from the below + * definition, leading on 64-bit systems to 4 bytes of padding after mtime, to + * align size to 8-byte alignment. This shifted all fields above (no padding + * was present on 32-bit, no other padding was added). + * + * However, this _can be detected_: it means that cow_format (always 0 until + * now) is shifted onto the first 4 bytes of backing_file, where it is otherwise + * impossible to find 4 zeros. -bb */ + struct cow_header_v3 { __u32 magic; __u32 version; - time_t mtime; + time32_t mtime; + __u64 size; + __u32 sectorsize; + __u32 alignment; + __u32 cow_format; + char backing_file[PATH_LEN_V3]; +} __attribute__((packed)); + +/* This is the broken layout used by some 64-bit binaries. */ +struct cow_header_v3_broken { + __u32 magic; + __u32 version; + __s64 mtime; __u64 size; __u32 sectorsize; __u32 alignment; @@ -81,6 +106,7 @@ union cow_header { struct cow_header_v1 v1; struct cow_header_v2 v2; struct cow_header_v3 v3; + struct cow_header_v3_broken v3_b; }; #define COW_MAGIC 0x4f4f4f4d /* MOOO */ @@ -89,15 +115,15 @@ union cow_header { #define DIV_ROUND(x, len) (((x) + (len) - 1) / (len)) #define ROUND_UP(x, align) DIV_ROUND(x, align) * (align) -void cow_sizes(int version, __u64 size, int sectorsize, int align, - int bitmap_offset, unsigned long *bitmap_len_out, +void cow_sizes(int version, __u64 size, int sectorsize, int align, + int bitmap_offset, unsigned long *bitmap_len_out, int *data_offset_out) { if(version < 3){ *bitmap_len_out = (size + sectorsize - 1) / (8 * sectorsize); *data_offset_out = bitmap_offset + *bitmap_len_out; - *data_offset_out = (*data_offset_out + sectorsize - 1) / + *data_offset_out = (*data_offset_out + sectorsize - 1) / sectorsize; *data_offset_out *= sectorsize; } @@ -110,13 +136,13 @@ void cow_sizes(int version, __u64 size, int sectorsize, int align, } } -static int absolutize(char *to, int size, char *from) +static int absolutize(char *to, size_t size, char *from) { char save_cwd[256], *slash; - int remaining; + size_t remaining; if(getcwd(save_cwd, sizeof(save_cwd)) == NULL) { - cow_printf("absolutize : unable to get cwd - errno = %d\n", + cow_printf("absolutize : unable to get cwd - errno = %d\n", errno); return(-1); } @@ -125,7 +151,7 @@ static int absolutize(char *to, int size, char *from) *slash = '\0'; if(chdir(from)){ *slash = '/'; - cow_printf("absolutize : Can't cd to '%s' - " + cow_printf("absolutize : Can't cd to '%s' - " "errno = %d\n", from, errno); return(-1); } @@ -137,7 +163,7 @@ static int absolutize(char *to, int size, char *from) } remaining = size - strlen(to); if(strlen(slash) + 1 > remaining){ - cow_printf("absolutize : unable to fit '%s' into %d " + cow_printf("absolutize : unable to fit '%s' into %zd " "chars\n", from, size); return(-1); } @@ -145,7 +171,7 @@ static int absolutize(char *to, int size, char *from) } else { if(strlen(save_cwd) + 1 + strlen(from) + 1 > size){ - cow_printf("absolutize : unable to fit '%s' into %d " + cow_printf("absolutize : unable to fit '%s' into %zd " "chars\n", from, size); return(-1); } @@ -157,24 +183,23 @@ static int absolutize(char *to, int size, char *from) return(0); } -int write_cow_header(char *cow_file, int fd, char *backing_file, - int sectorsize, int alignment, long long *size) +int write_cow_header(char *cow_file, int fd, char *backing_file, + int sectorsize, int alignment, unsigned long long *size) { - struct cow_header_v3 *header; + struct cow_header_v3 *header; struct stat64 buf; int err; err = cow_seek_file(fd, 0); - if(err != 0){ - cow_printf("write_cow_header - lseek failed, errno = %d\n", - errno); - return(-errno); + if(err < 0){ + cow_printf("write_cow_header - lseek failed, err = %d\n", -err); + goto out; } err = -ENOMEM; header = cow_malloc(sizeof(*header)); if(header == NULL){ - cow_printf("Failed to allocate COW V3 header\n"); + cow_printf("write_cow_header - failed to allocate COW V3 header\n"); goto out; } header->magic = htonl(COW_MAGIC); @@ -182,28 +207,30 @@ int write_cow_header(char *cow_file, int fd, char *backing_file, err = -EINVAL; if(strlen(backing_file) > sizeof(header->backing_file) - 1){ + /* Below, %zd is for a size_t value */ cow_printf("Backing file name \"%s\" is too long - names are " - "limited to %d characters\n", backing_file, + "limited to %zd characters\n", backing_file, sizeof(header->backing_file) - 1); goto out_free; } - if(absolutize(header->backing_file, sizeof(header->backing_file), + if(absolutize(header->backing_file, sizeof(header->backing_file), backing_file)) goto out_free; err = stat64(header->backing_file, &buf); if(err < 0){ - cow_printf("Stat of backing file '%s' failed, errno = %d\n", - header->backing_file, errno); - err = -errno; + cow_printf("write_cow_header - backing file '%s' mtime " + "request failed, err = %d\n", header->backing_file, + -err); goto out_free; } err = cow_file_size(header->backing_file, size); - if(err){ - cow_printf("Couldn't get size of backing file '%s', " - "errno = %d\n", header->backing_file, -*size); + if(err < 0){ + cow_printf("write_cow_header - couldn't get size of " + "backing file '%s', err = %d\n", + header->backing_file, -err); goto out_free; } @@ -213,10 +240,11 @@ int write_cow_header(char *cow_file, int fd, char *backing_file, header->alignment = htonl(alignment); header->cow_format = COW_BITMAP; - err = write(fd, header, sizeof(*header)); + err = cow_write_file(fd, header, sizeof(*header)); if(err != sizeof(*header)){ - cow_printf("Write of header to new COW file '%s' failed, " - "errno = %d\n", cow_file, errno); + cow_printf("write_cow_header - write of header to " + "new COW file '%s' failed, err = %d\n", cow_file, + -err); goto out_free; } err = 0; @@ -235,10 +263,10 @@ int file_reader(__u64 offset, char *buf, int len, void *arg) /* XXX Need to sanity-check the values read from the header */ -int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, - __u32 *version_out, char **backing_file_out, - time_t *mtime_out, __u64 *size_out, - int *sectorsize_out, __u32 *align_out, +int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, + __u32 *version_out, char **backing_file_out, + time_t *mtime_out, __u64 *size_out, + int *sectorsize_out, __u32 *align_out, int *bitmap_offset_out) { union cow_header *header; @@ -296,9 +324,10 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, *align_out = *sectorsize_out; file = header->v2.backing_file; } - else if(version == 3){ + /* This is very subtle - see above at union cow_header definition */ + else if(version == 3 && (*((int*)header->v3.backing_file) != 0)){ if(n < sizeof(header->v3)){ - cow_printf("read_cow_header - failed to read V2 " + cow_printf("read_cow_header - failed to read V3 " "header\n"); goto out; } @@ -306,12 +335,46 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, *size_out = ntohll(header->v3.size); *sectorsize_out = ntohl(header->v3.sectorsize); *align_out = ntohl(header->v3.alignment); + if (*align_out == 0) { + cow_printf("read_cow_header - invalid COW header, " + "align == 0\n"); + } *bitmap_offset_out = ROUND_UP(sizeof(header->v3), *align_out); file = header->v3.backing_file; } + else if(version == 3){ + cow_printf("read_cow_header - broken V3 file with" + " 64-bit layout - recovering content.\n"); + + if(n < sizeof(header->v3_b)){ + cow_printf("read_cow_header - failed to read V3 " + "header\n"); + goto out; + } + + /* this was used until Dec2005 - 64bits are needed to represent + * 2038+. I.e. we can safely do this truncating cast. + * + * Additionally, we must use ntohl() instead of ntohll(), since + * the program used to use the former (tested - I got mtime + * mismatch "0 vs whatever"). + * + * Ever heard about bug-to-bug-compatibility ? ;-) */ + *mtime_out = (time32_t) ntohl(header->v3_b.mtime); + + *size_out = ntohll(header->v3_b.size); + *sectorsize_out = ntohl(header->v3_b.sectorsize); + *align_out = ntohl(header->v3_b.alignment); + if (*align_out == 0) { + cow_printf("read_cow_header - invalid COW header, " + "align == 0\n"); + } + *bitmap_offset_out = ROUND_UP(sizeof(header->v3_b), *align_out); + file = header->v3_b.backing_file; + } else { cow_printf("read_cow_header - invalid COW version\n"); - goto out; + goto out; } err = -ENOMEM; *backing_file_out = cow_strdup(file); @@ -327,38 +390,39 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, } int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize, - int alignment, int *bitmap_offset_out, + int alignment, int *bitmap_offset_out, unsigned long *bitmap_len_out, int *data_offset_out) { - __u64 size, offset; + unsigned long long size, offset; char zero = 0; int err; - err = write_cow_header(cow_file, fd, backing_file, sectorsize, + err = write_cow_header(cow_file, fd, backing_file, sectorsize, alignment, &size); - if(err) + if(err) goto out; - + *bitmap_offset_out = ROUND_UP(sizeof(struct cow_header_v3), alignment); cow_sizes(COW_VERSION, size, sectorsize, alignment, *bitmap_offset_out, bitmap_len_out, data_offset_out); offset = *data_offset_out + size - sizeof(zero); err = cow_seek_file(fd, offset); - if(err){ - cow_printf("cow bitmap lseek failed : errno = %d\n", errno); + if(err < 0){ + cow_printf("cow bitmap lseek failed : err = %d\n", -err); goto out; } - /* does not really matter how much we write it is just to set EOF + /* does not really matter how much we write it is just to set EOF * this also sets the entire COW bitmap - * to zero without having to allocate it + * to zero without having to allocate it */ err = cow_write_file(fd, &zero, sizeof(zero)); if(err != sizeof(zero)){ - err = -EINVAL; cow_printf("Write of bitmap to new COW file '%s' failed, " - "errno = %d\n", cow_file, errno); + "err = %d\n", cow_file, -err); + if (err >= 0) + err = -EINVAL; goto out; } diff --git a/src/uml-tools/moo/cow.h b/src/tools-20070815/moo/cow.h similarity index 72% rename from src/uml-tools/moo/cow.h rename to src/tools-20070815/moo/cow.h index d875d04..b1be05f 100644 --- a/src/uml-tools/moo/cow.h +++ b/src/tools-20070815/moo/cow.h @@ -13,22 +13,23 @@ #error "__BYTE_ORDER not defined" #endif -extern int init_cow_file(int fd, char *cow_file, char *backing_file, - int sectorsize, int alignment, int *bitmap_offset_out, +extern int init_cow_file(int fd, char *cow_file, char *backing_file, + int sectorsize, int alignment, int *bitmap_offset_out, unsigned long *bitmap_len_out, int *data_offset_out); extern int file_reader(__u64 offset, char *buf, int len, void *arg); -extern int read_cow_header(int (*reader)(__u64, char *, int, void *), - void *arg, __u32 *version_out, - char **backing_file_out, time_t *mtime_out, - __u64 *size_out, int *sectorsize_out, +extern int read_cow_header(int (*reader)(__u64, char *, int, void *), + void *arg, __u32 *version_out, + char **backing_file_out, time_t *mtime_out, + __u64 *size_out, int *sectorsize_out, __u32 *align_out, int *bitmap_offset_out); -extern int write_cow_header(char *cow_file, int fd, char *backing_file, - int sectorsize, int alignment, long long *size); +extern int write_cow_header(char *cow_file, int fd, char *backing_file, + int sectorsize, int alignment, + unsigned long long *size); extern void cow_sizes(int version, __u64 size, int sectorsize, int align, - int bitmap_offset, unsigned long *bitmap_len_out, + int bitmap_offset, unsigned long *bitmap_len_out, int *data_offset_out); #endif diff --git a/src/uml-tools/moo/cow_sys.h b/src/tools-20070815/moo/cow_sys.h similarity index 76% rename from src/uml-tools/moo/cow_sys.h rename to src/tools-20070815/moo/cow_sys.h index 8a47a94..fb63f8e 100644 --- a/src/uml-tools/moo/cow_sys.h +++ b/src/tools-20070815/moo/cow_sys.h @@ -20,16 +20,7 @@ static inline void cow_free(void *ptr) free(ptr); } -static inline int cow_printf(char *fmt, ...) -{ - va_list args; - int n; - - va_start(args, fmt); - n = vprintf(fmt, args); - va_end(args); - return(n); -} +#define cow_printf printf static inline char *cow_strdup(char *str) { @@ -40,17 +31,17 @@ static inline int cow_seek_file(int fd, __u64 offset) { __u64 actual; - actual = lseek(fd, offset, SEEK_SET); + actual = lseek64(fd, offset, SEEK_SET); if(actual != offset) return(-errno); return(0); } -static inline int cow_file_size(char *file, long long *size_out) +static inline int cow_file_size(char *file, __u64 *size_out) { - struct stat buf; + struct stat64 buf; - if(stat(file, &buf) == -1){ + if (stat64(file, &buf) == -1) { cow_printf("Couldn't stat \"%s\" : errno = %d\n", file, errno); return(-errno); } @@ -76,9 +67,13 @@ static inline int cow_file_size(char *file, long long *size_out) return(0); } -static inline int cow_write_file(int fd, char *buf, int size) +static inline int cow_write_file(int fd, void *buf, int size) { - return(write(fd, buf, size)); + int ret = write(fd, buf, size); + + if (ret == -1) + return(-errno); + return(ret); } #endif diff --git a/src/uml-tools/moo/uml_mkcow.c b/src/tools-20070815/moo/uml_mkcow.c similarity index 84% rename from src/uml-tools/moo/uml_mkcow.c rename to src/tools-20070815/moo/uml_mkcow.c index 8bdbfd5..31510b7 100644 --- a/src/uml-tools/moo/uml_mkcow.c +++ b/src/tools-20070815/moo/uml_mkcow.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -19,6 +20,7 @@ void usage(const char progname[]) int main(int argc, char *argv[]) { int fd; + int err; char *cow_file; char *backing_file; int bitmap_offset_out; @@ -57,8 +59,9 @@ int main(int argc, char *argv[]) exit(1); } - if(init_cow_file(fd, cow_file, backing_file, 512, sysconf(_SC_PAGESIZE), - &bitmap_offset_out, &bitmap_len_out, &data_offset_out)){ + if((err = init_cow_file(fd, cow_file, backing_file, 512, sysconf(_SC_PAGESIZE), + &bitmap_offset_out, &bitmap_len_out, &data_offset_out))){ + errno = -err; perror("write_cow_header"); exit(1); } @@ -66,5 +69,5 @@ int main(int argc, char *argv[]) return (0); } -/* vim: ts=4 tw=74 +/* vim: ts=4 tw=74 sw=2 */ diff --git a/src/uml-tools/moo/uml_moo.c b/src/tools-20070815/moo/uml_moo.c similarity index 88% rename from src/uml-tools/moo/uml_moo.c rename to src/tools-20070815/moo/uml_moo.c index d7ae4e6..7e60ff2 100644 --- a/src/uml-tools/moo/uml_moo.c +++ b/src/tools-20070815/moo/uml_moo.c @@ -1,7 +1,7 @@ /* Copyrighted (C) 2001 RidgeRun,Inc (glonnon@ridgerun.com) * With modifications by Jeff Dike, James McMechan, and Steve Schmidtke. * Licensed under the GPL - */ + */ #define _XOPEN_SOURCE 500 @@ -18,24 +18,30 @@ #include #include "cow.h" -static inline int ubd_test_bit(int bit, unsigned long *data) +static inline int ubd_test_bit(__u64 bit, unsigned long *data) { - int bits, n, off; + int bits, off; + __u64 n; bits = sizeof(data[0]) * 8; n = bit / bits; off = bit % bits; - return((data[n] & (1 << off)) != 0); + //1UL to prevent sign-extension, which turns 0x8000000 into + //0xffffffff8000000 + return((data[n] & (1UL << off)) != 0); } -static inline void ubd_set_bit(int bit, unsigned long *data) +static inline void ubd_set_bit(__u64 bit, unsigned long *data) { - int bits, n, off; + int bits, off; + __u64 n; bits = sizeof(data[0]) * 8; n = bit / bits; off = bit % bits; - data[n] |= (1 << off); + //1UL to prevent sign-extension, which turns 0x8000000 into + //0xffffffff8000000 + data[n] |= (1UL << off); } int create_backing_file(char *in, char *out, char *actual_backing) @@ -44,21 +50,21 @@ int create_backing_file(char *in, char *out, char *actual_backing) struct stat buf; unsigned long *bitmap; unsigned long bitmap_len; - int sectors; + unsigned sectorsize, sectors; void *sector, *zeros; __u64 size, offset, i; /* i is u64 to prevent 32 bit overflow */ __u32 version, alignment; int data_offset; char *backing_file; time_t mtime; - int sectorsize, bitmap_offset, perms, n; + int bitmap_offset, perms, n; if((cow_fd = open(in, O_RDONLY)) < 0){ perror("COW file open"); exit(1); } - if(read_cow_header(file_reader, &cow_fd, &version, &backing_file, + if(read_cow_header(file_reader, &cow_fd, &version, &backing_file, &mtime, &size, §orsize, &alignment, &bitmap_offset)){ fprintf(stderr, "Reading COW header failed\n"); @@ -75,7 +81,7 @@ int create_backing_file(char *in, char *out, char *actual_backing) if(buf.st_size != size){ fprintf(stderr,"Size mismatch (%ld vs %ld) of COW header " - "vs backing file \"%s\"\n", (long int) size, + "vs backing file \"%s\"\n", (long int) size, (long int) buf.st_size, backing_file); exit(1); } @@ -101,7 +107,7 @@ int create_backing_file(char *in, char *out, char *actual_backing) } else out_fd = back_fd; - cow_sizes(version, size, sectorsize, alignment, bitmap_offset, + cow_sizes(version, size, sectorsize, alignment, bitmap_offset, &bitmap_len, &data_offset); bitmap = (unsigned long *) malloc(bitmap_len); @@ -151,7 +157,7 @@ int create_backing_file(char *in, char *out, char *actual_backing) */ if((i < sectors - 1) && !memcmp(sector, zeros, sectorsize)){ - /* If we're doing a non-destructive merge, then zero + /* If we're doing a non-destructive merge, then zero * sectors can just be skipped. */ if(out_fd != back_fd) @@ -194,7 +200,7 @@ int create_backing_file(char *in, char *out, char *actual_backing) return(0); } -static char *usage_string = +static char *usage_string = "%s usage:\n" "\t%s [ -b ] \n" "\t%s [ -b ] -d \n" @@ -203,14 +209,14 @@ static char *usage_string = "its current backing file\n" "Specifying -b overrides the backing_file specified in the COW file. This is\n" "needed when dealing with a COW file that was created inside a chroot jail.\n" -"%s supports version 1 and 2 COW files.\n" +"%s supports version 1,2 and 3 COW files.\n" ""; static int Usage(char *prog) { fprintf(stderr, usage_string, prog, prog, prog, prog); exit(1); } - + int main(int argc, char **argv) { char *prog = argv[0]; diff --git a/src/tools-20070815/patches/series b/src/tools-20070815/patches/series new file mode 100644 index 0000000..12891c0 --- /dev/null +++ b/src/tools-20070815/patches/series @@ -0,0 +1 @@ +tunctl-setgroup diff --git a/src/tools-20070815/patches/tunctl-setgroup b/src/tools-20070815/patches/tunctl-setgroup new file mode 100644 index 0000000..996b7fb --- /dev/null +++ b/src/tools-20070815/patches/tunctl-setgroup @@ -0,0 +1,103 @@ +Index: tools/tunctl/tunctl.c +=================================================================== +--- tools.orig/tunctl/tunctl.c 2002-09-10 18:18:06.000000000 -0400 ++++ tools/tunctl/tunctl.c 2007-08-15 11:04:19.000000000 -0400 +@@ -9,13 +9,19 @@ + #include + #include + #include ++#include + #include + #include + #include + ++/* TUNSETGROUP appeared in 2.6.23 */ ++#ifndef TUNSETGROUP ++#define TUNSETGROUP _IOW('T', 206, int) ++#endif ++ + static void Usage(char *name) + { +- fprintf(stderr, "Create: %s [-b] [-u owner] [-t device-name] " ++ fprintf(stderr, "Create: %s [-b] [-u owner] [-g group] [-t device-name] " + "[-f tun-clone-device]\n", name); + fprintf(stderr, "Delete: %s -d device-name [-f tun-clone-device]\n\n", + name); +@@ -29,11 +35,13 @@ int main(int argc, char **argv) + { + struct ifreq ifr; + struct passwd *pw; +- long owner = geteuid(); ++ struct group *gr; ++ uid_t owner = -1; ++ gid_t group = -1; + int tap_fd, opt, delete = 0, brief = 0; + char *tun = "", *file = "/dev/net/tun", *name = argv[0], *end; + +- while((opt = getopt(argc, argv, "bd:f:t:u:")) > 0){ ++ while((opt = getopt(argc, argv, "bd:f:t:u:g:")) > 0){ + switch(opt) { + case 'b': + brief = 1; +@@ -58,6 +66,20 @@ int main(int argc, char **argv) + Usage(name); + } + break; ++ case 'g': ++ gr = getgrnam(optarg); ++ if(gr != NULL){ ++ group = gr->gr_gid; ++ break; ++ } ++ group = strtol(optarg, &end, 0); ++ if(*end != '\0'){ ++ fprintf(stderr, "'%s' is neither a groupname nor a numeric group.\n", ++ optarg); ++ Usage(name); ++ } ++ break; ++ + case 't': + tun = optarg; + break; +@@ -100,14 +122,34 @@ int main(int argc, char **argv) + perror("TUNSETPERSIST"); + exit(1); + } +- if(ioctl(tap_fd, TUNSETOWNER, owner) < 0){ +- perror("TUNSETPERSIST"); +- exit(1); +- } ++ ++ /* emulate behaviour prior to TUNSETGROUP */ ++ if(owner == -1 && group == -1) { ++ owner = geteuid(); ++ } ++ ++ if(owner != -1) { ++ if(ioctl(tap_fd, TUNSETOWNER, owner) < 0){ ++ perror("TUNSETPERSIST"); ++ exit(1); ++ } ++ } ++ if(group != -1) { ++ if(ioctl(tap_fd, TUNSETGROUP, group) < 0){ ++ perror("TUNSETPERSIST"); ++ exit(1); ++ } ++ } + if(brief) + printf("%s\n", ifr.ifr_name); +- else printf("Set '%s' persistent and owned by uid %ld\n", ifr.ifr_name, +- owner); ++ else { ++ printf("Set '%s' persistent and owned by", ifr.ifr_name); ++ if(owner != -1) ++ printf(" uid %d", owner); ++ if(group != -1) ++ printf(" gid %d", group); ++ printf("\n"); ++ } + } + return(0); + } diff --git a/src/tools-20070815/port-helper/CVS/CVS/Entries b/src/tools-20070815/port-helper/CVS/CVS/Entries new file mode 100644 index 0000000..1784810 --- /dev/null +++ b/src/tools-20070815/port-helper/CVS/CVS/Entries @@ -0,0 +1 @@ +D diff --git a/src/tools-20070815/port-helper/CVS/CVS/Repository b/src/tools-20070815/port-helper/CVS/CVS/Repository new file mode 100644 index 0000000..456e4a6 --- /dev/null +++ b/src/tools-20070815/port-helper/CVS/CVS/Repository @@ -0,0 +1 @@ +tools/port-helper/CVS diff --git a/src/tools-20070815/port-helper/CVS/CVS/Root b/src/tools-20070815/port-helper/CVS/CVS/Root new file mode 100644 index 0000000..4f921bb --- /dev/null +++ b/src/tools-20070815/port-helper/CVS/CVS/Root @@ -0,0 +1 @@ +jdike@cvs.user-mode-linux.sourceforge.net:/cvsroot/user-mode-linux diff --git a/src/tools-20070815/port-helper/CVS/Entries b/src/tools-20070815/port-helper/CVS/Entries new file mode 100644 index 0000000..fc13abe --- /dev/null +++ b/src/tools-20070815/port-helper/CVS/Entries @@ -0,0 +1,3 @@ +D/CVS//// +/port-helper.c/1.6/Thu Jul 25 01:27:37 2002// +/Makefile/1.3/Sat Feb 8 04:05:31 2003// diff --git a/src/tools-20070815/port-helper/CVS/Repository b/src/tools-20070815/port-helper/CVS/Repository new file mode 100644 index 0000000..efbbaa8 --- /dev/null +++ b/src/tools-20070815/port-helper/CVS/Repository @@ -0,0 +1 @@ +tools/port-helper diff --git a/src/tools-20070815/port-helper/CVS/Root b/src/tools-20070815/port-helper/CVS/Root new file mode 100644 index 0000000..4f921bb --- /dev/null +++ b/src/tools-20070815/port-helper/CVS/Root @@ -0,0 +1 @@ +jdike@cvs.user-mode-linux.sourceforge.net:/cvsroot/user-mode-linux diff --git a/src/uml-tools/port-helper/Makefile b/src/tools-20070815/port-helper/Makefile similarity index 72% rename from src/uml-tools/port-helper/Makefile rename to src/tools-20070815/port-helper/Makefile index efb3260..7ce200b 100644 --- a/src/uml-tools/port-helper/Makefile +++ b/src/tools-20070815/port-helper/Makefile @@ -1,13 +1,14 @@ OBJS = port-helper.o BIN = port-helper -CFLAGS = -g -Wall +CFLAGS ?= -g -Wall +LIBS = ../lib/libuml.a LIB_DIR ?= /usr/lib/uml all : $(BIN) $(BIN) : $(OBJS) - $(CC) $(CFLAGS) -o $(BIN) $(OBJS) + $(CC) $(CFLAGS) -o $(BIN) $(OBJS) $(LIBS) clean : rm -f $(BIN) $(OBJS) *~ diff --git a/src/uml-tools/port-helper/port-helper.c b/src/tools-20070815/port-helper/port-helper.c similarity index 58% rename from src/uml-tools/port-helper/port-helper.c rename to src/tools-20070815/port-helper/port-helper.c index 435d3f3..16c3091 100644 --- a/src/uml-tools/port-helper/port-helper.c +++ b/src/tools-20070815/port-helper/port-helper.c @@ -20,48 +20,8 @@ for read and write, and the console is functional. #include #include -/* pass the fd over an fd that is already connected to a socket */ -static void send_fd(int fd, int target) -{ - - /* File descriptors are specific to a process and normally only - sharable with another process by inheritence with fork(). The - alternative is to use sendmsg with a special flag that says - "I'm knowingly giving another process information from my private - file descriptor table" (SCM_RIGHTS) - */ - - char anc[CMSG_SPACE(sizeof(fd))]; - struct msghdr msg; - struct cmsghdr *cmsg; - struct iovec iov; - int *fd_ptr, pid = getpid(); - - msg.msg_name = NULL; - msg.msg_namelen = 0; - iov = ((struct iovec) { iov_base : &pid, - iov_len : sizeof(pid) }); - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - msg.msg_flags = 0; - msg.msg_control = anc; - msg.msg_controllen = sizeof(anc); - - cmsg = CMSG_FIRSTHDR(&msg); - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - cmsg->cmsg_len = CMSG_LEN(sizeof(fd)); - - fd_ptr = (int *) CMSG_DATA(cmsg); - *fd_ptr = fd; - - msg.msg_controllen = cmsg->cmsg_len; - - if(sendmsg(target, &msg, 0) < 0){ - perror("sendmsg"); - exit(1); - } -} +extern void send_fd(int fd, int target, struct sockaddr *to, int to_len, + void *msg, int msg_len); /* for xterm we don't have an open socket, we only have the name of a file used as a Unix socket by UML. So we need to open it. */ @@ -95,7 +55,7 @@ static int open_socket(char *name) int main(int argc, char **argv) { - int fd; + int fd, pid; if((argc > 1) && !strcmp(argv[1], "-uml-socket")) { /* inherited a filename not an open fd */ @@ -108,7 +68,8 @@ int main(int argc, char **argv) signal(SIGHUP, SIG_IGN); if(ioctl(0, TIOCNOTTY, 0) < 0) perror("TIOCNOTTY failed in port-helper, check UML's exec call for xterm or telnetd"); - send_fd(0, fd); + pid = getpid(); + send_fd(0, fd, NULL, 0, &pid, sizeof(pid)); pause(); return(0); } diff --git a/src/tools-20070815/tunctl/CVS/Entries b/src/tools-20070815/tunctl/CVS/Entries new file mode 100644 index 0000000..21d98c5 --- /dev/null +++ b/src/tools-20070815/tunctl/CVS/Entries @@ -0,0 +1,3 @@ +/tunctl.c/1.4/Tue Sep 10 22:18:06 2002// +/Makefile/1.2/Sat Feb 8 04:05:04 2003// +D diff --git a/src/tools-20070815/tunctl/CVS/Repository b/src/tools-20070815/tunctl/CVS/Repository new file mode 100644 index 0000000..e9ca6de --- /dev/null +++ b/src/tools-20070815/tunctl/CVS/Repository @@ -0,0 +1 @@ +tools/tunctl diff --git a/src/tools-20070815/tunctl/CVS/Root b/src/tools-20070815/tunctl/CVS/Root new file mode 100644 index 0000000..4f921bb --- /dev/null +++ b/src/tools-20070815/tunctl/CVS/Root @@ -0,0 +1 @@ +jdike@cvs.user-mode-linux.sourceforge.net:/cvsroot/user-mode-linux diff --git a/src/uml-tools/tunctl/Makefile b/src/tools-20070815/tunctl/Makefile similarity index 92% rename from src/uml-tools/tunctl/Makefile rename to src/tools-20070815/tunctl/Makefile index 8a19de9..81cab8a 100644 --- a/src/uml-tools/tunctl/Makefile +++ b/src/tools-20070815/tunctl/Makefile @@ -1,6 +1,6 @@ OBJS = tunctl.o BIN = tunctl -CFLAGS = -g -Wall +CFLAGS ?= -g -Wall BIN_DIR ?= /usr/bin diff --git a/src/tools-20070815/tunctl/tunctl.c b/src/tools-20070815/tunctl/tunctl.c new file mode 100644 index 0000000..16e24a2 --- /dev/null +++ b/src/tools-20070815/tunctl/tunctl.c @@ -0,0 +1,156 @@ +/* Copyright 2002 Jeff Dike + * Licensed under the GPL + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* TUNSETGROUP appeared in 2.6.23 */ +#ifndef TUNSETGROUP +#define TUNSETGROUP _IOW('T', 206, int) +#endif + +static void Usage(char *name) +{ + fprintf(stderr, "Create: %s [-b] [-u owner] [-g group] [-t device-name] " + "[-f tun-clone-device]\n", name); + fprintf(stderr, "Delete: %s -d device-name [-f tun-clone-device]\n\n", + name); + fprintf(stderr, "The default tun clone device is /dev/net/tun - some systems" + " use\n/dev/misc/net/tun instead\n\n"); + fprintf(stderr, "-b will result in brief output (just the device name)\n"); + exit(1); +} + +int main(int argc, char **argv) +{ + struct ifreq ifr; + struct passwd *pw; + struct group *gr; + uid_t owner = -1; + gid_t group = -1; + int tap_fd, opt, delete = 0, brief = 0; + char *tun = "", *file = "/dev/net/tun", *name = argv[0], *end; + + while((opt = getopt(argc, argv, "bd:f:t:u:g:")) > 0){ + switch(opt) { + case 'b': + brief = 1; + break; + case 'd': + delete = 1; + tun = optarg; + break; + case 'f': + file = optarg; + break; + case 'u': + pw = getpwnam(optarg); + if(pw != NULL){ + owner = pw->pw_uid; + break; + } + owner = strtol(optarg, &end, 0); + if(*end != '\0'){ + fprintf(stderr, "'%s' is neither a username nor a numeric uid.\n", + optarg); + Usage(name); + } + break; + case 'g': + gr = getgrnam(optarg); + if(gr != NULL){ + group = gr->gr_gid; + break; + } + group = strtol(optarg, &end, 0); + if(*end != '\0'){ + fprintf(stderr, "'%s' is neither a groupname nor a numeric group.\n", + optarg); + Usage(name); + } + break; + + case 't': + tun = optarg; + break; + case 'h': + default: + Usage(name); + } + } + + argv += optind; + argc -= optind; + + if(argc > 0) + Usage(name); + + if((tap_fd = open(file, O_RDWR)) < 0){ + fprintf(stderr, "Failed to open '%s' : ", file); + perror(""); + exit(1); + } + + memset(&ifr, 0, sizeof(ifr)); + + ifr.ifr_flags = IFF_TAP | IFF_NO_PI; + strncpy(ifr.ifr_name, tun, sizeof(ifr.ifr_name) - 1); + if(ioctl(tap_fd, TUNSETIFF, (void *) &ifr) < 0){ + perror("TUNSETIFF"); + exit(1); + } + + if(delete){ + if(ioctl(tap_fd, TUNSETPERSIST, 0) < 0){ + perror("disabling TUNSETPERSIST"); + exit(1); + } + printf("Set '%s' nonpersistent\n", ifr.ifr_name); + } + else { + /* emulate behaviour prior to TUNSETGROUP */ + if(owner == -1 && group == -1) { + owner = geteuid(); + } + + if(owner != -1) { + if(ioctl(tap_fd, TUNSETOWNER, owner) < 0){ + perror("TUNSETOWNER"); + exit(1); + } + } + if(group != -1) { + if(ioctl(tap_fd, TUNSETGROUP, group) < 0){ + perror("TUNSETGROUP"); + exit(1); + } + } + + if(ioctl(tap_fd, TUNSETPERSIST, 1) < 0){ + perror("enabling TUNSETPERSIST"); + exit(1); + } + + if(brief) + printf("%s\n", ifr.ifr_name); + else { + printf("Set '%s' persistent and owned by", ifr.ifr_name); + if(owner != -1) + printf(" uid %d", owner); + if(group != -1) + printf(" gid %d", group); + printf("\n"); + } + } + return(0); +} diff --git a/src/uml-tools/mconsole/Makefile b/src/tools-20070815/uml_dump/Makefile similarity index 68% rename from src/uml-tools/mconsole/Makefile rename to src/tools-20070815/uml_dump/Makefile index 8cb6333..73d1e46 100644 --- a/src/uml-tools/mconsole/Makefile +++ b/src/tools-20070815/uml_dump/Makefile @@ -1,5 +1,5 @@ -BIN = uml_mconsole -OBJS = $(BIN).o +OBJS = uml_dump.o +BIN = uml_dump CFLAGS = -g -Wall BIN_DIR ?= /usr/bin @@ -7,7 +7,7 @@ BIN_DIR ?= /usr/bin all : $(BIN) $(BIN) : $(OBJS) - $(CC) $(CFLAGS) -o $(BIN) $(OBJS) -lreadline -lncurses + $(CC) $(CFLAGS) -o $(BIN) $(OBJS) clean : rm -f $(BIN) $(OBJS) *~ diff --git a/src/tools-20070815/uml_dump/uml_dump.c b/src/tools-20070815/uml_dump/uml_dump.c new file mode 100644 index 0000000..4ff84cf --- /dev/null +++ b/src/tools-20070815/uml_dump/uml_dump.c @@ -0,0 +1,276 @@ +/* + * Copyright 2008 + * Authors: + * - Julien Iguchi-Cartigny + * - Jean-Baptiste Machemie + * - Benoit Bitarelle + * Licensed under the GPL + * + * TODO: receive packets from multiple uml switchs + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../uml_router/switch.h" +#include "../uml_router/uml_switch.h" +#include "../uml_router/port.h" + +/***************** PCAP Part *****************/ + +int output_fd; + +unsigned char pcap_file_header[] = { + 0xd4, 0xc3, 0xb2, 0Xa1, // magic number + 0x02, 0x00, 0x04, 0x00, // major and minor version number: 2.4 + 0x00, 0x00, 0x00, 0x00, // thiszone: GMT + 0x00, 0x00, 0x00, 0x00, // accuracy: 0 + 0xEA, 0x05, 0x00, 0x00, // max length of captured packet: 1514 + 0x01, 0x00, 0x00, 0x00 // data link type: ethernet +}; + +unsigned int pcap_packet_header[] = { + 0, // timestamp second + 0, // timestamp microsecond + 0, // number of octets of packet saved in file + 0 // actual length of packet +}; + +struct timeval tv; + +void dump_packet(struct packet *packet, int size) { + + int w; + + gettimeofday(&tv, (void*)0); + + pcap_packet_header[0] = tv.tv_sec; + pcap_packet_header[1] = tv.tv_usec; + pcap_packet_header[2] = size; + pcap_packet_header[3] = size; + + w = fwrite(pcap_packet_header, sizeof(unsigned char), + sizeof(pcap_packet_header), stdout); + + if(w<=0) + perror("error when writing packet header to stdout"); + + w = fwrite((unsigned char*)packet, sizeof(unsigned char), size, stdout); + + if(w<=0) + perror("error when writing packet data to stdout"); + + w = fflush(stdout); + + if(w!=0) + perror("error flushing stdout"); +} + +/***************** UML Part *****************/ + +static char *prog; + +static char *ctl_socket = "/tmp/uml.ctl"; + +int connect_fd, data_out_fd, data_in_fd; + +void cleanup() { + close(connect_fd); + close(data_out_fd); +} + +static void sig_handler(int sig) +{ + fprintf(stderr,"Caught signal %d, cleaning up and exiting\n", sig); + cleanup(); + signal(sig, SIG_DFL); + kill(getpid(), sig); +} + +static void usage(void) +{ + fprintf(stderr, "Usage : %s control-socket\n" + "if no parameter %s is used as control socket\n", + prog, ctl_socket); + exit(1); +} + + +int main(int argc, char *argv[]) { + + prog = argv[0]; + argv++; + argc--; + + /* parameter -help */ + if(argc == 1) { + + if(!strcmp(argv[0], "-help")){ + usage(); + } + + ctl_socket = argv[0]; + } + + if(argc > 1) { + usage(); + } + + /* ask for the data in socket */ + if((data_in_fd = socket(PF_UNIX, SOCK_DGRAM, 0)) < 0){ + perror("socket"); + exit(1); + } + + if(fcntl(data_in_fd, F_SETFL, O_NONBLOCK) < 0){ + perror("setting O_NONBLOCK on data in fd"); + exit(1); + } + + /* prepare the data in structure */ + struct sockaddr_un data_in_sun; + + struct { + char zero; + int pid; + int usecs; + } name; + + struct timeval tv; + + name.zero = 0; + name.pid = getpid(); + gettimeofday(&tv, NULL); + name.usecs = tv.tv_usec; + + data_in_sun.sun_family = AF_UNIX; + memcpy(data_in_sun.sun_path, &name, sizeof(name)); + + /* bind data_in_socket */ + if(bind(data_in_fd, (struct sockaddr*) &data_in_sun, + sizeof(data_in_sun)) < 0){ + perror("binding to data in socket"); + exit(1); + } + + /* ask for the connect socket */ + if((connect_fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0){ + perror("socket connect"); + exit(1); + } + + /* start the connect socket */ + struct sockaddr_un connect_sun; + + connect_sun.sun_family = AF_UNIX; + strncpy(connect_sun.sun_path, ctl_socket, sizeof(connect_sun.sun_path)); + + if(connect(connect_fd, (struct sockaddr *)&connect_sun, + sizeof(connect_sun)) < 0){ + perror("connect connect"); + fprintf(stderr,"check the path to control socket: %s\n", ctl_socket); + exit(1); + } + + /* prepare the request */ + struct request_v3 request; + request.magic = 0xfeedface; + request.version = 3; + request.type = REQ_NEW_DUMP; + request.sock = data_in_sun; + + int n; + + /* send the request */ + n = send(connect_fd, &request, sizeof(request), 0); + + if(n < sizeof(request)) { + fprintf(stderr,"not enough byte sent or error: %d\n", n); + exit(1); + } + + /* receive the data out socket addr (we don't really care about it) */ + struct sockaddr_un data_out_sun; + + n = recv(connect_fd, &data_out_sun, sizeof(data_out_sun), 0); + + if(n < sizeof(data_out_sun)) { + fprintf(stderr,"not enough byte received or error: %d\n", n); + exit(1); + } + + /* prepare the pool */ + struct pollfd p[2]; + + p[0].fd = connect_fd; + p[0].events = POLLIN; + p[1].fd = data_in_fd; + p[1].events = POLLIN; + + /* setup the signal handler for CTRL-C */ + if(signal(SIGINT, sig_handler) < 0) + perror("Setting handler for SIGINT"); + + /* setup the signal handler for closed pipe by reader */ + if(signal(SIGPIPE, sig_handler) < 0) + perror("Setting handler for SIGPIPE"); + + /* writing pcap header to stdout */ + int w = fwrite(pcap_file_header, sizeof(unsigned char), + sizeof(pcap_file_header), stdout); + + if(w<=0) + perror("error when writing cap header to stdout"); + + struct packet packet; + + /* the main loop */ + while(1) { + + /* waiting */ + n = poll(p, 2, -1); + + if(n < 0){ + if(errno == EINTR) continue; /* if poll stop by a signal */ + perror("poll"); + break; + } + + /* check control socket */ + if(p[0].revents) { + if(p[0].revents & POLLHUP){ + fprintf(stderr,"uml_switch disconnected\n"); + break; + } else { + fprintf(stderr,"control packet in excess ?\n"); + exit(1); + } + } + + /* check data out socket */ + if(p[1].revents) { + + n = recv(data_in_fd, &packet, sizeof(packet), 0); + if(n < 0 && errno != EAGAIN) { + perror("recv data out socket\n"); + exit(1); + } + + dump_packet(&packet,n); + } + } + + cleanup(); + + return 0; +} diff --git a/src/uml-tools/uml_net/.cvsignore b/src/tools-20070815/uml_net/.cvsignore similarity index 100% rename from src/uml-tools/uml_net/.cvsignore rename to src/tools-20070815/uml_net/.cvsignore diff --git a/src/tools-20070815/uml_net/CVS/Entries b/src/tools-20070815/uml_net/CVS/Entries new file mode 100644 index 0000000..45bec27 --- /dev/null +++ b/src/tools-20070815/uml_net/CVS/Entries @@ -0,0 +1,11 @@ +/output.h/1.1/Tue Nov 13 05:25:26 2001// +/host.h/1.3/Mon Dec 10 04:36:26 2001// +/.cvsignore/1.1/Fri Jan 11 05:21:31 2002// +/host.c/1.6/Sun Apr 28 13:26:07 2002// +/output.c/1.2/Sun Apr 28 13:38:44 2002// +/slip.c/1.5/Sun Apr 28 19:47:35 2002// +/Makefile/1.8/Sat Feb 8 04:04:55 2003// +/uml_net.c/1.19/Tue May 27 02:52:21 2003// +/ethertap.c/1.9/Sat Nov 8 13:15:25 2003// +/tuntap.c/1.6/Sat Nov 8 13:04:58 2003// +D diff --git a/src/tools-20070815/uml_net/CVS/Repository b/src/tools-20070815/uml_net/CVS/Repository new file mode 100644 index 0000000..5ce7289 --- /dev/null +++ b/src/tools-20070815/uml_net/CVS/Repository @@ -0,0 +1 @@ +tools/uml_net diff --git a/src/tools-20070815/uml_net/CVS/Root b/src/tools-20070815/uml_net/CVS/Root new file mode 100644 index 0000000..4f921bb --- /dev/null +++ b/src/tools-20070815/uml_net/CVS/Root @@ -0,0 +1 @@ +jdike@cvs.user-mode-linux.sourceforge.net:/cvsroot/user-mode-linux diff --git a/src/uml-tools/uml_net/Makefile b/src/tools-20070815/uml_net/Makefile similarity index 89% rename from src/uml-tools/uml_net/Makefile rename to src/tools-20070815/uml_net/Makefile index 74af7e3..f877845 100644 --- a/src/uml-tools/uml_net/Makefile +++ b/src/tools-20070815/uml_net/Makefile @@ -1,7 +1,8 @@ TUNTAP = $(shell [ -e /usr/include/linux/if_tun.h ] && echo -DTUNTAP) BIN = uml_net -CFLAGS = -g -Wall $(TUNTAP) +CFLAGS ?= -g -Wall +override CFLAGS += $(TUNTAP) BIN_DIR ?= /usr/bin diff --git a/src/uml-tools/uml_net/ethertap.c b/src/tools-20070815/uml_net/ethertap.c similarity index 100% rename from src/uml-tools/uml_net/ethertap.c rename to src/tools-20070815/uml_net/ethertap.c diff --git a/src/uml-tools/uml_net/host.c b/src/tools-20070815/uml_net/host.c similarity index 99% rename from src/uml-tools/uml_net/host.c rename to src/tools-20070815/uml_net/host.c index 65c20df..24e477e 100644 --- a/src/uml-tools/uml_net/host.c +++ b/src/tools-20070815/uml_net/host.c @@ -104,7 +104,7 @@ static void local_net_do(char **argv, int if_index, char *addr_str, int is_a_device(char *dev) { - int i; + unsigned i; for(i = 0; i < strlen(dev); i++){ if(!isalnum(dev[i])) return(0); diff --git a/src/uml-tools/uml_net/host.h b/src/tools-20070815/uml_net/host.h similarity index 100% rename from src/uml-tools/uml_net/host.h rename to src/tools-20070815/uml_net/host.h diff --git a/src/uml-tools/uml_net/output.c b/src/tools-20070815/uml_net/output.c similarity index 100% rename from src/uml-tools/uml_net/output.c rename to src/tools-20070815/uml_net/output.c diff --git a/src/uml-tools/uml_net/output.h b/src/tools-20070815/uml_net/output.h similarity index 100% rename from src/uml-tools/uml_net/output.h rename to src/tools-20070815/uml_net/output.h diff --git a/src/uml-tools/uml_net/slip.c b/src/tools-20070815/uml_net/slip.c similarity index 88% rename from src/uml-tools/uml_net/slip.c rename to src/tools-20070815/uml_net/slip.c index 5089d66..78d2b9c 100644 --- a/src/uml-tools/uml_net/slip.c +++ b/src/tools-20070815/uml_net/slip.c @@ -111,7 +111,7 @@ void slip_v3(int argc, char **argv) void slip_v4(int argc, char **argv) { struct output output = INIT_OUTPUT; - char *op; + char *op, dev[sizeof("slnnnnn\0")]; if(setreuid(0, 0) < 0){ output_errno(&output, "slip - setreuid failed"); @@ -135,7 +135,14 @@ void slip_v4(int argc, char **argv) slip_up(0, argv[1], NULL, NULL, &output); } else if(!strcmp(op, "down")){ - slip_down(argv[1], NULL, NULL, &output); + /* We now pass the interface to the "down" command as an open FD, rather + * than as a name, because the latter allowed anybody to use uml_net to down + * a interface he didn't own. + * + * Instead, as Steve Schmidtke said, an open FD is a proof that you own the + * interface, so this way we should be safe. */ + slip_name(0, dev, &output); + slip_down(dev, NULL, NULL, &output); } else { printf("slip - Unknown op '%s'\n", op); diff --git a/src/uml-tools/uml_net/tuntap.c b/src/tools-20070815/uml_net/tuntap.c similarity index 100% rename from src/uml-tools/uml_net/tuntap.c rename to src/tools-20070815/uml_net/tuntap.c diff --git a/src/uml-tools/uml_net/uml_net.c b/src/tools-20070815/uml_net/uml_net.c similarity index 100% rename from src/uml-tools/uml_net/uml_net.c rename to src/tools-20070815/uml_net/uml_net.c diff --git a/src/tools-20070815/uml_router/Makefile.orig b/src/tools-20070815/uml_router/Makefile.orig new file mode 100644 index 0000000..e69de29 diff --git a/src/tools-20070815/uml_router/Makefile.rej b/src/tools-20070815/uml_router/Makefile.rej new file mode 100644 index 0000000..4e0748a --- /dev/null +++ b/src/tools-20070815/uml_router/Makefile.rej @@ -0,0 +1,10 @@ +--- uml_router/Makefile 2003-02-19 01:16:27.000000000 +0100 ++++ uml_router/Makefile 2009-05-01 23:31:20.088977298 +0200 +@@ -1,6 +1,6 @@ + TUNTAP = $(shell [ -e /usr/include/linux/if_tun.h ] && echo -DTUNTAP) + +-OBJS = hash.o port.o uml_switch.o ++OBJS = hash.o port.o uml_switch.o + BIN = uml_switch + CFLAGS = -g -Wall $(TUNTAP) + diff --git a/src/tools-20070815/uml_router/port.c.orig b/src/tools-20070815/uml_router/port.c.orig new file mode 100644 index 0000000..e69de29 diff --git a/src/tools-20070815/uml_router/port.c.rej b/src/tools-20070815/uml_router/port.c.rej new file mode 100644 index 0000000..98d6646 --- /dev/null +++ b/src/tools-20070815/uml_router/port.c.rej @@ -0,0 +1,102 @@ +--- uml_router/port.c 2003-03-12 17:35:03.000000000 +0100 ++++ uml_router/port.c 2009-05-01 23:31:20.593666238 +0200 +@@ -8,25 +8,6 @@ + #include "hash.h" + #include "port.h" + +-struct packet { +- struct { +- unsigned char dest[ETH_ALEN]; +- unsigned char src[ETH_ALEN]; +- unsigned char proto[2]; +- } header; +- unsigned char data[1500]; +-}; +- +-struct port { +- struct port *next; +- struct port *prev; +- int control; +- void *data; +- int data_len; +- unsigned char src[ETH_ALEN]; +- void (*sender)(int fd, void *packet, int len, void *data); +-}; +- + static struct port *head = NULL; + + #define IS_BROADCAST(addr) ((addr[0] & 1) == 1) +@@ -107,7 +88,16 @@ + (*p->sender)(p->control, packet, len, p->data); + } + } +- else (*target->sender)(target->control, packet, len, target->data); ++ else { ++ ++ /* looking for dump port */ ++ for(p = head; p != NULL; p = p->next){ ++ if(p == port) continue; ++ if(p->dump) ++ (*p->sender)(p->control, packet, len, p->data); ++ } ++ (*target->sender)(target->control, packet, len, target->data); ++ } + } + + static void handle_data(int fd, int hub, struct packet *packet, int len, +@@ -149,7 +139,7 @@ + } + + int setup_port(int fd, void (*sender)(int fd, void *packet, int len, +- void *data), void *data, int data_len) ++ void *data), void *data, int data_len, int dump) + { + struct port *port; + +@@ -165,6 +155,7 @@ + port->data = data; + port->data_len = data_len; + port->sender = sender; ++ port->dump = dump; + head = port; + printf("New connection\n"); + return(0); +@@ -215,7 +206,7 @@ + handle_data(fd, hub, &packet, len, &data, match_sock); + } + +-int setup_sock_port(int fd, struct sockaddr_un *name, int data_fd) ++int setup_sock_port(int fd, struct sockaddr_un *name, int data_fd, int dump) + { + struct sock_data *data; + +@@ -226,7 +217,7 @@ + } + *data = ((struct sock_data) { fd : data_fd, + sock : *name }); +- return(setup_port(fd, send_sock, data, sizeof(*data))); ++ return(setup_port(fd, send_sock, data, sizeof(*data), dump)); + } + + static void service_port(struct port *port) +@@ -235,9 +226,12 @@ + char c; + + n = read(port->control, &c, sizeof(c)); +- if(n < 0) perror("Reading request"); +- else if(n == 0) printf("Disconnect\n"); +- else printf("Bad request\n"); ++ if(n < 0) ++ perror("Reading request"); ++ else if(n == 0) ++ printf("Disconnect\n"); ++ else ++ printf("Bad request\n"); + } + + int handle_port(int fd) +@@ -252,4 +246,3 @@ + } + return(1); + } +- diff --git a/src/tools-20070815/uml_router/port.h.orig b/src/tools-20070815/uml_router/port.h.orig new file mode 100644 index 0000000..e69de29 diff --git a/src/tools-20070815/uml_router/port.h.rej b/src/tools-20070815/uml_router/port.h.rej new file mode 100644 index 0000000..0ec35d7 --- /dev/null +++ b/src/tools-20070815/uml_router/port.h.rej @@ -0,0 +1,37 @@ +--- uml_router/port.h 2002-04-10 22:08:09.000000000 +0200 ++++ uml_router/port.h 2009-05-01 23:31:20.717552166 +0200 +@@ -8,12 +8,32 @@ + #include + #include + ++struct packet { ++ struct { ++ unsigned char dest[ETH_ALEN]; ++ unsigned char src[ETH_ALEN]; ++ unsigned char proto[2]; ++ } header; ++ unsigned char data[1500]; ++}; ++ ++struct port { ++ struct port *next; ++ struct port *prev; ++ int control; ++ void *data; ++ int data_len; ++ unsigned char src[ETH_ALEN]; ++ void (*sender)(int fd, void *packet, int len, void *data); ++ int dump; ++}; ++ + extern int handle_port(int fd); + extern void close_port(int fd); +-extern int setup_sock_port(int fd, struct sockaddr_un *name, int data_fd); ++extern int setup_sock_port(int fd, struct sockaddr_un *name, int data_fd, int dump); + extern int setup_port(int fd, void (*sender)(int fd, void *packet, int len, + void *data), void *data, +- int data_len); ++ int data_len, int dump); + extern void handle_tap_data(int fd, int hub); + extern void handle_sock_data(int fd, int hub); + diff --git a/src/tools-20070815/uml_router/tuntap.c.orig b/src/tools-20070815/uml_router/tuntap.c.orig new file mode 100644 index 0000000..e69de29 diff --git a/src/tools-20070815/uml_router/tuntap.c.rej b/src/tools-20070815/uml_router/tuntap.c.rej new file mode 100644 index 0000000..f88a25f --- /dev/null +++ b/src/tools-20070815/uml_router/tuntap.c.rej @@ -0,0 +1,19 @@ +--- uml_router/tuntap.c 2002-04-27 19:02:16.000000000 +0200 ++++ uml_router/tuntap.c 2009-05-01 23:31:21.088773438 +0200 +@@ -6,6 +6,7 @@ + #include + #include + #include ++#include "switch.h" + #include "port.h" + + static void send_tap(int fd, void *packet, int len, void *unused) +@@ -35,7 +36,7 @@ + close(fd); + return(-1); + } +- err = setup_port(fd, send_tap, NULL, 0); ++ err = setup_port(fd, send_tap, NULL, 0, 0); + if(err) return(err); + return(fd); + } diff --git a/src/tools-20070815/uml_router/uml_switch.c.orig b/src/tools-20070815/uml_router/uml_switch.c.orig new file mode 100644 index 0000000..e69de29 diff --git a/src/tools-20070815/uml_router/uml_switch.c.rej b/src/tools-20070815/uml_router/uml_switch.c.rej new file mode 100644 index 0000000..c3cb75a --- /dev/null +++ b/src/tools-20070815/uml_router/uml_switch.c.rej @@ -0,0 +1,141 @@ +--- uml_router/uml_switch.c 2003-09-03 22:16:32.000000000 +0200 ++++ uml_router/uml_switch.c 2009-05-01 23:31:21.665168486 +0200 +@@ -7,9 +7,7 @@ + #include + #include + #include +-#include + #include +-#include + #include + #include + #include +@@ -19,6 +17,7 @@ + #ifdef TUNTAP + #include "tuntap.h" + #endif ++#include "uml_switch.h" + + #ifdef notdef + #include +@@ -26,58 +25,6 @@ + + static int hub = 0; + static int compat_v0 = 0; +- +-enum request_type { REQ_NEW_CONTROL }; +- +-struct request_v0 { +- enum request_type type; +- union { +- struct { +- unsigned char addr[ETH_ALEN]; +- struct sockaddr_un name; +- } new_control; +- } u; +-}; +- +-#define SWITCH_MAGIC 0xfeedface +- +-struct request_v1 { +- uint32_t magic; +- enum request_type type; +- union { +- struct { +- unsigned char addr[ETH_ALEN]; +- struct sockaddr_un name; +- } new_control; +- } u; +-}; +- +-struct request_v2 { +- uint32_t magic; +- uint32_t version; +- enum request_type type; +- struct sockaddr_un sock; +-}; +- +-struct reply_v2 { +- unsigned char mac[ETH_ALEN]; +- struct sockaddr_un sock; +-}; +- +-struct request_v3 { +- uint32_t magic; +- uint32_t version; +- enum request_type type; +- struct sockaddr_un sock; +-}; +- +-union request { +- struct request_v0 v0; +- struct request_v1 v1; +- struct request_v2 v2; +- struct request_v3 v3; +-}; +- + static char *ctl_socket = "/tmp/uml.ctl"; + + static char *data_socket = NULL; +@@ -149,7 +96,11 @@ + { + switch(req->type){ + case REQ_NEW_CONTROL: +- setup_sock_port(fd, &req->u.new_control.name, data_fd); ++ setup_sock_port(fd, &req->u.new_control.name, data_fd, 0); ++ break; ++ case REQ_NEW_DUMP: ++ printf("REQ_NEW_DUMP for version 0 not supported\n"); ++ close_descriptor(fd); + break; + default: + printf("Bad request type : %d\n", req->type); +@@ -164,7 +115,8 @@ + + switch(type){ + case REQ_NEW_CONTROL: +- err = setup_sock_port(fd, sock, data_fd); ++ case REQ_NEW_DUMP: ++ err = setup_sock_port(fd, sock, data_fd, (type == REQ_NEW_DUMP)); + if(err) return; + n = write(fd, &data_sun, sizeof(data_sun)); + if(n != sizeof(data_sun)){ +@@ -203,14 +155,28 @@ + return; + } + if(req.v1.magic == SWITCH_MAGIC){ +- if(req.v2.version == 2) new_port_v2(fd, &req.v2, data_fd); ++ ++ /* version 2*/ ++ if(req.v2.version == 2) ++ new_port_v2(fd, &req.v2, data_fd); ++ ++ /* version 3 */ + if(req.v3.version == 3) + new_port_v1_v3(fd, req.v3.type, &req.v3.sock, data_fd); ++ ++ /* version unknow */ + else if(req.v2.version > 2) + fprintf(stderr, "Request for a version %d port, which this " + "uml_switch doesn't support\n", req.v2.version); ++ ++ /* version 1 */ ++ else if(req.v1.type == REQ_NEW_DUMP) ++ fprintf(stderr, "REQ_NEW_DUMP request for version 1, which this " ++ "uml_switch doesn't support\n"); + else new_port_v1_v3(fd, req.v1.type, &req.v1.u.new_control.name, data_fd); + } ++ ++ /* version 0*/ + else new_port_v0(fd, &req.v0, data_fd); + } + +@@ -528,6 +494,8 @@ + } + for(i = 0; i < nfds; i++){ + if(fds[i].revents == 0) continue; ++ ++ /* stdin */ + if(fds[i].fd == 0){ + if(fds[i].revents & POLLHUP){ + printf("EOF on stdin, cleaning up and exiting\n"); diff --git a/src/tools-20070815/uml_router/uml_switch.h b/src/tools-20070815/uml_router/uml_switch.h new file mode 100644 index 0000000..6f6ed81 --- /dev/null +++ b/src/tools-20070815/uml_router/uml_switch.h @@ -0,0 +1,67 @@ +/* Copyright 2008 Jeff Dike & Kartoch + * Licensed under the GPL + */ + +#ifndef __UML_SWITCH_H__ +#define __UML_SWITCH_H__ + +#include +#include + +enum request_type { + REQ_NEW_CONTROL, + REQ_NEW_DUMP +}; + +struct request_v0 { + enum request_type type; + union { + struct { + unsigned char addr[ETH_ALEN]; + struct sockaddr_un name; + } new_control; + } u; +}; + +#define SWITCH_MAGIC 0xfeedface + +struct request_v1 { + uint32_t magic; + enum request_type type; + union { + struct { + unsigned char addr[ETH_ALEN]; + struct sockaddr_un name; + } new_control; + } u; +}; + +struct request_v2 { + uint32_t magic; + uint32_t version; + enum request_type type; + struct sockaddr_un sock; +}; + +struct reply_v2 { + unsigned char mac[ETH_ALEN]; + struct sockaddr_un sock; +}; + +struct request_v3 { + uint32_t magic; + uint32_t version; + enum request_type type; + struct sockaddr_un sock; +}; + +union request { + struct request_v0 v0; + struct request_v1 v1; + struct request_v2 v2; + struct request_v3 v3; +}; + +#endif + + diff --git a/src/uml-tools/uml_router/.cvsignore b/src/tools-20070815/uml_switch/.cvsignore similarity index 100% rename from src/uml-tools/uml_router/.cvsignore rename to src/tools-20070815/uml_switch/.cvsignore diff --git a/src/tools-20070815/uml_switch/CVS/Entries b/src/tools-20070815/uml_switch/CVS/Entries new file mode 100644 index 0000000..0e36df4 --- /dev/null +++ b/src/tools-20070815/uml_switch/CVS/Entries @@ -0,0 +1,11 @@ +/.cvsignore/1.1/Fri Jan 11 05:21:31 2002// +/switch.h/1.1/Sun Apr 7 17:57:12 2002// +/tuntap.h/1.1/Wed Apr 10 11:21:56 2002// +/port.h/1.1/Wed Apr 10 13:07:02 2002// +/hash.h/1.2/Tue Apr 9 14:38:23 2002// +/hash.c/1.3/Sat Apr 27 15:42:04 2002// +/tuntap.c/1.2/Wed Apr 24 00:13:30 2002// +/Makefile/1.10/Sat Feb 8 04:04:39 2003// +/port.c/1.4/Wed Mar 12 15:19:03 2003// +/uml_switch.c/1.11/Fri Aug 15 19:03:58 2003// +D diff --git a/src/tools-20070815/uml_switch/CVS/Repository b/src/tools-20070815/uml_switch/CVS/Repository new file mode 100644 index 0000000..693f985 --- /dev/null +++ b/src/tools-20070815/uml_switch/CVS/Repository @@ -0,0 +1 @@ +tools/uml_router diff --git a/src/tools-20070815/uml_switch/CVS/Root b/src/tools-20070815/uml_switch/CVS/Root new file mode 100644 index 0000000..4f921bb --- /dev/null +++ b/src/tools-20070815/uml_switch/CVS/Root @@ -0,0 +1 @@ +jdike@cvs.user-mode-linux.sourceforge.net:/cvsroot/user-mode-linux diff --git a/src/uml-tools/uml_router/Makefile b/src/tools-20070815/uml_switch/Makefile similarity index 88% rename from src/uml-tools/uml_router/Makefile rename to src/tools-20070815/uml_switch/Makefile index e140f54..7f9c5e1 100644 --- a/src/uml-tools/uml_router/Makefile +++ b/src/tools-20070815/uml_switch/Makefile @@ -2,7 +2,8 @@ TUNTAP = $(shell [ -e /usr/include/linux/if_tun.h ] && echo -DTUNTAP) OBJS = hash.o port.o uml_switch.o BIN = uml_switch -CFLAGS = -g -Wall $(TUNTAP) +CFLAGS ?= -g -Wall +override CFLAGS += $(TUNTAP) BIN_DIR ?= /usr/bin diff --git a/src/uml-tools/uml_router/hash.c b/src/tools-20070815/uml_switch/hash.c similarity index 92% rename from src/uml-tools/uml_router/hash.c rename to src/tools-20070815/uml_switch/hash.c index da07556..ab8b094 100644 --- a/src/uml-tools/uml_router/hash.c +++ b/src/tools-20070815/uml_switch/hash.c @@ -28,12 +28,12 @@ struct hash_entry { static struct hash_entry *h[HASH_SIZE]; -static int calc_hash(char *src) +static int calc_hash(unsigned char *src) { return ((*(u_int32_t *) &src[0] % HASH_MOD) ^ src[4] ^ src[5] ) % HASH_SIZE ; } -static struct hash_entry *find_entry(char *dst) +static struct hash_entry *find_entry(unsigned char *dst) { struct hash_entry *e; int k = calc_hash(dst); @@ -44,14 +44,14 @@ static struct hash_entry *find_entry(char *dst) return(NULL); } -void *find_in_hash(char *dst) +void *find_in_hash(unsigned char *dst) { struct hash_entry *e = find_entry(dst); if(e == NULL) return(NULL); return(e->port); } -void insert_into_hash(char *src, void *port) +void insert_into_hash(unsigned char *src, void *port) { struct hash_entry *new; int k = calc_hash(src); @@ -74,7 +74,7 @@ void insert_into_hash(char *src, void *port) h[k] = new; } -void update_entry_time(char *src) +void update_entry_time(unsigned char *src) { struct hash_entry *e; @@ -93,7 +93,7 @@ static void delete_hash_entry(struct hash_entry *old) free(old); } -void delete_hash(char *dst) +void delete_hash(unsigned char *dst) { struct hash_entry *old = find_entry(dst); diff --git a/src/tools-20070815/uml_switch/hash.h b/src/tools-20070815/uml_switch/hash.h new file mode 100644 index 0000000..08d1ffe --- /dev/null +++ b/src/tools-20070815/uml_switch/hash.h @@ -0,0 +1,15 @@ +/* Copyright 2002 Yon Uriarte and Jeff Dike + * Licensed under the GPL + */ + +#ifndef __HASH_H__ +#define __HASH_H__ + +extern void *find_in_hash(unsigned char *dst); +extern void insert_into_hash(unsigned char *src, void *port); +extern void delete_hash(unsigned char *dst); +extern void print_hash(char *(*port_id)(void *)); +extern void update_entry_time(unsigned char *src); +extern void hash_init(void); + +#endif diff --git a/src/uml-tools/uml_router/port.c b/src/tools-20070815/uml_switch/port.c similarity index 99% rename from src/uml-tools/uml_router/port.c rename to src/tools-20070815/uml_switch/port.c index 5e4271f..2b02d41 100644 --- a/src/uml-tools/uml_router/port.c +++ b/src/tools-20070815/uml_switch/port.c @@ -202,7 +202,8 @@ void handle_sock_data(int fd, int hub) { struct packet packet; struct sock_data data; - int len, socklen = sizeof(data.sock); + int len; + unsigned int socklen = sizeof(data.sock); len = recvfrom(fd, &packet, sizeof(packet), 0, (struct sockaddr *) &data.sock, &socklen); diff --git a/src/uml-tools/uml_router/port.h b/src/tools-20070815/uml_switch/port.h similarity index 100% rename from src/uml-tools/uml_router/port.h rename to src/tools-20070815/uml_switch/port.h diff --git a/src/uml-tools/uml_router/switch.h b/src/tools-20070815/uml_switch/switch.h similarity index 100% rename from src/uml-tools/uml_router/switch.h rename to src/tools-20070815/uml_switch/switch.h diff --git a/src/uml-tools/uml_router/tuntap.c b/src/tools-20070815/uml_switch/tuntap.c similarity index 100% rename from src/uml-tools/uml_router/tuntap.c rename to src/tools-20070815/uml_switch/tuntap.c diff --git a/src/uml-tools/uml_router/tuntap.h b/src/tools-20070815/uml_switch/tuntap.h similarity index 100% rename from src/uml-tools/uml_router/tuntap.h rename to src/tools-20070815/uml_switch/tuntap.h diff --git a/src/uml-tools/uml_router/uml_switch.c b/src/tools-20070815/uml_switch/uml_switch.c similarity index 98% rename from src/uml-tools/uml_router/uml_switch.c rename to src/tools-20070815/uml_switch/uml_switch.c index d2eb205..b737bd6 100644 --- a/src/uml-tools/uml_router/uml_switch.c +++ b/src/tools-20070815/uml_switch/uml_switch.c @@ -178,7 +178,7 @@ static void new_port_v1_v3(int fd, enum request_type type, } } -static void new_port_v2(int fd, struct request_v2 *req, int data_fd) +static void new_port_v2(int fd) { fprintf(stderr, "Version 2 is not supported\n"); close_descriptor(fd); @@ -203,7 +203,7 @@ static void new_port(int fd, int data_fd) return; } if(req.v1.magic == SWITCH_MAGIC){ - if(req.v2.version == 2) new_port_v2(fd, &req.v2, data_fd); + if(req.v2.version == 2) new_port_v2(fd); if(req.v3.version == 3) new_port_v1_v3(fd, req.v3.type, &req.v3.sock, data_fd); else if(req.v2.version > 2) @@ -217,7 +217,8 @@ static void new_port(int fd, int data_fd) void accept_connection(int fd) { struct sockaddr addr; - int len, new; + unsigned int len; + int new; len = sizeof(addr); new = accept(fd, &addr, &len); @@ -360,7 +361,7 @@ void bind_data_socket(int fd, struct sockaddr_un *sun) void bind_sockets(int ctl_fd, const char *ctl_name, int data_fd) { - int err, used; + int err, used = 0; err = bind_socket(ctl_fd, ctl_name, NULL); if(err == 0){ @@ -487,7 +488,7 @@ int main(int argc, char **argv) exit(1); } - if(signal(SIGINT, sig_handler) < 0) + if(signal(SIGINT, sig_handler) == SIG_ERR) perror("Setting handler for SIGINT"); hash_init(); diff --git a/src/tools-20070815/uml_util.spec b/src/tools-20070815/uml_util.spec new file mode 100644 index 0000000..c236dcc --- /dev/null +++ b/src/tools-20070815/uml_util.spec @@ -0,0 +1,46 @@ +# Generated by RPM Workshop. v0.1 + +# Macro definitions +%define ver 20070815 +%define rel 1 + +Name: uml_utilities +Version: %{ver} +Release: %{rel} +Copyright: GPL +Packager: Someone +URL: http://user-mode-linux.sourceforge.net/index.html +Source: http://prdownloads.sourceforge.net/user-mode-linux/uml_utilities_%{ver}.tar.bz2 +BuildRoot: %{_tmppath}/%{name}-%{ver}-root +Group: System +Summary: Utilities for user-mode linux kernel + +%description +This package contains the utilities for user-mode linux for networking, +COW, etc. + + +%prep +%setup -n tools + +%build +make CFLAGS="-g -Wall -O2" DESTDIR=$RPM_BUILD_ROOT + +%install +make install DESTDIR=$RPM_BUILD_ROOT + +%files +%attr(755,root,root) %{_bindir}/jailtest +#%attr(755,root,root) %{_bindir}/mkrootfs +%attr(755,root,root) %{_bindir}/tunctl +%attr(755,root,root) %{_bindir}/uml_mconsole +%attr(755,root,root) %{_bindir}/uml_moo +%attr(4755,root,root) %{_bindir}/uml_net +%attr(755,root,root) %{_bindir}/uml_switch +%attr(755,root,root) %dir %{_libdir}/uml +%attr(755,root,root) %{_bindir}/uml_mkcow +%attr(755,root,root) %{_bindir}/uml_watchdog +#%attr(755,root,root) %{_libdir}/uml/functions +%attr(755,root,root) %{_libdir}/uml/port-helper + +%clean diff --git a/src/uml-tools/uml_util.spec.in b/src/tools-20070815/uml_util.spec.in similarity index 95% rename from src/uml-tools/uml_util.spec.in rename to src/tools-20070815/uml_util.spec.in index fb758c7..6bb6296 100644 --- a/src/uml-tools/uml_util.spec.in +++ b/src/tools-20070815/uml_util.spec.in @@ -24,7 +24,7 @@ COW, etc. %setup -n tools %build -make DESTDIR=$RPM_BUILD_ROOT +make CFLAGS="-g -Wall -O2" DESTDIR=$RPM_BUILD_ROOT %install make install DESTDIR=$RPM_BUILD_ROOT diff --git a/src/tools-20070815/umlfs/Makefile b/src/tools-20070815/umlfs/Makefile new file mode 100644 index 0000000..ddffc81 --- /dev/null +++ b/src/tools-20070815/umlfs/Makefile @@ -0,0 +1,19 @@ +BIN = uml_mount +OBJS = $(BIN).o +# I have the FUSE headers in /usr/local/include +CFLAGS = -g -Wall -D_FILE_OFFSET_BITS=64 -I/usr/local/include +LIBS = -lfuse + +BIN_DIR ?= /usr/bin + +all : $(BIN) + +$(BIN) : $(OBJS) + $(CC) $(CFLAGS) -o $(BIN) $(OBJS) $(LIBS) + +clean : + rm -f $(BIN) $(OBJS) *~ + +install : $(BIN) + install -d $(DESTDIR)$(BIN_DIR) + install -s $(BIN) $(DESTDIR)$(BIN_DIR) diff --git a/src/tools-20070815/umlfs/uml_mount.c b/src/tools-20070815/umlfs/uml_mount.c new file mode 100644 index 0000000..6c1abbb --- /dev/null +++ b/src/tools-20070815/umlfs/uml_mount.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include +#include + +static int init_fuse(int argc, char **argv) +{ + struct fuse_args args = FUSE_ARGS_INIT(argc, argv); + char *mountpoint; + + if (fuse_parse_cmdline(&args, &mountpoint, NULL, NULL) == -1) + return -EINVAL; + return fuse_mount(mountpoint, &args); +} + +int main(int argc, char **argv) +{ + char *umid, fd_arg[sizeof("1234567890\0")]; + int fd; + + umid = argv[1]; + argv[1] = argv[0]; + argv++; + argc--; + fd = init_fuse(argc, argv); + if(fd < 0) + return 1; + + snprintf(fd_arg, sizeof(fd_arg), "%d", fd); + execlp("uml_mconsole", "uml_mconsole", umid, "umlfs", fd_arg, NULL); + + perror("Failed to exec uml_mconsole\n"); + + return 1; +} diff --git a/src/tools-20070815/umlgdb/CVS/CVS/Entries b/src/tools-20070815/umlgdb/CVS/CVS/Entries new file mode 100644 index 0000000..1784810 --- /dev/null +++ b/src/tools-20070815/umlgdb/CVS/CVS/Entries @@ -0,0 +1 @@ +D diff --git a/src/tools-20070815/umlgdb/CVS/CVS/Repository b/src/tools-20070815/umlgdb/CVS/CVS/Repository new file mode 100644 index 0000000..338317f --- /dev/null +++ b/src/tools-20070815/umlgdb/CVS/CVS/Repository @@ -0,0 +1 @@ +tools/umlgdb/CVS diff --git a/src/tools-20070815/umlgdb/CVS/CVS/Root b/src/tools-20070815/umlgdb/CVS/CVS/Root new file mode 100644 index 0000000..4f921bb --- /dev/null +++ b/src/tools-20070815/umlgdb/CVS/CVS/Root @@ -0,0 +1 @@ +jdike@cvs.user-mode-linux.sourceforge.net:/cvsroot/user-mode-linux diff --git a/src/tools-20070815/umlgdb/CVS/Entries b/src/tools-20070815/umlgdb/CVS/Entries new file mode 100644 index 0000000..091dcb9 --- /dev/null +++ b/src/tools-20070815/umlgdb/CVS/Entries @@ -0,0 +1,3 @@ +D/CVS//// +/Makefile/1.1/Sun Apr 14 20:37:39 2002// +/umlgdb/1.3/Sat Nov 8 13:20:29 2003// diff --git a/src/tools-20070815/umlgdb/CVS/Repository b/src/tools-20070815/umlgdb/CVS/Repository new file mode 100644 index 0000000..35f5b86 --- /dev/null +++ b/src/tools-20070815/umlgdb/CVS/Repository @@ -0,0 +1 @@ +tools/umlgdb diff --git a/src/tools-20070815/umlgdb/CVS/Root b/src/tools-20070815/umlgdb/CVS/Root new file mode 100644 index 0000000..4f921bb --- /dev/null +++ b/src/tools-20070815/umlgdb/CVS/Root @@ -0,0 +1 @@ +jdike@cvs.user-mode-linux.sourceforge.net:/cvsroot/user-mode-linux diff --git a/src/uml-tools/umlgdb/Makefile b/src/tools-20070815/umlgdb/Makefile similarity index 100% rename from src/uml-tools/umlgdb/Makefile rename to src/tools-20070815/umlgdb/Makefile diff --git a/src/uml-tools/umlgdb/umlgdb b/src/tools-20070815/umlgdb/umlgdb old mode 100755 new mode 100644 similarity index 100% rename from src/uml-tools/umlgdb/umlgdb rename to src/tools-20070815/umlgdb/umlgdb diff --git a/src/tools-20070815/watchdog/CVS/Entries b/src/tools-20070815/watchdog/CVS/Entries new file mode 100644 index 0000000..55349e2 --- /dev/null +++ b/src/tools-20070815/watchdog/CVS/Entries @@ -0,0 +1,3 @@ +/uml_watchdog.c/1.1/Tue Jun 4 02:53:57 2002// +/Makefile/1.2/Sat Feb 8 04:04:25 2003// +D diff --git a/src/tools-20070815/watchdog/CVS/Repository b/src/tools-20070815/watchdog/CVS/Repository new file mode 100644 index 0000000..63e7c6f --- /dev/null +++ b/src/tools-20070815/watchdog/CVS/Repository @@ -0,0 +1 @@ +tools/watchdog diff --git a/src/tools-20070815/watchdog/CVS/Root b/src/tools-20070815/watchdog/CVS/Root new file mode 100644 index 0000000..4f921bb --- /dev/null +++ b/src/tools-20070815/watchdog/CVS/Root @@ -0,0 +1 @@ +jdike@cvs.user-mode-linux.sourceforge.net:/cvsroot/user-mode-linux diff --git a/src/uml-tools/watchdog/Makefile b/src/tools-20070815/watchdog/Makefile similarity index 92% rename from src/uml-tools/watchdog/Makefile rename to src/tools-20070815/watchdog/Makefile index 1241c55..3cdfaaf 100644 --- a/src/uml-tools/watchdog/Makefile +++ b/src/tools-20070815/watchdog/Makefile @@ -1,6 +1,6 @@ BIN = uml_watchdog OBJS = $(BIN).o -CFLAGS = -g -Wall +CFLAGS ?= -g -Wall BIN_DIR ?= /usr/bin diff --git a/src/uml-tools/watchdog/uml_watchdog.c b/src/tools-20070815/watchdog/uml_watchdog.c similarity index 100% rename from src/uml-tools/watchdog/uml_watchdog.c rename to src/tools-20070815/watchdog/uml_watchdog.c diff --git a/src/uml-tools/humfsify/Makefile b/src/uml-tools/humfsify/Makefile deleted file mode 100644 index 2188807..0000000 --- a/src/uml-tools/humfsify/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -all install: - -clean: - rm -f *~ diff --git a/src/uml-tools/humfsify/humfsify b/src/uml-tools/humfsify/humfsify deleted file mode 100755 index 8acfe48..0000000 --- a/src/uml-tools/humfsify/humfsify +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -user=$1 ; -group=$2 ; -size=$3 ; - -if [ -z "$user" -o -z "$group" -o -z "$size" ] -then - echo Usage : humfsify user group size; - exit 1 ; -fi - -case $size in - [0-9]*K) size=$[ `echo $size | sed s/K$//` * 1024 ] ;; - [0-9]*M) size=$[ `echo $size | sed s/M$//` * 1024 * 1024 ] ;; - [0-9]*G) size=$[ `echo $size | sed s/G$//` * 1024 * 1024 * 1024] ;; - [0-9]*) ;; - *) echo "Bad filesystem size - '$size'"; - exit 1 ;; -esac - -used=$[ `du -sk data | awk '{print $1}'` * 1024 ]; - -if [ $used -gt $size ] -then - echo "Current disk usage greater than the requested size - $used vs $size" ; - exit 1 -fi - -for f in `cd data ; find .` ; do - full=data/$f; - - uid=`cd data ; ls -ld $f | awk '{print $3}'` ; - [ `echo $uid | sed 's/^[0-9]*$//'` ] && uid=`id -u $uid` ; - - gid=`cd data ; ls -ld $f | awk '{print $4}'` ; - [ `echo $gid | sed 's/^[0-9]*$//'` ] && - gid=`awk -F: "{ if(\\$1==\"$gid\") print \\$3 }" /etc/group | head -1` ; - - meta=metadata/$f ; - if [ -d $full ] - then - mkdir -p $meta ; - chown $user.$group $meta ; - meta=$meta/metadata ; - else - mkdir -p metadata/`dirname $f` ; - chown $user.$group metadata/`dirname $f` ; - fi - chown $user.$group $full ; - echo $uid $gid >> $meta ; - chown $user.$group $meta ; -done - -cat >> superblock < -#include -#include - -static void Usage(void) -{ - fprintf(stderr, "Usage : jail_uml jail-directory uid " - "uml-command-line ...\n"); - exit(1); -} - -int main(int argc, char **argv) -{ - char *dir, *end; - int uid; - - if(geteuid() != 0){ - fprintf(stderr, "jail_uml must be run as root\n"); - exit(1); - } - - if(argc < 3) Usage(); - dir = argv[1]; - uid = strtoul(argv[2], &end, 0); - if(*end != '\0') Usage(); - argc -= 3; - argv += 3; - - if(chdir(dir)){ - perror("chdir"); - exit(1); - } - - if(chroot(".")){ - perror("chroot"); - exit(1); - } - - if(setuid(uid)){ - perror("setuid"); - exit(1); - } - - execv(argv[0], argv); - fprintf(stderr, "execve of %s failed : ", argv[0]); - perror(""); - exit(1); -} diff --git a/src/uml-tools/net/Makefile b/src/uml-tools/net/Makefile deleted file mode 100644 index 59343ee..0000000 --- a/src/uml-tools/net/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -CC = gcc - -CFLAGS = -Wall -ggdb - -all: um_eth_serv um_eth_tool - -SERV_OBJS = input.o um_eth_serv.o output.o - -um_eth_serv: $(SERV_OBJS) - $(CC) $(CFLAGS) -o $@ $(SERV_OBJS) - -um_eth_tool: um_eth_tool.o - $(CC) $(CFLAGS) -o $@ $< - -clean: - rm -rf um_eth_serv um_eth_tool *.o core *~ diff --git a/src/uml-tools/net/README b/src/uml-tools/net/README deleted file mode 100644 index 2bc0468..0000000 --- a/src/uml-tools/net/README +++ /dev/null @@ -1,66 +0,0 @@ -There are a lot of requirements you must have before this will work: --2.2.x or 2.4.x host kernel --Ethertap of TUN/TAP support in the host kernel --bridging support in the host kernel --bridging configuration utilities on the host filesystem --'um_eth_tool' on the UM filesystem ** - -To use: - -UML to Host connection - technique 1 ------------------------------------- -eth0 is eth UM virtual interface -tap0 is the TAP device on the host -br0 is the bridge interface on the host - -uml-1> um_eth_tool -i eth0 -a tap0 -uml-1> ifconfig eth0 10.0.0.1 netmask 255.255.255.0 -host> brctl addbr br0 -host> brctl addif br0 tap0 -host> ifconfig tap0 up -host> ifconfig br0 10.0.0.254 netmask 255.255.255.0 - -.... wait for the bridging code to go into the forwarding state .... - -host> ping 10.0.0.1 -uml-1> ping 10.0.0.254 - -UML to Host connection - technique 2 ------------------------------------- -eth0 is eth UM virtual interface -tap0 is the TAP device on the host - -uml-1> um_eth_tool -i eth0 -a tap0 -uml-1> ifconfig eth0 10.0.0.1 netmask 255.255.255.0 -host> ifconfig tap0 10.0.0.254 netmask 255.255.255.0 - -.... wait for the bridging code to go into the forwarding state .... - -host> ping 10.0.0.1 -uml-1> ping 10.0.0.254 - -UML to UML connection ---------------------- -uml-1> um_eth_tool -i eth1 -a tap1 -uml-1> ifconfig eth1 10.0.1.1 netmask 255.255.255.0 -uml-2> um_eth_tool -i eth2 -a tap2 -uml-2> ifconfig eth2 10.0.1.2 netmask 255.255.255.0 -host> brctl addbr br1 -host> ifconfig br1 up -host> ifconfig tap1 up -host> ifconfig tap2 up -host> brctl addif br1 tap1 -host> brctl addif br1 tap2 - -.... wait for the bridging code to go into the forwarding state .... - -uml-1> ping 10.0.1.2 -uml-2> ping 10.0.1.1 - -UML to physical ethernet ------------------------- - -In theory this should work, but I couldn't figure it out -If anyone gets it to work, please share ... - -You can contact me at jleu@mindspring.com for help diff --git a/src/uml-tools/net/ethertap_helper.c b/src/uml-tools/net/ethertap_helper.c deleted file mode 100644 index 3e8641e..0000000 --- a/src/uml-tools/net/ethertap_helper.c +++ /dev/null @@ -1,112 +0,0 @@ -#include -#include -#include -#include -#include - -void fail(int fd) -{ - char c = 0; - - if(write(fd, &c, sizeof(c)) != sizeof(c)) - perror("Writing failure byte"); - exit(1); -} - -int do_exec(char **args, int need_zero) -{ - int pid, status; - - if((pid = fork()) == 0){ - execvp(args[0], args); - exit(1); - } - else if(pid < 0){ - perror("fork failed"); - return(-1); - } - if(waitpid(pid, &status, 0) < 0){ - perror("execvp"); - return(-1); - } - if(need_zero && (!WIFEXITED(status) || (WEXITSTATUS(status) != 0))){ - printf("'%s' didn't exit with status 0\n", args[0]); - return(-1); - } - return(0); -} - -#define BUF_SIZE 1500 - -main(int argc, char **argv) -{ - char *dev = argv[1]; - int fd = atoi(argv[2]); - char *gate_addr = argv[3]; - char *remote_addr = argv[4]; - int pid, status; - char *ifconfig_argv[] = { "ifconfig", dev, "arp", gate_addr, "up", - "mtu", "1484", NULL }; - char *route_argv[] = { "route", "add", "-host", remote_addr, "gw", - gate_addr, NULL }; - char *arp_argv[] = { "arp", "-Ds", remote_addr, "eth0", "pub", NULL }; - char *forw_argv[] = { "bash", "-c", - "echo 1 > /proc/sys/net/ipv4/ip_forward", NULL }; - char dev_file[sizeof("/dev/tapxxxx\0")], c; - int tap, *fdptr; - - setreuid(0, 0); - - sprintf(dev_file, "/dev/%s", dev); - if((tap = open(dev_file, O_RDWR | O_NONBLOCK)) < 0){ - perror("open"); - fail(fd); - } - - if(do_exec(ifconfig_argv, 1)) fail(fd); - if(do_exec(route_argv, 0)) fail(fd); - do_exec(arp_argv, 0); - do_exec(forw_argv, 0); - - /* On UML : route add -net 192.168.0.0 gw 192.168.0.4 netmask 255.255.255.0 - */ - - c = 1; - if(write(fd, &c, sizeof(c)) != sizeof(c)){ - perror("write"); - fail(fd); - } - - while(1){ - fd_set fds, except; - char buf[BUF_SIZE]; - int from, to, n, max; - - FD_ZERO(&fds); - FD_SET(tap, &fds); - FD_SET(fd, &fds); - except = fds; - max = ((tap > fd) ? tap : fd) + 1; - if(select(max, &fds, NULL, &except, NULL) < 0){ - perror("select"); - continue; - } - if(FD_ISSET(tap, &fds)){ - from = tap; - to = fd; - } - else if(FD_ISSET(fd, &fds)){ - from = fd; - to = tap; - } - else continue; - n = read(from, buf, sizeof(buf)); - if(n == 0){ - exit(0); - } - else if(n < 0) perror("read"); - n = write(to, buf, n); - if(n < 0) perror("write"); - } - return(0); -} diff --git a/src/uml-tools/net/input.c b/src/uml-tools/net/input.c deleted file mode 100644 index 96a0a10..0000000 --- a/src/uml-tools/net/input.c +++ /dev/null @@ -1,131 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "um_eth.h" - -static unsigned int header[2]; -static int header_size = sizeof(header); - -static unsigned char _buffer[10240]; -static unsigned char *buffer = _buffer + 2; -static int buffer_size = sizeof(_buffer) - 2; - -static struct msghdr msg; -static struct iovec io[2]; - -int packet_input(struct connection_data *conn_in) { - struct sockaddr addr; - int in = conn_in->fd; - int new_fd; - int len; - int result = -1; - int unread; - - io[0].iov_base = header; - io[0].iov_len = header_size; - - io[1].iov_base = buffer; - io[1].iov_len = buffer_size; - - msg.msg_name = NULL; - msg.msg_namelen = 0; - msg.msg_iov = io; - msg.msg_iovlen = 2; - msg.msg_control = NULL; - msg.msg_controllen = 0; - - switch(conn_in->stype) { - case SOCKET_LISTEN: - { - if(debug > 3) fprintf(stderr,"connect\n"); - new_fd = accept(in,(struct sockaddr*)&addr,&len); - fcntl(new_fd, F_SETFL, O_ASYNC | O_NONBLOCK); - if((uml_connection[new_fd] = NEW_CONNECTION) == NULL) { - perror("malloc of uml_connection data"); - return -1; - } - FILL_CONNECTION(new_fd); - return 0; - } - case SOCKET_CONNECTION: - { - msg.msg_iovlen = 1; - result = recvmsg(in,&msg,MSG_PEEK); - msg.msg_iovlen = 2; - - if(result >= header_size) { - - if(ioctl(in,FIONREAD,&unread)) { - CLOSE_CONNECTION(in); - return -1; - } - if(unread < (ntohl(header[1]) + header_size)) { - return 0; - } - io[1].iov_len = ntohl(header[1]); - - result = recvmsg(in,&msg,MSG_WAITALL); - if(result != (io[0].iov_len + io[1].iov_len)) { - fprintf(stderr,"Short read\n"); - } - - if(result > 0) { - conn_in->too_little = 0; - } - - } else { - - if(++conn_in->too_little > 1000) { - CLOSE_CONNECTION(in); - return -1; - } - - } - break; - } - default: - break; - } /* switch(conn_in->stype) */ - - if(result <=0) { - if((!result) || (errno != EAGAIN && errno != EINTR)) { - CLOSE_CONNECTION(in); - return -1; - } - return 0; - } - - switch(ntohl(header[0])) { - case PACKET_MGMT: - { - memcpy(&result,io[1].iov_base,sizeof(result)); - conn_in->net_num = ntohl(result); - if(debug) fprintf(stderr,"mgmt: %d is now on %d\n",in,conn_in->net_num); - break; - } - case PACKET_DATA: - { - if(debug > 3) { - fprintf(stderr,"%02d %02d <- ",in,conn_in->net_num); - dump_packet(io[1].iov_base,ntohl(header[1]),1); - } - packet_output(in,&msg); - break; - } - default: - { - fprintf(stderr,"unknow packet type (%d)\n",ntohl(header[0])); - return -1; - } - } /* switch(ntohl(header[0])) */ - return 1; -} diff --git a/src/uml-tools/net/output.c b/src/uml-tools/net/output.c deleted file mode 100644 index 122832b..0000000 --- a/src/uml-tools/net/output.c +++ /dev/null @@ -1,84 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "um_eth.h" - -int packet_output(int in,struct msghdr *msg) { - struct connection_data *conn_in,*conn_out; - int result = 0; - int count = 0; - int out; - - conn_in = uml_connection[in]; - - if(debug > 1) { - fprintf(stderr,"%02d %02d ->",in,conn_in->net_num); - dump_packet(msg->msg_iov[1].iov_base,msg->msg_iov[1].iov_len,0); - fprintf(stderr," ->"); - } - - for(out=0;out<=high_fd;out++) { - conn_out = uml_connection[out]; - if(conn_out == NULL) continue; - if(conn_out->stype == SOCKET_LISTEN) continue; - - if((out != in) && (conn_out->net_num == conn_in->net_num)) { - - if(debug > 1) { - fprintf(stderr," %02d",out); - } - - switch(conn_out->stype) { - case SOCKET_CONNECTION: - { - int unsent = 0; - int size = 0; - int dumb = sizeof(size); - - if(ioctl(out,TIOCOUTQ,&unsent) || - getsockopt(out,SOL_SOCKET,SO_SNDBUF,&size,&dumb)) { - CLOSE_CONNECTION(out); - continue; - } - - if((size - unsent) < - (msg->msg_iov[0].iov_len+msg->msg_iov[1].iov_len)) { - fprintf(stderr,"%d full! packet dropped\n",out); - continue; - } - -send_again: - result = sendmsg(out,msg,0); - if(result < 0) { - if(errno == EINTR || errno == EAGAIN) { - CLOSE_CONNECTION(out); - goto send_again; - } - } else if(result != (msg->msg_iov[0].iov_len + - msg->msg_iov[1].iov_len)) { - if(!result) { - fprintf(stderr,"sendmsg zero\n"); - goto send_again; - } else { - fprintf(stderr,"sendmsg short write\n"); - } - } - break; - } - case SOCKET_LISTEN: - default: - continue; - } - count++; - } - } - if(debug > 1) fprintf(stderr,"\n"); - return count; -} diff --git a/src/uml-tools/net/um_eth.h b/src/uml-tools/net/um_eth.h deleted file mode 100644 index ba71a9b..0000000 --- a/src/uml-tools/net/um_eth.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef _UM_ETH_NET_H -#define _UM_ETH_NET_H - -#define UM_ETH_NET_MAX_PACKET 1544 -#define UM_ETH_NET_HDR_SIZE (sizeof(unsigned int)*2) - -#define UM_ETH_NET_PORT 5299 -#define UM_ETH_NET_DEFAULT_NUM 100 - -enum packet_type { - PACKET_DATA = 1, - PACKET_MGMT -}; - -enum socket_type { - SOCKET_LISTEN = 1, - SOCKET_CONNECTION, - SOCKET_PHY, - SOCKET_TAP -}; - -struct connection_data { - enum socket_type stype; - int net_num; - int too_little; - int fd; -}; - -extern int packet_output(int, struct msghdr*); -extern int packet_input(struct connection_data*); -extern int socket_phy_setup(char *); -extern int socket_tap_setup(char *); -extern void dump_packet(unsigned char *buffer,int size,int term); - -extern struct connection_data *uml_connection[]; -extern int high_fd; -extern int debug; -extern fd_set perm; - -#define NEW_CONNECTION \ - (struct connection_data*)malloc(sizeof(struct connection_data)) - -#define CLOSE_CONNECTION(y) \ - FD_CLR(y,&perm); \ - fprintf(stderr,"socket close\n");\ - close(y); \ - free(uml_connection[y]);\ - uml_connection[y] = NULL; - -#define FILL_CONNECTION(y) \ - uml_connection[y]->stype = SOCKET_CONNECTION; \ - uml_connection[y]->net_num = UM_ETH_NET_DEFAULT_NUM; \ - uml_connection[y]->fd = y; \ - if(y > high_fd) high_fd = y; \ - FD_SET(y,&perm); - -#endif diff --git a/src/uml-tools/net/um_eth_serv.c b/src/uml-tools/net/um_eth_serv.c deleted file mode 100644 index fc4e1ef..0000000 --- a/src/uml-tools/net/um_eth_serv.c +++ /dev/null @@ -1,135 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "um_eth.h" - -struct connection_data* uml_connection[1024]; -int debug = 0; -int high_fd = 0; -fd_set perm; -const char* const unix_socket = "/tmp/um_eth"; - -static void sig_int(int dummy) { - unlink(unix_socket); - exit(0); -} - -void dump_packet(unsigned char *buffer,int size,int term) { - int i; - if(size > 16) size = 16; - - if(term) fprintf(stderr,"packet:"); - for(i=0;isin_family = AF_INET; - sin->sin_port = htons(UM_ETH_NET_PORT); - sin->sin_addr.s_addr = htonl(INADDR_ANY); - - if((new_fd = socket(PF_INET,SOCK_STREAM,0))<= 0) { - perror("socket"); - exit(errno); - } - if(setsockopt(new_fd,SOL_SOCKET,SO_REUSEADDR,(char*)&one,sizeof(one))<0) { - perror("setsockopt"); - exit(errno); - } - if(bind(new_fd,(struct sockaddr*)sin,sizeof(struct sockaddr_in))<0) { - perror("bind"); - exit(errno); - } - if(listen(new_fd,15)<0) { - perror("listen"); - exit(errno); - } - - if((uml_connection[new_fd] = NEW_CONNECTION) == NULL) { - perror("malloc of listen data"); - exit(errno); - } - FILL_CONNECTION(new_fd); - uml_connection[new_fd]->stype = SOCKET_LISTEN; - - sun = (struct sockaddr_un*)&addr; - sun->sun_family = AF_UNIX; - sprintf(sun->sun_path,unix_socket); - - if((new_fd = socket(PF_UNIX,SOCK_STREAM,0))<= 0) { - perror("socket"); - exit(errno); - } - if(setsockopt(new_fd,SOL_SOCKET,SO_REUSEADDR,(char*)&one,sizeof(one))<0) { - perror("setsockopt"); - exit(errno); - } - if(bind(new_fd,(struct sockaddr*)sun,sizeof(struct sockaddr_un))<0) { - perror("bind"); - exit(errno); - } - if(listen(new_fd,15)<0) { - perror("listen"); - exit(errno); - } - - if((uml_connection[new_fd] = NEW_CONNECTION) == NULL) { - perror("malloc of listen data"); - exit(errno); - } - FILL_CONNECTION(new_fd); - uml_connection[new_fd]->stype = SOCKET_LISTEN; - - while(1) { - memcpy(&temp,&perm,sizeof(fd_set)); - if(select(high_fd+1,&temp,NULL,NULL,NULL)>0) { - for(in=0;in<=high_fd;in++) { - if((conn_in = uml_connection[in]) == NULL) continue; - if(!FD_ISSET(in,&temp)) continue; - while(packet_input(conn_in) > 0); - } - } - } - return 0; -} diff --git a/src/uml-tools/net/um_eth_tool.c b/src/uml-tools/net/um_eth_tool.c deleted file mode 100644 index 7ee62fb..0000000 --- a/src/uml-tools/net/um_eth_tool.c +++ /dev/null @@ -1,123 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -void usage(char *name) { - fprintf(stderr,"\n%s -i ifname [-n netnum] [-a address] [-s script]\n\n",name); - fprintf(stderr,"\taddress:\n"); - fprintf(stderr,"\t\tINET \n"); - fprintf(stderr,"\t\tUNIX \n"); - fprintf(stderr,"\t\tTUNTAP \n"); - fprintf(stderr,"\n\tnetnum:\n"); - fprintf(stderr,"\t\tonly has effect with INET and UNIX sockets\n"); - fprintf(stderr,"\n\tscript:\n"); - fprintf(stderr,"\t\tscript exec'ed by host after interface is connected\n"); -} - -int main(int argc,char **argv) { - struct ifreq ifr; - char *temp; - char *ifname = NULL; - int fd; - int opt; - - memset(&ifr,0,sizeof(struct ifreq)); - - if((fd = socket(PF_INET,SOCK_STREAM,0))<= 0) { - perror("socket"); - exit(errno); - } - - if(argc <= 1) usage(argv[0]); - - while((opt = getopt(argc,argv,"i:a:n:s:h")) != EOF) { - switch(opt) { - case 'i': - ifname = optarg; - strcpy(ifr.ifr_name,optarg); - break; - case 'a': - if(!ifname) { - usage(argv[0]); - exit(-1); - } - if((temp = index(optarg,':'))) { - struct sockaddr_in *sin = (struct sockaddr_in*)&ifr.ifr_dstaddr; - char *ip_str = optarg; - char *port_str = temp + 1; - *temp = '\0'; - - sin->sin_family = AF_INET; - sin->sin_port = htons(atoi(port_str)); - sin->sin_addr.s_addr = inet_addr(ip_str); - - printf("%s will connect to AF_INET server at %s:%s\n",ifname,ip_str, - port_str); - } else if(argv[3][0] == '/') { - struct sockaddr_un *sun = (struct sockaddr_un*)&ifr.ifr_dstaddr; - - sun->sun_family = AF_UNIX; - strcpy(sun->sun_path,argv[3]); - printf("%s will connect to AF_UNIX server at %s\n",ifname,optarg); - } else { - struct sockaddr_un *sun = (struct sockaddr_un*)&ifr.ifr_dstaddr; - - sun->sun_family = 0; - strcpy(sun->sun_path,optarg); - printf("%s will connect to TUNTAP interface %s\n",ifname,optarg); - } - if(ioctl(fd,SIOCDEVPRIVATE+1,&ifr)<0) { - perror("ioctl"); - exit(errno); - } - break; - case 's': - { - struct sockaddr_un *sun = (struct sockaddr_un*)&ifr.ifr_dstaddr; - - if(!ifname) { - usage(argv[0]); - exit(-1); - } - - sun->sun_family = AF_UNIX; - strcpy(sun->sun_path,optarg); - printf("host will execute %s when %s is connected\n",optarg,ifname); - - if(ioctl(fd,SIOCDEVPRIVATE+2,&ifr)<0) { - perror("ioctl"); - exit(errno); - } - break; - } - case 'n': - if(!ifname) { - usage(argv[0]); - exit(-1); - } - ifr.ifr_flags = atoi(optarg); - if(ioctl(fd,SIOCDEVPRIVATE,&ifr)<0) { - perror("Net number"); - exit(errno); - } - break; - case 'h': - default: - usage(argv[0]); - exit(-1); - } - } - - - - return 0; -} diff --git a/src/uml-tools/rpm/Makefile b/src/uml-tools/rpm/Makefile deleted file mode 100644 index 9eb7f9e..0000000 --- a/src/uml-tools/rpm/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -RPMCMD = rpm -bb uml.spec - -UML_BUILD_DIR = /tmp/uml_kit - -all : uml.spec ztarball - UML_BUILD_DIR=$(UML_BUILD_DIR) $(RPMCMD) - -ztarball : - cp $(ZTARBALL) . - -uml.spec: uml.spec.in - export UML_VERSION=$(UML_VERSION) ; \ - export CHANGELOG=$(CHANGELOG) ; \ - export ME="$(ME)" ; \ - awk "/%changelog/ \ - { print; \ - printf \"* %s $(ME)\n\", \"`date +'%a %b %e %Y'`\"; \ - system(\"sed 's/^/- /' $(CHANGELOG)\"); \ - print \"\"; \ - next } \ - { print }" < uml.spec.in > uml.spec.tmp ; \ - mv uml.spec.tmp uml.spec.in ; \ - echo "%define version $(UML_VERSION)" > uml.spec ; \ - echo "BuildRoot: $(UML_BUILD_DIR)" >> uml.spec ; \ - cat uml.spec.in >> uml.spec - -clean: - rm -f uml.spec diff --git a/src/uml-tools/rpm/uml.spec.in b/src/uml-tools/rpm/uml.spec.in deleted file mode 100644 index e61d4ff..0000000 --- a/src/uml-tools/rpm/uml.spec.in +++ /dev/null @@ -1,600 +0,0 @@ -Name: user_mode_linux -Summary: The user-mode port of the Linux kernel -Version: %{version} -Release: 0 -Copyright: GPL -Packager: Jeff Dike -Group: Utilities/System -Source: http://download.sourceforge.net/user-mode-linux/uml-patch-%{version} -Vendor: Jeff Dike -URL: http://user-mode-linux.sourceforge.net/ - -%description -This is the user-mode port of the Linux kernel - it runs a virtual -machine in a set of Linux processes. This package also contains a -number of other useful tools and utilities related to UML. - -%changelog -* Sat Dec 29 2001 Jeff Dike -- Kernel changes: -- Updated UML to 2.4.17 -- -- Added a port channel, which allows UML consoles and serial lines to be -- attached to a host port, where they can be accessed with telnet. -- -- Redid the context switching mechanism so that it's far simpler and -- probably much faster. -- -- Fixed a couple of SIGIO setup buglets. -- -- UML can now be shut down by sending a SIGINT or SIGTERM to the tracing -- thread. -- -- Terminal mode handling is now cleaner. main no longer saves and restores -- the modes of stdin/stdout/stderr. -- -- The async IO signal is now explicitly set to SIGIO. -- -- General purpose registers are now stored properly in core files. -- -- The drivers again are compiled in or not depending on whether they were -- configured in. -- -- Cleaned up the network portion of the config. -- -- Userspace changes: -- Added port-helper, which is a helper needed for the new port channel. -- -- Fixed another potential exploit. -- -- Fixed an exploitable buffer overflow in uml_net and tightened up buffer -- use in general. -- - -* Sun Dec 9 2001 Jeff Dike -- Kernel changes: -- Reorganized the host channel support code. -- -- The mconsole protocol is now structured, rather than being plain text. You -- will need the new mconsole client in order to do mconsole things with this -- kernel. -- -- Fixed a data corruption bug in the last patch. -- -- Improved the error message that gets printed when there are no -- multcast-capable interfaces on the host. -- -- Fixed a bug in kill_child_dead. -- -- It is now possible to write to a COW-ed device that contains a non-root -- filesystem. -- -- The errors that get spit out from uml_net when you remove a net device are -- gone. -- -- Compilation warnings were fixed, and various bit of code were cleaned up. -- -- The network backends now pass the netmask to uml_net so it can do proxy -- arp properly. You will need the latest utilities in order to run this. -- -- There is support for RT signals in the form of a siginfo struct on the -- stack if necessary. There is no ucontext on the stack as yet. -- -- Fixed a bug which could cause a hang with a process receiving infinite -- segfaults. -- -- wait_for_stop now passes SIGINT to the process so ^C at the wrong time -- won't panic the tracing thread. -- -- Fixed a bug in sigsuspend and rt_sigsuspend which caused them to return -- incorrect values. -- -- Fixed the tuntap packet dropping problem, fixed the same bug in all the -- other transports, and merged all the read routines. -- -- Added some latent support for uml_net being able to do proxy arp -- intelligently. -- -- Userspace changes: -- Updated uml_mconsole to use the new protocol. -- -- Proxy arp is now smart enough to only add arp entries to interfaces which -- are on the local network. -- -- Slip now supports changing IP addresses. -- - -* Sun Nov 25 2001 Jeff Dike -- Kernel changes: -- Reorganized the host channel support code. -- -- The mconsole protocol is now structured, rather than being plain text. You -- will need the new mconsole client in order to do mconsole things with this -- kernel. -- -- Fixed a data corruption bug in the last patch. -- -- Improved the error message that gets printed when there are no -- multcast-capable interfaces on the host. -- -- Fixed a bug in kill_child_dead. -- -- It is now possible to write to a COW-ed device that contains a non-root -- filesystem. -- -- The errors that get spit out from uml_net when you remove a net device are -- gone. -- -- Compilation warnings were fixed, and various bit of code were cleaned up. -- -- The network backends now pass the netmask to uml_net so it can do proxy -- arp properly. You will need the latest utilities in order to run this. -- -- There is support for RT signals in the form of a siginfo struct on the -- stack if necessary. There is no ucontext on the stack as yet. -- -- Fixed a bug which could cause a hang with a process receiving infinite -- segfaults. -- -- wait_for_stop now passes SIGINT to the process so ^C at the wrong time -- won't panic the tracing thread. -- -- Fixed a bug in sigsuspend and rt_sigsuspend which caused them to return -- incorrect values. -- -- Fixed the tuntap packet dropping problem, fixed the same bug in all the -- other transports, and merged all the read routines. -- -- Added some latent support for uml_net being able to do proxy arp -- intelligently. -- -- Userspace changes: -- Updated uml_mconsole to use the new protocol. -- -- Proxy arp is now smart enough to only add arp entries to interfaces which -- are on the local network. -- -- Slip now supports changing IP addresses. -- - -* Tue Nov 13 2001 Jeff Dike -- Kernel changes: -- Updated to 2.4.14. -- -- Redid the task switching code. The tracing thread is no longer involved. -- Rather, the two threads arrange it themselves with one sending a SIGTERM -- to the other, and protecting itself from races by blocking SIGTERM and -- re-enabling it with sigsuspend. -- -- Fixed a bug in the new poll code which could cause pollfd structs to be lost. -- -- UML now works on 3G/1G hosts when CONFIG_HOST_2G_2G is on. -- -- sigio_handler now uses poll instead of select. -- -- Every thread now has a private page of data which contains errno. -- -- Cleaned up some code and Makefiles. -- -- Sped up context switching some more by removing the code that unmapped -- pages that weren't present to begin with. -- -- Cleaned up some code. -- -- Fixed the process segfaults caused by Xnest and kernel builds. The same -- fix also makes gdb work better. -- -- Fixed a typo in arch/um/kernel/Makefile which caused modules not to load -- into a profiled kernel. -- -- Jorgen Cederlof's context switch optimization is now turned on. -- -- Userspace changes: -- Restructured the uml_net sources to make them more modular. -- -- uml_net should now do proxy arp correctly. -- -- uml_mconsole can now take a command on its command line. -- - -* Fri Oct 26 2001 Jeff Dike -- Kernel changes: -- defconfig now turns on CONFIG_PACKET. -- -- Profiled modules can now be loaded without undefined symbols. -- -- Fixed a segfault on startup caused by an early unexpected malloc in a -- profiling UML. -- -- Added sys_readahead support. -- -- The network backends are now able to cleanly print the commands that -- uml_net runs and their output. -- -- Physical memory protection is now optional and is controlled by the 'jail' -- switch. -- -- Fixed the TMP/TMPDIR/TEMPDIR support. -- -- Fixed a bug with uml_dir not having a trailing '/'. -- -- Fixed the initrd botch in -2 and also appear to have made the linker error -- go away. -- -- Argument parsing and some initialization is now done in the same way as -- the generic kernel, with structures being put into special sections of the -- binary, and initialization code iterates over that section doing whatever -- is necessary. -- -- The initrd code is now split out from everything else, removing a pile of -- ifdefs. -- -- ppc cleanups from Chris -- -- Various other small cleanups -- -- Userspace changes: -- Set the uml_net VERSION to 3. -- -- uml_net can now feed command lines and output back to UML. -- -- uml_net now doesn't segfault if someone runs it by hand with no arguments. -- -- uml_net sets up proxy arp by changing -- /proc/sys/net/ipv4/conf/DEV/proxy_arp rather than by running arp. -- - -* Fri Oct 26 2001 Jeff Dike -- Kernel changes: -- defconfig now turns on CONFIG_PACKET. -- -- Profiled modules can now be loaded without undefined symbols. -- -- Fixed a segfault on startup caused by an early unexpected malloc in a -- profiling UML. -- -- Added sys_readahead support. -- -- The network backends are now able to cleanly print the commands that -- uml_net runs and their output. -- -- Physical memory protection is now optional and is controlled by the 'jail' -- switch. -- -- Fixed the TMP/TMPDIR/TEMPDIR support. -- -- Fixed a bug with uml_dir not having a trailing '/'. -- -- Fixed the initrd botch in -2 and also appear to have made the linker error -- go away. -- -- Argument parsing and some initialization is now done in the same way as -- the generic kernel, with structures being put into special sections of the -- binary, and initialization code iterates over that section doing whatever -- is necessary. -- -- The initrd code is now split out from everything else, removing a pile of -- ifdefs. -- -- ppc cleanups from Chris -- -- Various other small cleanups -- -- Userspace changes: -- Set the uml_net VERSION to 3. -- -- uml_net can now feed command lines and output back to UML. -- -- uml_net now doesn't segfault if someone runs it by hand with no arguments. -- -- uml_net sets up proxy arp by changing -- /proc/sys/net/ipv4/conf/DEV/proxy_arp rather than by running arp. -- - -* Thu Oct 11 2001 Jeff Dike -- Kernel changes: -- Updated to 2.4.12 -- -- Userspace changes: - -* Wed Oct 10 2001 Jeff Dike -- Kernel changes: -- Fixed a couple of MAP_SHARED that I missed last time. -- -- Updated config.release -- -- Redid the signal delivery code so that the code running on the process stack doesn't need to modify the task structure. This allowed the task structure to be write-protected while in userspace, so that all of physical memory is protected now. -- -- applied some patches from Andrea Archangeli -- -- fixed the protect panic -- -- wrapped '#ifdef __CONFIG_SMP' around smp.h to give ppc a better chance of building -- -- mrproper now removes the header symlinks -- -- Fixed a signal delivery bug which caused interrupted system calls to return the wrong value. -- -- Fixed a crash caused by typing at a console -- -- More ppc updates -- -- CONFIG_DEBUG_SLAB is now configurable -- -- Compilation warnings eliminated and some minor cleanups made -- -- Updated to 2.4.11 -- -- Converted OX_OBJS to export_objs -- -- Userspace changes: -- Added top-level all, clean, and install rules. -- -- Added a copy of the GPL -- -- Changed uml_router to uml_switch -- -- uml_switch now has a -hub switch -- -- Converted the uml_switch main loop from select to poll -- - -* Tue Sep 25 2001 Jeff Dike -- Kernel changes: -- There is now a TUN/TAP backend for the network driver. -- -- UML no longer hangs when it can't find xterm. -- -- It complains more informatively when the host is out of ptys. -- -- The TUN/TAP backend now works properly. You'll need to grab the latest -- uml_net from CVS /tools/uml_net even if you grabbed the one for 2.4.9-2um. -- -- Fixed the process segfaults that happened when the system was swapping. -- -- Merged the latest ppc changes. -- -- malloc, free, and calloc are now wrapped and redirected to kmalloc/kfree -- if they're running, and the normal libc functions if not. This fixes -- gprof and gcov crashes when they tried to allocate memory when opening -- their output files. It also closes a possible security hole. -- -- The block driver now reports IO errors back to the block layer. -- -- COW headers now contain absolute pathnames to their backing files. -- -- Fixed some smp.h compilation problems. -- -- Fixed a couple of profiling timer problems. -- -- UML now loads itself and its memory into the top of the address -- space. This cleans up a lot of code, and also probably fixes the mlockall -- bug. -- -- The COW header is at version 2, which supports filename lengths up to -- MAXPATHLEN and is in network byte order. -- -- A gprof buglet was also fixed. -- -- Process stacks are now normally below kernelspace rather than above it. -- -- UML is now more intelligent about allocating its virtual memory area, so -- it's possible to run with more physical memory. I got up to 464M, at -- which point I was down to 8M of kernel virtual memory. -- -- The former CONFIG_2G_2G is now CONFIG_HOST_2G_2G. -- -- Cleaned up the signal delivery code and the network device config -- -- Updated the mmapper driver -- -- ubd COW bitmaps are now vmalloced -- -- Removed some 64-bit uncleanliness from the ubd driver -- -- Fixed and cleaned up the tlb flush code -- -- Updated to 2.4.10 -- -- Fixed the sigaltstack problem that prevented UML from booting on 2.2 hosts. -- -- Userspace changes: -- Added 'quit' and 'switch' to the mconsole. -- -- Also added some local help. -- -- uml_net now is as helpful with TUN/TAP as with ethertap, creating -- directories and device nodes and insmod-ing modules if necessary. -- -- uml_net also now insmods netlink-dev for ethertap. - -* Tue Sep 25 2001 Jeff Dike -- Kernel changes: -- There is now a TUN/TAP backend for the network driver. -- -- UML no longer hangs when it can't find xterm. -- -- It complains more informatively when the host is out of ptys. -- -- The TUN/TAP backend now works properly. You'll need to grab the latest -- uml_net from CVS /tools/uml_net even if you grabbed the one for 2.4.9-2um. -- -- Fixed the process segfaults that happened when the system was swapping. -- -- Merged the latest ppc changes. -- -- malloc, free, and calloc are now wrapped and redirected to kmalloc/kfree -- if they're running, and the normal libc functions if not. This fixes -- gprof and gcov crashes when they tried to allocate memory when opening -- their output files. It also closes a possible security hole. -- -- The block driver now reports IO errors back to the block layer. -- -- COW headers now contain absolute pathnames to their backing files. -- -- Fixed some smp.h compilation problems. -- -- Fixed a couple of profiling timer problems. -- -- UML now loads itself and its memory into the top of the address -- space. This cleans up a lot of code, and also probably fixes the mlockall -- bug. -- -- The COW header is at version 2, which supports filename lengths up to -- MAXPATHLEN and is in network byte order. -- -- A gprof buglet was also fixed. -- -- Process stacks are now normally below kernelspace rather than above it. -- -- UML is now more intelligent about allocating its virtual memory area, so -- it's possible to run with more physical memory. I got up to 464M, at -- which point I was down to 8M of kernel virtual memory. -- -- The former CONFIG_2G_2G is now CONFIG_HOST_2G_2G. -- -- Cleaned up the signal delivery code and the network device config -- -- Updated the mmapper driver -- -- ubd COW bitmaps are now vmalloced -- -- Removed some 64-bit uncleanliness from the ubd driver -- -- Fixed and cleaned up the tlb flush code -- -- Updated to 2.4.10 -- -- Fixed the sigaltstack problem that prevented UML from booting on 2.2 hosts. -- -- Userspace changes: -- Added 'quit' and 'switch' to the mconsole. -- -- Also added some local help. -- -- uml_net now is as helpful with TUN/TAP as with ethertap, creating -- directories and device nodes and insmod-ing modules if necessary. -- -- uml_net also now insmods netlink-dev for ethertap. - -* Thu Aug 16 2001 Jeff Dike -- Kernel - -- Updated to 2.4.9 -- Some signal handling fixes -- Started protecting kernel memory from malicious processes -- Userspace - -- None - -* Sun Aug 12 2001 Jeff Dike -- Kernel - -- Updated to 2.4.8 -- Fixed the TASK_UNINTERRUPTIBLE deadlock again -- hostfs writes go through the page cache -- Finished merging the ppc port -- Fixed a crash if an interface tries to get an ether address without -- having an IP address -- Fixed an old bug which only showed up now which caused 2.4.7 not to boot -- Fixed hostfs ls on 2.4 hosts -- Fixed gprof support -- Added text to Configure.help -- The pid file now always contains the right pid -- hostfs again should compile and run on 2.2 -- ethertap eth devices can have their addresses changed on the fly -- Userspace - -- uml_net now changes the host configuration to follow IP address changes -- inside UML - -* Wed Jul 4 2001 Jeff Dike -- Merged the management console -- Many bug fixes -- 64 bit IO works again - -* Wed Mar 7 2001 Jeff Dike -- Redid the network drivers - -* Wed Mar 7 2001 Jeff Dike -- initial version - - -%prep - -rm -rf uml -mkdir uml -cd uml -cp $ZTARBALL . -compressed=`echo user_mode_linux*` -gunzip $compressed -archive=`echo $compressed | sed 's/.gz$//'` -tar xf $archive . - -%build - -cd uml -make all - -%install - -rm -rf $UML_BUILD_DIR -mkdir $UML_BUILD_DIR -cd uml -make install DESTDIR=$UML_BUILD_DIR - -%clean -rm -rf uml - -%files -%defattr(-,root,root) -%attr(755,root,root) /usr/bin/linux -%attr(644,root,root) /usr/lib/uml/modules-2.2.tar -%attr(644,root,root) /usr/lib/uml/modules-2.4.tar -%attr(755,root,root) /usr/bin/mkrootfs -%attr(755,root,root) /usr/lib/uml/functions -%attr(644,root,root) /usr/lib/uml/config -%attr(644,root,root) /usr/lib/uml/port-helper -%attr(4755,root,root) /usr/bin/uml_net -%attr(755,root,root) /usr/bin/uml_switch -%attr(755,root,root) /usr/bin/uml_moo -%attr(755,root,root) /usr/bin/uml_mconsole -#%attr(644,root,root) /usr/doc/HOWTO/UserModeLinux-HOWTO diff --git a/src/uml-tools/test/COPYING b/src/uml-tools/test/COPYING deleted file mode 100644 index 60549be..0000000 --- a/src/uml-tools/test/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/src/uml-tools/test/Makefile b/src/uml-tools/test/Makefile deleted file mode 100644 index ad6a457..0000000 --- a/src/uml-tools/test/Makefile +++ /dev/null @@ -1 +0,0 @@ -clean: diff --git a/src/uml-tools/test/README b/src/uml-tools/test/README deleted file mode 100644 index f39c5af..0000000 --- a/src/uml-tools/test/README +++ /dev/null @@ -1,11 +0,0 @@ -This directory contains the UML package, in UML.pm, a test harness in -tsuite.pl, and some tests in t. Read the pod at the end of UML.pm to -see what the UML methods and their arguments are. - -You can run the suite with "perl -I . tsuite.pl". You will need to -change the kernel command line in tsuite.pl, and maybe pass in values -for the login and password prompts, the login account name and -password, and the shell prompt to UML::new(). - -It will boot up a virtual machine and run the tests, logging the -machine output in "test.log" and the test output in t/*.log. diff --git a/src/uml-tools/test/UML.pm b/src/uml-tools/test/UML.pm deleted file mode 100644 index 6a51bdd..0000000 --- a/src/uml-tools/test/UML.pm +++ /dev/null @@ -1,220 +0,0 @@ -# -# Copyright (C) 2001 Jeff Dike (jdike@karaya.com) -# Licensed under the GPL -# - -package UML; - -use Expect; -use IO::File; -use strict; - -sub new { - my $proto = shift; - my $class = ref($proto) || $proto; - my $me = { kernel => 'linux', - arguments => '', - login_prompt => 'login:', - login => 'root', - password_prompt => 'Password:', - password => 'root', - prompt => 'darkstar:.*#', - halt => 'halt', - expect_handle => undef }; - - while(@_){ - my $arg = shift; - if($arg eq 'kernel'){ - $me->{kernel} = shift; - } - elsif($arg eq 'arguments'){ - $me->{arguments} = shift; - } - elsif($arg eq 'login_prompt'){ - $me->{login_prompt} = shift; - } - elsif($arg eq 'login'){ - $me->{login} = shift; - } - elsif($arg eq 'password_prompt'){ - $me->{password_prompt} = shift; - } - elsif($arg eq 'password'){ - $me->{password} = shift; - } - elsif($arg eq 'prompt'){ - $me->{prompt} = shift; - } - elsif($arg eq 'halt'){ - $me->{halt} = shift; - } - else { - die "UML::new : Unknown argument - $arg"; - } - } - bless($me, $class); - return $me; -} - -sub boot { - my $me = shift; - my $log_file = shift; - my $log; - - if(defined($me->{expect_handle})){ - warn "UML::boot : already booted"; - return; - } - my $cmd = "$me->{kernel} $me->{arguments}"; - $me->{expect_handle} = Expect->spawn($cmd); - if(defined($log_file)){ - $log = $me->open_log($log_file); - $me->{expect_handle}->log_stdout(0); - } - $me->{expect_handle}->expect(undef, "$me->{login_prompt}"); - $me->{expect_handle}->print("$me->{login}\n"); - $me->{expect_handle}->expect(undef, "$me->{password_prompt}"); - $me->{expect_handle}->print("$me->{password}\n"); - $me->{expect_handle}->expect(undef, "-re", "$me->{prompt}"); - return($log); -} - -sub command { - my $me = shift; - my $cmd = shift; - my %globals = ( "Kernel panic" => "", "$me->{prompt}" => "-re" ); - my @expects = ( @_ ); - my @strings = (); - - foreach my $key (keys(%globals)){ - $globals{$key} eq "-re" and push @expects, "-re"; - push @expects, $key; - } - foreach my $str (@expects){ - $str ne "-re" and push @strings, $str; - } - $me->{expect_handle}->print("$cmd\n"); - my @match = $me->{expect_handle}->expect(undef, @expects); - defined $match[0] and $match[0]--; - if(defined($match[1])){ - die "Expect error : $match[1]"; - } - elsif(defined($globals{$strings[$match[0]]})){ - $strings[$match[0]] eq "Kernel panic" and die "panic"; - return(undef); - } - else { - $me->{expect_handle}->expect(undef, "-re", "$me->{prompt}"); - return($match[0]); - } -} - -sub open_log { - my $me = shift; - my $file = shift; - my $fh = new IO::File "$file"; - my $have_logs = $me->{expect_handle}->set_group(); - my @logs; - - if(!defined($have_logs)){ - @logs = (); - } - else { - @logs = $me->{expect_handle}->set_group(); - } - if(defined($fh)){ - my $log = Expect->exp_init(\*$fh); - push @logs, $log; - $me->{expect_handle}->set_group(@logs); - return $log; - } - return undef; -} - -sub close_log { - my $me = shift; - my $log = shift; - my @logs = $me->{expect_handle}->set_group(); - - foreach my $i (0..$#logs){ - if($logs[$i] == $log){ - splice @logs, $i, 1; - $log->hard_close(); - } - } - if(!@logs){ - my $fh = new IO::File "> /dev/null"; - push @logs, Expect->exp_init(\*$fh); - } - $me->{expect_handle}->set_group(@logs); -} - -sub halt { - my $me = shift; - - $me->{expect_handle}->print("$me->{halt}\n"); - $me->{expect_handle}->expect(undef); -} - -sub kill { - my $me = shift; - - $me->{expect_handle}->hard_close(); -} - -1; - -=head1 NAME - -UML - class to control User-mode Linux - -=head1 SYNOPSIS - - use UML; - - ################# - # class methods # - ################# - $uml = UML->new(kernel => $path_to_kernel, # default "linux" - arguments => $kernel_arguments, # "" - login_prompt => $login_prompt, # "login:" - login => $account_name, # "root" - password_prompt => $password_prompt, # "Password:" - password => $account_password, # "root" - prompt => $shell_prompt_re, # "darkstar:.*#" - halt => $halt_command); # "halt" - $uml->boot(); - $uml->command($command_string); - $uml->halt(); - - ####################### - # object data methods # - ####################### - - ######################## - # other object methods # - ######################## - -=head1 DESCRIPTION - -The UML class is used to control the execution of a user-mode kernel. -All of the arguments to UML::new are optional and will be defaulted if -not present. The arguments and their values are as follows: - kernel - the filename of the kernel executable - arguments - a string containing the kernel command line - login_prompt - a string matching the login prompt - login - the account to log in to - password_prompt - a string matching the password prompt - password - the account's password - prompt - a regular expression matching the shell prompt - halt - the command used to halt the virtual machine - -Once constructed, the UML object may be booted. UML::boot() will -return after it has successfully logged in. - -Then, UML::command may be called as many times as desired. It will -return when the command has finished and the next shell prompt has -been seen. - -When the testing is finished, UML::halt() is called to shut the -virtual machine down. diff --git a/src/uml-tools/test/tsuite.pl b/src/uml-tools/test/tsuite.pl deleted file mode 100644 index 7021742..0000000 --- a/src/uml-tools/test/tsuite.pl +++ /dev/null @@ -1,74 +0,0 @@ -# -# Copyright (C) 2001 Jeff Dike (jdike@karaya.com) -# Licensed under the GPL -# - -use UML; -use IO::File; - -use strict; - -# The kernel command line - you probably need to change this - -my $args = "ubd0=../../../distros/slackware_7.0/root_fs_slackware_7_0 " . - "ubd3=../../../kernel ubd5=../../../lmbench umn=192.168.0.100 mem=128M " . - "no-xterm"; - -my $uml = UML->new(kernel => '../../../um/linux', arguments => $args); - -print "Logging full session to \"tests.log\"\n"; -print "Booting virtual machine\n"; - -my $global_log = $uml->boot("> tests.log"); - -my @tests = glob("t/*.pl"); - -my $run = 0; -my $failed = 0; -my $not_run = 0; - -foreach my $test (@tests){ - my $pl = `cat $test`; - my $info = eval $pl; - if($@){ - print "Failed to evaluate \"$test\": $@\n"; - next; - } - print "Test : $info->{name} (logging to \"$test.log\") ... "; - my $log = $uml->open_log("$test.log"); - if(!defined($log)){ - warn "Couldn't open log file \"$test.log\" : $!"; - } - $run++; - my $res = eval { $info->{test}->($uml) }; - $uml->close_log($log); - if($@){ - if($@ =~ "^panic"){ - $failed++; - print "Paniced\n"; - $uml->kill(); - $uml = UML->new(kernel => '../../../um/linux', arguments => $args); - print "Booting another virtual machine\n"; - $uml->boot(">> tests.log"); - next; - } - $not_run++; - print "Not run ($@)\n"; - } - elsif($res){ - print "Succeeded\n"; - } - else { - $failed++; - print "Failed\n"; - } -} - -print "Tests finished, halting machine\n"; - -$uml->halt(); - -$uml->close_log($global_log); - -print "Tests done :\n\tTotal - $run\n\tFailed - $failed\n" . - "\tNot run - $not_run\n"; diff --git a/src/uml-tools/uml_router/hash.h b/src/uml-tools/uml_router/hash.h deleted file mode 100644 index 9192912..0000000 --- a/src/uml-tools/uml_router/hash.h +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2002 Yon Uriarte and Jeff Dike - * Licensed under the GPL - */ - -#ifndef __HASH_H__ -#define __HASH_H__ - -extern void *find_in_hash(char *dst); -extern void insert_into_hash(char *src, void *port); -extern void delete_hash(char *dst); -extern void print_hash(char *(*port_id)(void *)); -extern void update_entry_time(char *src); -extern void hash_init(void); - -#endif