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 2010-12-22 12:00:02

magnusheino
New member
Registered: 2010-12-22
Posts: 1

DNS-320 chmod 755 on usb ext3

Hi.

I have fun_plug running on my DNS-320. I tried to install it on a 8gb usb stick. Everything is working, but one thing...

The DNS-320 seems to chmod -R 777 * on any usb device with ext3 that I put in it. Very annoying behaviour. Any one know where to search? I found the usbmount script, but it only seems to do chmod -R a+w stuff, not a+rwx :-P

/Magnus

Offline

 

#2 2011-09-18 23:14:47

KyleK
Member
From: Dresden, Germany
Registered: 2007-12-05
Posts: 1178

Re: DNS-320 chmod 755 on usb ext3

Hi,

did you find any more info on where the DNS calls chmod -R 777? I'd like to install funplug on a USB stick as well.

Offline

 

#3 2011-09-21 14:00:33

bazzer
Member
Registered: 2011-06-03
Posts: 8

Re: DNS-320 chmod 755 on usb ext3

It's very annoying, I'd love if this could be fixed.

Offline

 

#4 2011-09-21 14:58:33

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

Re: DNS-320 chmod 755 on usb ext3

The bootlog suggests that the rootfs is a ramdisk. If that is true, you can exchange chmod by a script which logs it commandline, and its PPID, and the commandline of the parent, and the PPPID, and...
This might tell where and how it's called.

A work around to be able to put FFP on an USB stick could be the usage of a loop device on a big file on the stick.

Offline

 

#5 2011-09-22 15:08:34

KyleK
Member
From: Dresden, Germany
Registered: 2007-12-05
Posts: 1178

Re: DNS-320 chmod 755 on usb ext3

The bootlog suggests that the rootfs is a ramdisk. If that is true, you can exchange chmod by a script which logs it commandline, and its PPID, and the commandline of the parent, and the PPPID, and...
This might tell where and how it's called.

Not a bad idea, I'll give it a try later today.
Although this'll only work if the commandline tool 'chmod' is called. If a binary tool uses a syscall, the script won't help.

Last edited by KyleK (2011-09-22 15:09:12)

Offline

 

#6 2011-09-23 10:45:08

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

Re: DNS-320 chmod 755 on usb ext3

KyleK wrote:

If a binary tool uses a syscall, the script won't help.

Well, at least then you know it's not a script which does the ugly work.

Offline

 

#7 2011-10-16 01:34:04

bertgr
New member
Registered: 2011-10-16
Posts: 1

Re: DNS-320 chmod 755 on usb ext3

I just connected my ext2-formatted USB-drive to my new (funplugged) DNS-320. It was auto-mounted and started with a lot of activity. When I checked with ps-command I saw "19972 root chmod 777 -R /mnt/USB/HD_c1". I killed it immediate. So I think it's the normal chmod-command, triggered by an automount. Not sure if it's the funplug-version or the original.
I don't like this, all the stuff I copy from USB to the NAS is completely open to everybody.
I don't understand why. A bug?
I wonder this this will also happen if I connect the USB before powering on (is mounting done by funplug of DNS-automount? With funplug I can do a r/o-mount.)

Last edited by bertgr (2011-10-16 21:30:32)

Offline

 

#8 2011-10-16 22:04:15

KyleK
Member
From: Dresden, Germany
Registered: 2007-12-05
Posts: 1178

Re: DNS-320 chmod 755 on usb ext3

Ok, I did some digging.

First attempt was to intercept any calls to "chmod" to see who's actually doing the chmodding:

Code:

CALLER: 0 init         --->     1 /ffp/bin/bash /bin/chmod 777 -R /mnt/USB/HD_c1

That's not much help hmm

But, I think I still found the culprit: /usr/local/modules/scripts/usbmount (shell-script) calls /usr/local/modules/sbin/usb_disk (binary). And that binary contains the string "chmod 777 -R 777 %s/%s/%s". Bam!
Now my problem is, since /usr/local/modules is mounted ro, I can neither change the script nor hex-patch the binary.

Any ideas how to obtain this?

Offline

 

#9 2011-10-16 22:15:16

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

Re: DNS-320 chmod 755 on usb ext3

You can bindmount a writable directory on /usr/local/modules/sbin/, containing a patched usb_disk. Or you could do the same with /usr/local/modules/scripts/, and change usbmount to export a PATH which forces another chmod to run.

/Edit: Or, if /bin is writable, you could exchange chmod by a script which filters on exact this string, and else passes it to busybox.

Last edited by Mijzelf (2011-10-16 22:18:57)

Offline

 

#10 2011-11-16 02:02:52

KyleK
Member
From: Dresden, Germany
Registered: 2007-12-05
Posts: 1178

Re: DNS-320 chmod 755 on usb ext3

Hey guys,

I've been running funplug from a (ext2) USB stick for a couple of weeks now, and finally had some time to create a little package for everyone to use.
I followed Mijzelfs suggestions to replace /bin/chmod with a custom script that blocks that one particular command that causes so much trouble.

You can get the package here: dns325-chmod-fix-0.1-1.tgz

This script should work with ffp-0.5 and ffp-0.7.

So, what does it do?
The package contains 2 script files, chmod_usb.sh and dns325-fix-chmod.sh. The first is the replacement for /bin/chmod, the second does the dirty work to replace /bin/chmod with a symlink to chmod_usb.sh.
All this is done automatically when you install the script (via funpkg -i dns325-chmod-fix-0.1-1.tgz).
The 2 scripts are copied to /usr/local/config. Also, the file rc.init.sh residing in that folder is modified so that it calls dns325-fix-chmod.sh when you boot the NAS.
That script is perfect for the task, because it gets called right before the hotplug script takes action, and also before the NAS looks for fun_plug.


Anyway, let me know how it goes for you (this is my first package with a doinst.sh).

PS: For now, all calls to /bin/chmod are logged to /usr/local/config/chmod.log, and you can see here which calls are suppressed and which go through.


Edit: Fixed link.

Last edited by KyleK (2012-06-13 09:51:40)

Offline

 

#11 2011-11-16 10:07:26

Gyngy
Member
Registered: 2011-05-27
Posts: 32

Re: DNS-320 chmod 755 on usb ext3

KyleK, thank you!

I will try today evening and post some reply.

Gyngy

Offline

 

#12 2011-11-17 20:16:08

Gyngy
Member
Registered: 2011-05-27
Posts: 32

Re: DNS-320 chmod 755 on usb ext3

Hi KyleK,
your installation package works like a charm. Finally is my USB mounted as it should be - with permissions.

Thank you again!

Gyngy

Offline

 

#13 2012-04-11 20:31:27

schluri
New member
Registered: 2012-04-11
Posts: 1

Re: DNS-320 chmod 755 on usb ext3

Hi folks,

I recently purchased a DNS-345 and I tried to install the dns325-chmod-fix-0.1-1.tgz on the NAS but it didn't work.
I dug a bit deeper into the issue and found that the script rc.init.sh is never called during system start.
Here is the system start as I could identify it:

1) /etc/inittab
2) /etc/rc.sh
3) system_init

In the system_init script I can see the following lines :

Code:

echo "*** execute rc.init.sh"
ip.sh booting

So, it appers as if the rc.init.sh call has been removed.

Hence the first non read-only script which is called during system start is the fun_plug script.
But at that point all auto-mounts are done with the wrong permissions.

Has anyone else recognized the same behaviour ?

One solution might be to store the permissions after install of the fun_plug stuff and restore them after the reboot usinng the fun_plug vehicle. This might work but it is not a smart solution.
Are there any plans for a custom firmware for the DNS-345 which fixes this 'chmod' nightmare ?

Offline

 

#14 2012-04-11 23:22:32

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

Re: DNS-320 chmod 755 on usb ext3

Depending on your goal you could avoid automounting. When the 345 supports loopdevices, you could let a filesystem start on an offset on a raw disk. It won't be automounted, but fun_plug can mount it.

Offline

 

#15 2012-04-24 06:52:54

bazzer
Member
Registered: 2011-06-03
Posts: 8

Re: DNS-320 chmod 755 on usb ext3

I was unable to download the file from KyleK, so just thought I'd mention that it appears to have been moved to here.

Offline

 

#16 2012-04-24 09:52:38

KyleK
Member
From: Dresden, Germany
Registered: 2007-12-05
Posts: 1178

Re: DNS-320 chmod 755 on usb ext3

Updated the link in my post, as the package was moved to a different folder. Thanks for catching this, bazzer!

Offline

 

#17 2012-04-24 11:03:19

KyleK
Member
From: Dresden, Germany
Registered: 2007-12-05
Posts: 1178

Re: DNS-320 chmod 755 on usb ext3

@schluri: Are there no other scripts in /usr/local/config that might be executed before usbmount/funplug?

We might then be able to inject the code at a different position.

Offline

 

#18 2012-06-08 15:11:13

shidevil
Member
Registered: 2012-06-08
Posts: 18

Re: DNS-320 chmod 755 on usb ext3

Hi,

i ran into a problem trying to run FFP on USB.

Followed shadowandy guide on http://www.shadowandy.net/2011/12/movin … to-usb.htm

however following all the steps..

except running into an error on Update it to suppress HD_c instead of HD_c1 by typing “cat /usr/local/config/chmod_usb.sh | sed -e ‘s/\/HD_c1\”/\/HD_c\”/’ >> /usr/local/config/chmod_usb.sh“

can't get it to run hence i forgot it knowing my mounting is hd_c1

followed all the way through..

and finally the error here.

/dev/sdc1: UUID="5ef5ce8f-cab0-4adc-9f54-cc320707d57a" TYPE="ext2"
Success. Found 5ef5ce8f-cab0-4adc-9f54-cc320707d57a.
* FFP was not found on a USB device. Reverting back to HDD-based FFP

Offline

 

#19 2012-06-08 15:17:05

KyleK
Member
From: Dresden, Germany
Registered: 2007-12-05
Posts: 1178

Re: DNS-320 chmod 755 on usb ext3

Did you format the USB stick and put the fun_plug.tgz archive onto the stick?

Offline

 

#20 2012-06-08 15:21:27

shidevil
Member
Registered: 2012-06-08
Posts: 18

Re: DNS-320 chmod 755 on usb ext3

KyleK wrote:

Did you format the USB stick and put the fun_plug.tgz archive onto the stick?

yes i did format the stick and did a copy instead.

following shadowandy guide.

Copy the current ffp folder to USB

We will be shifting the current ffp installation on your disk to the USB drive and it will take a while before the copy completes so sit back and enjoy a can of coke or a cup of Starbucks.

Copy the current ffp installation to USB by typing “cp -a /mnt/HD/HD_a2/ffp /mnt/USB/HD_c1/“

I did this.

I have double confirmed that my USB stick is ext2 format and have ffp folder inside.

Offline

 

#21 2012-06-08 15:26:10

KyleK
Member
From: Dresden, Germany
Registered: 2007-12-05
Posts: 1178

Re: DNS-320 chmod 755 on usb ext3

Is your USB stick mounted to /mnt/USB/HD_c or /mnt/USB/HD_c1?
If the latter, then you need to modify the fun_plug script (put the correct path in the variable FFP_USB, right at the beginning of the file).

Offline

 

#22 2012-06-08 15:31:53

shidevil
Member
Registered: 2012-06-08
Posts: 18

Re: DNS-320 chmod 755 on usb ext3

KyleK wrote:

Is your USB stick mounted to /mnt/USB/HD_c or /mnt/USB/HD_c1?
If the latter, then you need to modify the fun_plug script (put the correct path in the variable FFP_USB, right at the beginning of the file).

oh! i get it. let me try it now!

thank you so much!

I have just installed transmission. Do i need to move the file to the USB instead?

Offline

 

#23 2012-06-08 15:34:20

shidevil
Member
Registered: 2012-06-08
Posts: 18

Re: DNS-320 chmod 755 on usb ext3

KyleK wrote:

Is your USB stick mounted to /mnt/USB/HD_c or /mnt/USB/HD_c1?
If the latter, then you need to modify the fun_plug script (put the correct path in the variable FFP_USB, right at the beginning of the file).

Awesome! got it to work.

/dev/sdc1: UUID="5ef5ce8f-cab0-4adc-9f54-cc320707d57a" TYPE="ext2"
Success. Found 5ef5ce8f-cab0-4adc-9f54-cc320707d57a.
* Found FFP on USB device

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB