[uml-devel] Telnet (IPV6) on port

2005-02-26 Thread Adil Mujeeb, Noida




Hi,
Iam using 2.4.26 linux source and patch it with 
uml-patch-2.4.26-3 patch.
I have built the uml binary with ipv6 support and my 
host has ipv6 module loaded.
The 
telnet client and daemon are IPV6 supported on the Host machine. Iam able to 
telnet on the localhost with ipv6 address. 
For 
example to telnet on localhost with loopback address ( ::1 ) , it works 
fine.
 
Now Im running 
uml on this host (RedHat 9) with command as 
follows:
 
./linux ubd0=guest1.diff,root_fs con=port:9001 
con0=fd:0,fd:1 umid=guest1 mem=32m
 
Now 
when i try to telnet on UML with following command :
telnet 
127.0.0.1 9001, it works fine
 
But if I telnet with :
telnet ::1 9001
it gives message connection 
refused.

 
Can 
anyone throw some light on it why this is 
happening???
 
Thanks and Best Regards,Adil 
Mujeeb


[uml-devel] [PATCH] allow jail_uml to work with a numeric uid

2005-02-26 Thread Matt Zimmerman

-- 
 - mdz
--- Begin Message ---

On Thu, Dec 02 '04 at 09:51, Matt Zimmerman wrote:
> Could you send your changes as a patch against the current package, rather
> than a new package?

Like this?

Cu,
Goetz.
-- 
/"\ Goetz Bock at blacknet dot de  --  secure mobile Linux everNETting
\ /   (c) 2004 Creative Commons, Attribution-ShareAlike 2.0 de
 X   [ 1. Use descriptive subjects - 2. Edit a reply for brevity -  ]
/ \  [ 3. Reply to the list - 4. Read the archive *before* you post ]
diff -pruN uml-utilities-20040406-1/debian/changelog 
uml-utilities-20040406-1bg/debian/changelog
--- uml-utilities-20040406-1/debian/changelog   2004-12-02 19:19:26.0 
+0100
+++ uml-utilities-20040406-1bg/debian/changelog 2004-12-02 19:20:12.0 
+0100
@@ -1,3 +1,9 @@
+uml-utilities (20040406-1bg) unstable; urgency=low
+
+  * Patch from Goetz Bock to allow jail_uml to work with a numeric uid
+  
+ -- Goetz Bock <[EMAIL PROTECTED]>  Thu,  2 Dec 2004 18:16:23 -0100
+
 uml-utilities (20040406-1) unstable; urgency=low
 
   * New upstream release
diff -pruN uml-utilities-20040406-1/jail/Makefile 
uml-utilities-20040406-1bg/jail/Makefile
--- uml-utilities-20040406-1/jail/Makefile  2004-12-02 19:19:26.0 
+0100
+++ uml-utilities-20040406-1bg/jail/Makefile2004-12-02 19:20:12.0 
+0100
@@ -1,11 +1,17 @@
-all : jail_uml
+OBJS = jail_uml.o
+BIN = jail_uml
+CFLAGS = -g -Wall
 
-install:
+SBIN_DIR ?= /usr/sbin
 
-jail_uml : jail_uml.c
+all : $(BIN)
 
-# Don't install anything as yet
-install :
+$(BIN) : $(OBJS)
+   $(CC) $(CFLAGS) -o $(BIN) $(OBJS)
 
+install : $(BIN)
+   install -d $(DESTDIR)$(SBIN_DIR)
+   install -s $(BIN) $(DESTDIR)$(SBIN_DIR)
+   
 clean :
-   rm -rf *~ jail_uml cell[0-9]* core* tty_log_cell*
+   rm -rf *~ $(BIN) $(OBJS) cell[0-9]* core* tty_log_cell*
diff -pruN uml-utilities-20040406-1/jail/jail_uml.c 
uml-utilities-20040406-1bg/jail/jail_uml.c
--- uml-utilities-20040406-1/jail/jail_uml.c2003-01-22 18:46:36.0 
+0100
+++ uml-utilities-20040406-1bg/jail/jail_uml.c  2004-12-02 19:20:12.0 
+0100
@@ -1,18 +1,32 @@
+/* jail a uml into a directory.
+ 
+*/
+
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 static void Usage(void)
 {
-  fprintf(stderr, "Usage : jail_uml jail-directory uid "
+  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;
-  int uid;
+  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");
@@ -21,8 +35,22 @@ int main(int argc, char **argv)
 
   if(argc < 3) Usage();
   dir = argv[1];
-  uid = strtoul(argv[2], &end, 0);
-  if(*end != '\0') Usage();
+  user = argv[2];
+  
+  // get users password information
+  pw = getpwnam (user);
+  if (pw == 0){
+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;
 
@@ -36,6 +64,10 @@ int main(int argc, char **argv)
 exit(1);
   }
 
+  if(setgid(gid)){
+perror("setgid");
+exit(1);
+  }
   if(setuid(uid)){
 perror("setuid");
 exit(1);
--- End Message ---