From owner-freebsd-emulation@FreeBSD.ORG Sat Mar 6 06:13:42 2010 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0EB491065670 for ; Sat, 6 Mar 2010 06:13:42 +0000 (UTC) (envelope-from lists@jnielsen.net) Received: from ns1.jnielsen.net (ns1.jnielsen.net [69.55.238.237]) by mx1.freebsd.org (Postfix) with ESMTP id E8FBF8FC1B for ; Sat, 6 Mar 2010 06:13:41 +0000 (UTC) Received: from jnielsen-2.local (jn@stealth.jnielsen.net [74.218.226.254]) (authenticated bits=0) by ns1.jnielsen.net (8.12.9p2/8.12.9) with ESMTP id o266DXpf023291; Sat, 6 Mar 2010 01:13:33 -0500 (EST) (envelope-from lists@jnielsen.net) From: John Nielsen To: freebsd-emulation@freebsd.org Date: Sat, 6 Mar 2010 01:13:32 -0500 User-Agent: KMail/1.12.4 (Darwin/9.8.0; KDE/4.3.4; i386; ; ) References: <201003021325.27197.lists@jnielsen.net> <20100305092611.0000772c@unknown> <20100305091446.GZ8200@hoeg.nl> In-Reply-To: <20100305091446.GZ8200@hoeg.nl> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201003060113.32628.lists@jnielsen.net> X-Virus-Scanned: ClamAV version 0.88.4, clamav-milter version 0.88.4 on ns1.jnielsen.net X-Virus-Status: Clean Cc: Ed Schouten , Alexander Leidinger Subject: Re: linux-only jail possible? X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Mar 2010 06:13:42 -0000 On Friday 05 March 2010 04:14:46 Ed Schouten wrote: > Hello Alexander, > > * Alexander Leidinger wrote: > > > My current hurdle is sshd: > > > Mar 3 22:20:51 centos sshd[88836]: fatal: openpty returns device for > > > which ttyname fails. > > > > > > Apparently the Linux sshd isn't using /dev/ptmx appropriately. I'll > > > probably just have to replace it with one that does.. > > > > Ed, can it be that the linuxulator ttyname stuff needs to be fixed > > after your tty changes? > > Hmmm... It worked back in August 2008 when I committed it to HEAD. > ttyname() on Linux works pretty bad. First of all, it tries to > readlink() on a node in devfs. If that fails, it falls back to stat()ing > in /dev, /dev/pts, etc. until a device node is found which shares the > same major/minor number. On FreeBSD we just use FIODGNAME (see > fdevname(3)). > > Could you please strace/truss/etc the Linux binary to see what it > exactly does? Ptrace inside the jail doesn't run: Mar 6 00:33:32 stealth kernel: linux: ptrace(24, ...) not implemented Truss from the host side seems okay except that -f doesn't work as expected. I can attach manually to the child processes just before submitting an SSH password though so hopefully that's enough. If you want me to do any of this again with different truss flags or other information just let me know. === attach truss to already-running jailed Linux sshd stealth# truss -f -a -s 256 -d -p 86936 & 86936: -1267855183.102078976 SIGNAL 17 (SIGSTOP) === connect SSH client 86936: 12.137609664 linux_select(0x6,0x1070920,0x0,0x0,0x0,0x6) = 1 (0x1) 86936: 12.137928894 linux_socketcall(0x5,0x9fbfdc40,0x1064904,0x10691a0,0x1070920,0x6) = 4 (0x4) 86936: 12.138072794 linux_fcntl64(0x4,0x3,0x0,0x0,0x215d8ff4,0x6) = 2 (0x2) 86936: 12.138208180 linux_pipe(0x9fbfe1f0,0xa,0x1064904,0x1066a20,0x1070920,0x6) = 0 (0x0) 86936: 12.138339736 linux_socketcall(0x8,0x9fbfdc40,0x1064904,0x1066a20,0x1070920,0x6) = 0 (0x0) 86936: 12.139791642 linux_clone(0x1200011,0x0,0x0,0x0,0x216a2878,0x6) = 87878 (0x15746) 86936: 12.145413510 close(6) = 0 (0x0) 86936: 12.145607825 write(7,"\0\0\^B\r\0",5) = 5 (0x5) 86936: 12.146314103 write(7,"\0\0\^B\^D\n\n\n\n\n\n\n\n\n\n\n\n\n\nProtocol 2\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nSyslogFacility AUTHPRIV\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nPasswordAuthentication yes\n\n\n\nChallengeResponseAuthentication no\n\n\n\n\n\n\n\n\n\nGSSAPIA"...,524) = 524 (0x20c) 86936: 12.146439264 close(7) = 0 (0x0) 86936: 12.146522149 close(8) = 0 (0x0) 86936: 12.146693212 close(4) = 0 (0x0) === attach truss to two child processes (identified in another terminal) truss -f -a -s 256 -d -p 87878 & truss -f -a -s 256 -d -p 87879 & === submit password from client 87879: 9.853932067 linux_select(0x4,0x106ff30,0x0,0x0,0x0,0x6) = 1 (0x1) 87879: 9.854301549 read(3,"0\M-u\M-S \M-.\M^XB\M-?D\M-N3rxp\M-r\M^AqO\M- h\M^X\M-895Pi\M^_\M^?\M^?\M-1y?X\M^BLq\M-x\M-I\^Y\^R\M-0\M-m\M-8\M-4k\^?\M- w\^D.r\M-S\M-/F\M-R\\\^_\M-^7a\M-S\M^XK\M-}\M^B\M-c\^V\M- dj\M-}:dP\M^T~\M^O\M^Q\M-;\M-Z\^?\M-A^a\M^A^z\M-)\M^I%\M-1\M-P\M-M\M- CNq\M-("...,8192) = 144 (0x90) 87879: 9.854845776 write(4,"\0\0\0\r\v",5) = 5 (0x5) 87878: 20.687933561 read(6,"\0\0\0\r",4) = 4 (0x4) 87879: 9.855093717 write(4,"\0\0\0\bi26y4you",12) = 12 (0xc) 87878: 20.688170204 read(6,"\v\0\0\0\bi26y4you",13) = 13 (0xd) 87878: 20.688383401 linux_time(0x0,0x210971c8,0x0,0x106fdb0,0x106ff50,0x6) = 1267855265 (0x4b91efa1) 87878: 20.688535529 linux_getuid(0x2180e5e4,0x19,0x1,0x1077978,0x106ff50,0x6) = 0 (0x0) 87878: 20.688872527 linux_open("/etc/passwd",0x0,0666) = 4 (0x4) 87878: 20.689040520 linux_fcntl64(0x4,0x1,0x0,0x0,0x215d8ff4,0x6) = 0 (0x0) 87878: 20.689186549 linux_fcntl64(0x4,0x2,0x1,0x1,0x215d8ff4,0x6) = 0 (0x0) 87878: 20.689294722 linux_fstat64(0x4,0x9fbfd774,0x215d8ff4,0x107bb98,0x107bb98,0x6) = 0 (0x0) 87878: 20.689428922 linux_mmap2(0x0,0x1000,0x3,0x22,0xffffffff,0x6) = 554172416 (0x21080000) 87878: 20.699234019 read(4,"root:x:0:0:root:/root:/bin/bash\nbin:x:1:1:bin:/bin:/sbin/nologin\ndaemon:x:2:2:daemon:/sbin:/sbin/nologin\nadm:x:3:4:adm:/var/adm:/sbin/nologin\nlp:x:4:7:lp:/var/spool/lpd:/sbin/nologin\nsync:x:5:0:sync:/sbin:/bin/sync\nshutdown:x:6:0:shutdown:/sbin:/sbin"...,4096) = 1212 (0x4bc) 87878: 20.699503111 close(4) = 0 (0x0) 87878: 20.699635968 munmap(0x21080000,4096) = 0 (0x0) 87878: 20.699914320 linux_open("/etc/shadow",0x0,0666) = 4 (0x4) 87878: 20.700006293 linux_fcntl64(0x4,0x1,0x0,0x0,0x215d8ff4,0x6) = 0 (0x0) 87878: 20.700129843 linux_fcntl64(0x4,0x2,0x1,0x1,0x215d8ff4,0x6) = 0 (0x0) 87878: 20.700259840 linux_fstat64(0x4,0x9fbfd774,0x215d8ff4,0x107bfc0,0x107bfc0,0x6) = 0 (0x0) 87878: 20.700384377 linux_mmap2(0x0,0x1000,0x3,0x22,0xffffffff,0x6) = 554172416 (0x21080000) 87878: 20.708676112 read(4,"root: $1$pG5H8Y01$yn7Y0p4FKKi8sIDcQ3rEf1:14671:0:99999:7::: \nbin:*:14671:0:99999:7:::\ndaemon:*:14671:0:99999:7::: \nadm:*:14671:0:99999:7:::\nlp:*:14671:0:99999:7::: \nsync:*:14671:0:99999:7:::\nshutdown:*:14671:0:99999:7::: \nhalt:*:14671:0:99999:7:::\nmail:"...,4096) = 769 (0x301) 87878: 20.708940347 close(4) = 0 (0x0) 87878: 20.709078960 munmap(0x21080000,4096) = 0 (0x0) 87878: 20.709905132 linux_socketcall(0x1,0x9fbfd890,0x210cdff4,0x1,0x106ff50,0x6) ERR#47 'Address family not supported by protocol family' 87878: 20.710306504 write(6,"\0\0\0\^E\f",5) = 5 (0x5) 87879: 9.877288770 read(4,"\0\0\0\^E",4) = 4 (0x4) 87878: 20.710505458 write(6,"\0\0\0\^A",4) = 4 (0x4) 87879: 9.877482859 read(4,"\f\0\0\0\^A",5) = 5 (0x5) 87879: 9.877654694 write(4,"\0\0\0\^A/",5) = 5 (0x5) 87878: 20.710731764 read(6,"\0\0\0\^A",4) = 4 (0x4) 87878: 20.710905919 read(6,"/",1) = 1 (0x1) 87878: 20.711149450 linux_open("/etc/nologin",0x8000,00) ERR#2 'No such file or directory' 87878: 20.711385340 linux_getuid(0x2180e5e4,0x19,0x0,0x106ff50,0x106ff50,0x6) = 0 (0x0) 87878: 20.711617951 linux_open("/etc/passwd",0x0,0666) = 4 (0x4) 87878: 20.711708912 linux_fcntl64(0x4,0x1,0x0,0x0,0x215d8ff4,0x6) = 0 (0x0) 87878: 20.711830195 linux_fcntl64(0x4,0x2,0x1,0x1,0x215d8ff4,0x6) = 0 (0x0) 87878: 20.711987900 linux_fstat64(0x4,0x9fbfd774,0x215d8ff4,0x107c410,0x107c410,0x6) = 0 (0x0) 87878: 20.712120506 linux_mmap2(0x0,0x1000,0x3,0x22,0xffffffff,0x6) = 554172416 (0x21080000) 87878: 20.712779451 read(4,"root:x:0:0:root:/root:/bin/bash\nbin:x:1:1:bin:/bin:/sbin/nologin\ndaemon:x:2:2:daemon:/sbin:/sbin/nologin\nadm:x:3:4:adm:/var/adm:/sbin/nologin\nlp:x:4:7:lp:/var/spool/lpd:/sbin/nologin\nsync:x:5:0:sync:/sbin:/bin/sync\nshutdown:x:6:0:shutdown:/sbin:/sbin"...,4096) = 1212 (0x4bc) 87878: 20.713160707 close(4) = 0 (0x0) 87878: 20.713268842 munmap(0x21080000,4096) = 0 (0x0) 87878: 20.713400150 geteuid() = 0 (0x0) 87878: 20.713600510 linux_open("/etc/shadow",0x0,0666) = 4 (0x4) 87878: 20.713714568 linux_fcntl64(0x4,0x1,0x0,0x0,0x215d8ff4,0x6) = 0 (0x0) 87878: 20.713833549 linux_fcntl64(0x4,0x2,0x1,0x1,0x215d8ff4,0x6) = 0 (0x0) 87878: 20.713961773 linux_fstat64(0x4,0x9fbfd774,0x215d8ff4,0x107cb90,0x107cb90,0x6) = 0 (0x0) 87878: 20.714090120 linux_mmap2(0x0,0x1000,0x3,0x22,0xffffffff,0x6) = 554172416 (0x21080000) 87878: 20.714762942 read(4,"root: [/etc/shadow contents sanitized] ...,4096) = 769 (0x301) 87878: 20.715053325 close(4) = 0 (0x0) 87878: 20.715173597 munmap(0x21080000,4096) = 0 (0x0) 87878: 20.715325437 linux_time(0x0,0x2180e5e4,0x0,0x1070000,0x107c410,0x6) = 1267855265 (0x4b91efa1) 87878: 20.715451861 linux_socketcall(0x1,0x9fbfd900,0x210cdff4,0x0,0x0,0x6) ERR#47 'Address family not supported by protocol family' 87878: 20.715829496 write(6,"\0\0\0\t0",5) = 5 (0x5) 87879: 9.882848296 read(4,"\0\0\0\t",4) = 4 (0x4) 87878: 20.716121724 write(6,"\0\0\0\^A\0\0\0\0",8) = 8 (0x8) 87879: 9.883134465 read(4,"0\0\0\0\^A\0\0\0\0",9) = 9 (0x9) 87878: 20.716568885 linux_time(0x0,0x215d8ff4,0x9fbfd2dc,0x9fbfd2dc,0x1075b28,0x6) = 1267855265 (0x4b91efa1) 87879: 9.883559415 write(3,"\M-(\a\M-m\M-U\^B6^\M^H\f\M^?\M^_