DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2009-06-24 20:15:19

Bever
Member
Registered: 2009-06-24
Posts: 8

No shell when running from USB stick

I have a working ffp on my HD. I found a script that will load my USB module and mount my USB stick and run ffp from there. I copied over my working ffp to the stick (after slapping ext3 on there), and it boots fine. Apparently SSHD is running, as I can connect through SSH, but after the login, I get no shell. Not with root who has bash, and not with another user who has the standard shell. Now I can use sftp, so that tells me that the authentication probably goes OK. But why am I not getting my shell then... Also, when I start telnetd, I can connect just once, and then it disconnects straight away.

Any ideas?

Last edited by Bever (2009-06-24 20:15:57)

Offline

 

#2 2009-06-25 10:48:13

Bever
Member
Registered: 2009-06-24
Posts: 8

Re: No shell when running from USB stick

OK, after some tweaking of the logging options, I think I have narrowed it down to devpts /dev/pts devpts not being mounted. This is what I got from syslog:

Jun 25 09:19:06 BITBUCKET auth.debug sshd[3183]: debug1: session_input_channel_req: session 0 req pty-req
Jun 25 09:19:06 BITBUCKET auth.debug sshd[3183]: debug1: Allocating pty.
Jun 25 09:19:06 BITBUCKET auth.err sshd[3183]: error: openpty: No such file or directory
Jun 25 09:19:06 BITBUCKET auth.err sshd[3183]: error: session_pty_req: session 0 alloc failed

So I compared my /proc/mounts between booting from USB and booting from HDD.

USB:

rootfs / rootfs rw 0 0
/dev/root / ext2 rw 0 0
proc /proc proc rw,nodiratime 0 0
/dev/loop0 /sys/crfs squashfs ro 0 0
/dev/md0 /mnt/HD_a2 ext3 rw 0 0
/dev/sda4 /mnt/HD_a4 ext3 rw 0 0
/dev/sdb4 /mnt/HD_b4 ext3 rw 0 0
none /proc/bus/usb usbfs rw 0 0
/dev/sdc1 /mnt/USB ext3 rw 0 0

HDD:

rootfs / rootfs rw 0 0
/dev/root / ext2 rw 0 0
proc /proc proc rw,nodiratime 0 0
/dev/loop0 /sys/crfs squashfs ro 0 0
/dev/md0 /mnt/HD_a2 ext3 rw 0 0
/dev/sda4 /mnt/HD_a4 ext3 rw 0 0
/dev/sdb4 /mnt/HD_b4 ext3 rw 0 0
none /proc/bus/usb usbfs rw 0 0
devpts /dev/pts devpts rw 0 0

So yeah, now I have to find out why devpts is not mounted when booted from USB. As always, suggestions are welcomed smile

Offline

 

#3 2009-06-25 11:01:27

Mijzelf
Member / Developer
Registered: 2008-07-05
Posts: 709

Re: No shell when running from USB stick

Looking at the order in /dev/mounts it seems to me devpts is mounted *after* fun_plug has run. So maybe fun_plug now never returns, or returns an errorcode causing the calling script to stop?

Offline

 

#4 2009-06-25 12:52:32

Bever
Member
Registered: 2009-06-24
Posts: 8

Re: No shell when running from USB stick

I've found it. The script I used doesn't have these two entries:

# run fun_plug.init, if present
if [ -x /ffp/etc/fun_plug.init ]; then
    echo "* Running /ffp/etc/fun_plug.init ..."
    /ffp/etc/fun_plug.init
fi

# run fun_plug.local, if present
if [ -x /ffp/etc/fun_plug.local ]; then
    echo "* Running /ffp/etc/fun_plug.local ..."
    /ffp/etc/fun_plug.local
fi

For reasons unknown to me...

It is in fun_plug.init that devpts is mounted. So now it's working!

Offline

 

#5 2009-06-26 05:53:05

freitas
Member
Registered: 2009-06-06
Posts: 9

Re: No shell when running from USB stick

I had the same problem.  I used the standard funplug script and then used bootstrap script below. 

I like this one better because I do not need to know the UUID of the USB drive.

For more on this script see http://dns323.kood.org/forum/viewtopic.php?id=2885

Code:

#!/bin/sh

usbdisk_mount_options="-t auto"
usbdisk_dev="sdc1"
usbdisk_name="usb"
usbdisk_mountp="/mnt/$usbdisk_name"

# Load usb-storage module
insmod /mnt/HD_a2/ffp/lib/modules/$(uname -r)/usb-storage.ko

# Test to see if usb-storage module loaded.
/bin/grep -q usb_storage /proc/modules
if [ $? -eq 0 ]; then
    # Announce Successful load of usb-storage.ko
    echo "Success - usb-storage.ko module loaded."

    #  Wait for disk to initialize.
    let timeout=60
    while [ $timeout -gt 0 ]; do
    echo "Waiting $timeout seconds for $usbdisk_dev to initialize."
        /bin/grep -q $usbdisk_dev /proc/partitions
        [ $? -eq 0 ] && break
        sleep 2
        let timeout=${timeout}-2
    done
    /bin/grep -q $usbdisk_dev /proc/partitions
    if [ $? -eq 0 ]; then
        # Disk found. Attempt to create mount point.
        mkdir -p $usbdisk_mountp
        echo "Mounting /dev/$usbdisk_dev on $usbdisk_mountp"
        mount $usbdisk_mount_options /dev/$usbdisk_dev $usbdisk_mountp >$usbdisk_mountp/mount-error.txt 2>&1
        if [ $? -eq 0 ]; then
            echo "Success - /dev/$usbdisk_dev mounted as $usbdisk_mountp."
            # Test for existence of ffp on USB drive
            if [ -d $usbdisk_mountp/ffp ]; then
                # Establish path to symlink
                FFP_PATH="$usbdisk_mountp/ffp"
            fi            
        else
            echo "Warning - failed to mount /dev/$usbdisk_dev!"
            cat $usbdisk_mountp/mount-error.txt
        fi
    else
        echo "Warning - failed to mount /dev/$usbdisk_dev. Did not find $usbdisk_dev in /proc/partitions!"        
    fi
else
    # Storage module failed to load. Write error to ffp.log.
    echo "Warning - failed to load usb-storage.ko module!"
fi

Last edited by freitas (2009-06-26 05:54:20)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB