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 2006-10-12 11:48:50

smack
New member
Registered: 2006-10-12
Posts: 3

Putting it all together

I've been reading the posts here, great work. I believe that I understand the basic process of "fun_plugging" my system, but I would appreciate your insights. Here we go...

1) Checking for fun plug
According to the post from SALA the DSM G600 runs a script on startup "/etc/rc.sh" that executes another script "/usr/sbin/chk_fun_plug" that looks for the file "fun_plug" on the hard drives.

Did I get that right? There's no need to modify the /etc/rc.sh, or /usr/sbin/chk_fun_plug scripts?

2) Creating and then adding your own fun plug file
In order to execute your own scripts (and expand the functionality of the DSM 600), you must add a fun_plug text file to the hard drive. I've read on the forum that this can be done via SAMBA or FTP. I've also read that it has been successfully accomplished on Linux, Windows and Mac OS X. However there are a few details that I need clarification on.

A. What do I need to create a successful fun plug file using Windows XP. I've read on this forum that users have put the fun_plug together using Cygwin. Is this necessary? Can this text file be created using notepad? Are there special characters or attributes that Cygwin is going to take into account? What's the proper extension of the fun_plug text file?

B. Where exactly does the fun_plug file need to go? I'm guessing that it just needs to go in the root of hd_a2. Is that correct?

C. What's the easiest way of getting this file where it needs to be? It seem like FTP is the easiest method. If so what are the things to take into account for FTP access? For example, I've already created a user for the DSM G600 using the Web admin tool and I've given this user root access to read/write on the entire drive. Can I therefore move the file to the hd_a2 root folder via FTP using this account? I've also read that I need to change the permissions of the file via the chmod command in FTP to 777. Is this completly necessary? Does changing the file to these permissions open any potentail security risks? Couldn't we just grant the system read/write/execute privs and not the public?

D. Where can I read up on linux scripts. I really have no freaking clue what you guys are writing in your sample scripts. Any chance of one of you could throw some comments in there for us newbs? These are "bash" scripts right? Forgive me I'm a Web developer who hasn't spent much time in linux unless in was necessary.

3) Adding programs
There are programs hosted on this Web site that have been compiled for the DSM. To use these programs all I have to do is:

A. Upload the programs to the root level of hd_a2
B. Update my fun_plug file to look for the new program

Is that correct? Do you have any suggestions for keeping my hd_a2 from getting too cluttered? In otherwords, can I put everything in a folder like _programs or _applications?

4) Creating new programs
We can compile additional programs using the toolchain provided on this Web site. Correct? Do I have to be running an instance of linux to compile new binaries? Will a live linux CD work? What are some tips for using the tool chain? I was thinking of compiling ruby on rails... but I have no ideas what would be involved, or if the memory of this embedded system will be enough.

5) FTP
Does anyone else think that the default FTP sucks? I tried to assign more than one folder to a user and it kept overriding my first assigned folder. I was thinking of giving dropbear a try. I like the fact that it support SSH. Does anyone have insights into setting this up? Also is there anything I should watch out for when adding a second FTP related program to the DSM? Will I run into conflicts? Or will the two systems ignore each other?

Thank you for your patience. I don't mean to abuse your good will, I'm just not in a hurry to turn my DSM into a brick. Looking forward to hearing from you.

Offline

 

#2 2006-10-12 14:19:54

Grouper
Member
Registered: 2006-09-19
Posts: 33

Re: Putting it all together

Thanks for the post, I think it summarizes a lot of people questions quiet well.
I think I can not really help, I created and transfered the fun_plug, chmodded it and got a telnet login (so something has happened) but I cannot login. (All done with cygwin and vim (which is a pain in the a.. for Windows users...) and ftp)
to 1. yes, right

2) see my effort above
3) For installing you are right,transfer the file to /hdd_a2, enter them in your fun_plug.
4) Dunno
5) Yes,exactly, right again. This and the crappy upnp server made me look around for an alternative Firmware, so here we are :-)

Maybe the rest of the guys around are able to answer your questions better.

Best regards, Grouper

Offline

 

#3 2006-10-12 19:34:31

smack
New member
Registered: 2006-10-12
Posts: 3

Re: Putting it all together

Grouper,

Thanks for the post. So based on your experience I can confirm the following:

1) Nothing needs to be modified to the original boot code to add a fun plug.
3) Additional programs are added by uploading them to the hd_a2 drive and referencing them inside the fun plug script. Although I'd like to know if I can reorganize these programs into a particular folder. I'm guessing that I can as long as I put the correct file path in the fun plug?

What I'm still not clear on is whether or not I need to install cygwin to create my fun plug on Windows (Item 2 in my original post).

What's the concern with being able to telnet into the box? If you have network access to the hd_a2 drive couldn't you make changes to the fun plug and just drop them onto the system? So all you need is a simple script with references to the compiled programs already provided on this Web site.... correct?

I don't like the idea of just using someone's script without knowing what features it's enabling. If anyone in the community has a well commented fun plug script that they'd like to share that would be great. Or maybe you could point me to a good linux Web site that covers creating such scripts.

Thanks for your help guys...

Last edited by smack (2006-10-12 19:38:31)

Offline

 

#4 2006-10-12 21:30:30

Grouper
Member
Registered: 2006-09-19
Posts: 33

Re: Putting it all together

Hi Smack,
finally I got everything running. To sum up, my problem was that I used a different busybox version, I think this one didnīt like my root access.
To sum it up: Telnet is not needed, put the fun_plug with ftp on HDD_a2,do the same with the compiled progs.
If you donīt like the idea of putting scripts you do not understand into the fun_plug, you should not put programs you do not know on your disc either :-)
Cygwin and the telnet is only important if you do not succeed in chmod the file status (777) by ftp. Same is for the unix-compatibility of the fun_plug txt file.
good luck,hope this helps!

Offline

 

#5 2006-10-14 22:18:04

Bunsen
Member
Registered: 2006-09-12
Posts: 6

Re: Putting it all together

1)  Correct.  The built-in chk_fun_plug script looks for /mnt/HD_a2/fun_plug, and executes it if possible.  I'm pretty sure that this is run as root, so only root needs to have permission to execute the file.  "chmod 744 fun_plug" or such (700 even, if you don't want other users reading it) should work fine.  My DSM-G600 isn't active at the moment, or I'd check for you.

2)a.  I made my fun_plug file in vim under linux, so I'm not sure if windows will do anything odd.  I seem to recall that windows and unix use different end-of-line characters (one uses just a CR, one CR and linefeed?), but that memory is a bit fuzzy.  If you want to check that your fun_plug is running, add a line like "touch /mnt/HD_a2/fun_plug_works".  Reboot the DSM, and if the file "fun_plug_works" exists, then it worked.  Also, there is no extension on the filename.  It's just "fun_plug".

d. There's a lot to learn if you want to understand the scripts posted here.  Google for "bash tutorial" and find one that's written in a style you can understand.  The script I'm using (that allows SSH logins) uses a couple sed commands to edit the etc/passwd file so that root and/or user accounts can get a shell when they log in.  If you want to understand those lines, you'll have to learn about sed.  Be prepared to spend a bit of time doing that.  I'm afraid I don't know of any one place you can go to find relevant, understandable information about these things, so you'll probably have to dig through some useless junk to learn what you want to know.

3) You can put additional programs anywhere you want, as long as you tell the system where to look for them.  So if you want to put busybox in HD_a2/bin/ (which would be a linux user's habitual name for a directory full of executable binaries), a line like

Code:

/mnt/HD_a2/busybox telnetd

would just turn into

Code:

/mnt/HD_a2/bin/busybox telnetd

If you're going to use a shell on the box (for ssh or telnet access), you may want to have your own utilities available from the command line without specifying a path (just typing "ctorrent  blah.torrent" instead of "/mnt/HD_a2/ctorrent blah.torrent", for example).  If you've put your executables in HD_a2/bin/, the command

Code:

export PATH=$PATH:/mnt/HD_a2/bin/

will tell the shell to look in /mnt/HD_a2/bin/ for commands (in addition to all the places it normally looks, like /bin/).  (I've been running this from the command line when I log in.  I think you can put the same command, or one like "PATH=$PATH:/mnt/HD_a2/bin/ ; export PATH" in your fun_plug script.  I can't recall if that'll have an effect on your command shell, though.  Go read through the part of that bash tutorial on variables and the "export" command, 'cuz I can't remember.)

4) Personally, I have no idea.  I haven't yet compiled anything for the G600 myself.

5) The web configuration interface for the FTP server does indeed suck. I'm running dropbear (using code from the fun_plug included with it) and using SSH for command-line access, but my FTP access is still through the built-in server.  It's working OK for me, but I don't yet have multiple users on the thing.

When I downloaded the .tar.gz for dropbear, the fun_plug included was a bit messed up.  I think the person who contributed it was in the middle of moving programs from HD_a2/ to another directory (see #3), and some of the file locations in the fun_plug were inconsistent.  Watch out for that.  I can look at my fun_plug later and post it, if you want to check.

The best part about all of this is that it's just about impossible to totally kill the device.  If everything gets fubared, you can pull the drive out, format it in your desktop, put it back, and hit the "restore to factory defaults" button on the G600.  You'll lose any files you had on it, but it's easy enough to keep that backed up until you're done experimenting.

Good luck!

Offline

 

#6 2006-10-15 03:20:08

smack
New member
Registered: 2006-10-12
Posts: 3

Re: Putting it all together

Bunsen,

Thank you for the detailed response.

I got a C in Unix administration in college (Just wasn't my thing... I'm more of a front-end developer). So I recognize a little bit of the shell scripting stuff. The Web can be a great resource but there's also a lot of conflicting information out there. For example there appears to be several shell scripting variations out there for linux. I don't want to waste a lot of time learning some variation that doesn't work on the DSM. Do you know which version(s) of shell are supported by the DSM out of the box?

What's your experience with Dropbear? I wanted to use this utility for the SSH feature, but then I read that in order to enable that I had to change preferences to the linux system itself and I wasn't sure how to do that.

My end goal is get:

1) Secure FTP w/ better multi-user support
2) Simple HTTP w/ either PHP or Ruby - I want to able to sign-in to my box remotely and listen to my music, etc.

For a while I was toying with the notion of putting a VPN server on the box. But that seems a little much for this little box.

A little more research into shell scripts and I think I'll be ready to start toying with my DSM. It's comforting to know that I can simply reformat my drive to start over. But I hope to never have to do that (50+ Gigs of music takes a long time to rip, sort and format) Thank you everyone who's repsonded to this post. I look forward to hearing from more of you.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB