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 2007-03-11 19:22:16

woody
Member
Registered: 2007-03-05
Posts: 31

fun_plug stopped working

I was trying to get Firefly (standalone) to work, and somehow my fun_plug stopped working.  I can still telnet in, so it's getting that far, but it's not doing everything after that

#!/bin/sh
#
# Minimal fun_plug, only enables telnet
#
# Requires: /mnt/HD_a2/starttelnet.sh
#           /mnt/HD_a2/lnx_bin/busybox3
#           /mnt/HD_a2/lnx_bin/utelnetd
#

#
# Uncomment next line if you want "proof of concept".
# A filem dmesg.out will be located on \\NAS\HDD_1 or
# \\NAS\Volume_1 depnding on firmware version.
#
dmesg > /mnt/HD_a2/userdata/woody/dmesg.out

#
# Start the telnet deamon
#
/mnt/HD_a2/starttelnet.sh

#
# Use my smb.conf
#
cp /mnt/HD_a2/smb.conf /etc/samba/smb.conf

#
# reset my samba password
#
(echo "xxx"; echo "xxx") | smbpasswd -s -a woodylott
(echo "xxx"; echo "xxx") | smbpasswd -s -a claudia

#
# restart samba
#
smb restart

Right after reboot, If I look at /etc/samba/smb.conf it doesn't look like  /mnt/HD_a2/smb.conf.  If I run the last few commands by hand, my samba shares show up

Offline

 

#2 2007-03-11 20:40:26

woody
Member
Registered: 2007-03-05
Posts: 31

Re: fun_plug stopped working

tried putting samba stuff in a seperate script (/mnt/HD_a2/mysmb.sh):


#!/bin/sh
cp /mnt/HD_a2/smb.conf /etc/samba/smb.conf
(echo "xxx"; echo "xxx") | smbpasswd -s -a woodylott
(echo "xxx"; echo "xxx") | smbpasswd -s -a claudia
smb restart

added line to /mnt/HD_a2/fun_plug:

/mnt/HD_a2/mysmb.sh

reboot and shares aren't there.  However, if I then run /mnt/HD_a2/mysmb.sh, they show up?!?

Offline

 

#3 2007-03-12 13:14:14

woody
Member
Registered: 2007-03-05
Posts: 31

Re: fun_plug stopped working

It tried to debug which line is failing:

ls -al /etc/samba/smb.conf > /mnt/HD_a2/smbconf.b4

cp /mnt/HD_a2/smb.conf /etc/samba/smb.conf

if [ "$?" -eq 0 ] # Check the return code
then
        echo 'copy smb.conf worked' > /mnt/HD_a2/funplug.debug
else
        echo 'copy smb.conf didn't work' > /mnt/HD_a2/funplug.debug
fi

ls -al /etc/samba/smb.conf > /mnt/HD_a2/smbconf.after

I rebooted and I got the file

/mnt/HD_a2/smbconf.b4

but I didn't get either of these
/mnt/HD_a2/funplug.debug
/mnt/HD_a2/smbconf.after

It looks like the line where I copy my smb.conf over the 'system' version is failing.  Why?

Offline

 

#4 2007-03-12 13:29:13

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: fun_plug stopped working

Looks as if the shell aborts, probably because of an error.

In your fun_plug, try changing

  /mnt/HD_a2/mysmb.sh

to

  /mnt/HD_a2/mysmb.sh 1>/mnt/HD_a2/mysmb.log 2>&1

All relevant error messages should show up in mysmb.log then.

Offline

 

#5 2007-03-12 13:47:47

woody
Member
Registered: 2007-03-05
Posts: 31

Re: fun_plug stopped working

I tried your suggestion, and it looks like the everything but copying my smb.conf worked:

# # more /mnt/HD_a2/mysmb.log

Password changed for user woodylott.
Password changed for user claudia.
$Shutting down SMB services:
$Shutting down NMB services:
$Starting SMB services:
$Starting NMB services:
# ls -al /etc/samba/smb.conf

# -rw-r--r--    1 root     root         1321 Mar 12 05:39 /etc/samba/smb.conf
# # ls -al /mnt/HD_a2/smb.conf

-rwxrwxrwx    1 woodylot admins       1831 Mar  9 14:11 /mnt/HD_a2/smb.conf

Why is the line
cp /mnt/HD_a2/smb.conf /etc/samba/smb.conf
not working?

I just ran mysmb.sh from shell, and my shares showed.  Why doesn't it run from within fun_plug?

Offline

 

#6 2007-03-12 13:55:14

Apskaft
Member
From: Karlskrona, Sweden
Registered: 2007-01-09
Posts: 165

Re: fun_plug stopped working

woody wrote:

Why is the line
cp /mnt/HD_a2/smb.conf /etc/samba/smb.conf
not working?

Maybe the (quite limited) shell used during boot does not support the cp command. Maybe the PATH environment variable is not setup in the fun_plug and need to be modified.

Try to use '/mnt/HD_a2/lnx_bin/busybox3 cp' instead, or add to your PATH the location of the cp command. E.g. 'export $PATH=/bin:$PATH'

While booting, add 'echo $PATH > mypath.log" to your fun_plug to see which PATH beeing used and if cp command is available there.

/Apan

Offline

 

#7 2007-03-12 14:12:04

woody
Member
Registered: 2007-03-05
Posts: 31

Re: fun_plug stopped working

Apskaft wrote:

Try to use '/mnt/HD_a2/lnx_bin/busybox3 cp' instead, or add to your PATH the location of the cp command.
/Apan

I changed it

# cp /mnt/HD_a2/smb.conf /etc/samba/smb.conf
/mnt/HD_a2/lnx_bin/busybox3 cp /mnt/HD_a2/smb.conf /etc/samba/smb.conf

but it didn't work

# ls -al /etc/samba/smb.conf
# -rw-r--r--    1 root     root         1321 Mar 12 06:06 /etc/samba/smb.conf

Offline

 

#8 2007-03-12 14:13:04

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: fun_plug stopped working

There should be a message like "cp: Command not found". I wonder why it fails silently...

Offline

 

#9 2007-03-12 14:23:09

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: fun_plug stopped working

In case "cp" is the problem, you could try to replace the cp command with:

cat /mnt/HD_a2/smb.conf > /etc/samba/smb.conf

(NOTE the added ">")

Also add a "echo $UID" to your script (should print 0 for root user.
If not, there might be a permission problem)

Offline

 

#10 2007-03-12 14:30:09

woody
Member
Registered: 2007-03-05
Posts: 31

Re: fun_plug stopped working

fonz wrote:

There should be a message like "cp: Command not found". I wonder why it fails silently...

I tried copying my smb.conf to /etc/samba dir with different name

/mnt/HD_a2/lnx_bin/busybox3 cp /mnt/HD_a2/smb.conf /etc/samba/smbconf.testcopy

and that worked

# ls -al /etc/samba

drwxr-xr-x    2 root     root         1024 Mar 12 06:24 .
drwxr-xr-x    5 root     root         1024 Mar 12 06:24 ..
lrwxr-xr-x    1 root     root           19 Mar 12 00:23 codepages -> /sys/crfs/codepages
-rw-------    1 root     root         8192 Mar 12 06:24 secrets.tdb
-rw-r--r--    1 root     root         1321 Mar 12 06:24 smb.conf
-rwxr-xr-x    1 root     root         1127 Mar 12 00:23 smb.default
-rwxr-xr-x    1 root     root         1831 Mar 12 06:24 smbconf.testcopy
-rw-------    1 root     root          428 Mar 12 06:24 smbpasswd

Maybe the cp is working, but it's being overwritten afterwards by system version.  Isn't fun_plug last in init scripts?

Offline

 

#11 2007-03-12 14:38:33

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: fun_plug stopped working

woody wrote:

Maybe the cp is working, but it's being overwritten afterwards by system version.  Isn't fun_plug last in init scripts?

Good point. I think there's more stuff running after fun_plug. Unfortunately, I cannot access my box right now.
Search for a script "rc.sh" or similar. It runs fun_plug and some more things.

Offline

 

#12 2007-03-12 15:43:24

woody
Member
Registered: 2007-03-05
Posts: 31

Re: fun_plug stopped working

fonz wrote:

Good point. I think there's more stuff running after fun_plug. Unfortunately, I cannot access my box right now.
Search for a script "rc.sh" or similar. It runs fun_plug and some more things.

I put a sleep 20 in mysmb.sh, and that fixed it.  I'm not sure why that fixed it, though.  Does that make sense to anyone?

Offline

 

#13 2007-03-12 16:00:57

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: fun_plug stopped working

It fixed it, because the rc-script I mentioned starts fun_plug in the background. So your sleep 20 waits until all the other startup scripts have finished. So you're probably right that the startup scripts overwrite smb.conf _after_ fun_plug has been started.

Offline

 

#14 2007-03-12 17:45:27

Apskaft
Member
From: Karlskrona, Sweden
Registered: 2007-01-09
Posts: 165

Re: fun_plug stopped working

I have a feeling that the program op_server screws things up. Samba is started prior to the fun_plug, but I think the op_server restarts it. At least the .text. part contains "smb.restart" and reference to smb.conf. I think this process monitors the system configuration files and keeps things running. E.g. if you kill "webs" then "webs" will be restarted by this process.

The .text. section of op_server reveals a lot of the internals of the DNS. I suppose this could be a reason why the system is so hard to find sometimes, from an XP system, while rebooted. Samba is restarted at least once during boot.

Poor design!! But, this we already known from the wonderful rc.sh script....

These two files alone justifies the work of magore and all you others trying to throw out D-Link from this unit...

/Apan

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB