PDA

Bekijk de volledige versie : FTP - Make permanent changes to stupid-ftpd.conf



Bertie
27-11-2004, 19:02
OK, my first posting in the forum comes here..

I've just installed the custom firmware ver 1.8.1.7-3 (looks very cool!!). I've creating my custom stupid-ftpd.conf file and made it permanent with flashfs-command. The problem is that when I plug in a USB-drive the stupid-ftpd starts and it replaces my stupid-ftpd.conf file with a default one. How can I avoid my custom stupid-ftpd.conf file being replaced?

Styno
27-11-2004, 22:26
This config file in /tmp is being created whithin a script. I have no idea about how to change this ...

hugo
27-11-2004, 22:41
You cannot avoid the auto-usb program to run. This one run the ftp process and create on the fly stupid-ftpd.conf file.

You can try to disable the "enable ftp server" option in USB application menu.

Then you can make sure the stupid-ftpd process is not run, and make change permanent using the instruction in here (http://wl500g.dyndns.org)

Otherwise, you'll have to make a script to overwrite the stupid-ftp.conf and maybe use a cron to run is on a regular basis

Bertie
28-11-2004, 00:28
Still havent found a sollution. Tried adding the following lines to the post-boot:

killall stupid-ftpd
cp /tmp/stupid-ftpd.conf.tmp /tmp/stupid-ftpd.conf
stupid-ftpd

But it didn't work. Seems theese commands get executed before the USB is mounted and the "default" stupid-ftpd is started. Can I make a script like the one above that waits some seconds before beeing executed?

Styno
28-11-2004, 00:51
Still havent found a sollution. Tried adding the following lines to the post-boot:

killall stupid-ftpd
cp /tmp/stupid-ftpd.conf.tmp /tmp/stupid-ftpd.conf
stupid-ftpd

But it didn't work. Seems theese commands get executed before the USB is mounted and the "default" stupid-ftpd is started. Can I make a script like the one above that waits some seconds before beeing executed?
1) Disable stupid-ftp in webinterface
2) Place following code in the post-boot script:
http://wl500g.info/showpost.php?p=6290&postcount=26
3) After the delay code, copy your stupid-ftp config to /temp
4) Also after delay start stupid-ftp daemon

The proper place to store you custom configuration is in /usr/local/etc. So, save it there with flashfs save and commit.
Try this and tell us if it works

Bertie
28-11-2004, 12:31
Still no luck. I'm a Linux-beginner so maybe it's some stupid mistake I'm doing.. Anyway, I tried edit my post-boot script so it waited until folder /tmp/harddisk/ftp_pub is availiable. No luck. So I tried waiting for the process stupid-ftpd instead. Still no luck. My post-boot contains the following:

#!/bin/sh
i=0
while [$i -le 30]; do
e=ps -ef | grep -c "[s]tupid-ftpd"
if [$e -gt 0] ; then
killall stupid-ftpd
cp /usr/local/etc/stupid-ftpd/stupid-ftpd.conf.aon /tmp/stupid-ftpd.conf
stupid-ftpd
break;
fi
sleep 1
i=(($i + 1))
done

Styno
28-11-2004, 19:51
Is it possible to start the stupid-ftp daemon from a telnet session at all? If it does, my previous post should do the trick. If not I'm out of options...

Bertie
29-11-2004, 19:44
Finally! I did it! :D (Not that it required very advanced sollutions...) Thanks hugo and Styno for your time. The main sollution was to replace the increment line in the delay script with

: $((i = $i + 1 ))

Also did the check on the file stupid-ftpd.conf, that is I delay the boot until this file exist. The whole script follows..

i=0
while [ $i -le 30 ]; do
if [ -e /tmp/stupid-ftpd.conf ] ; then
killall stupid-ftpd
cp /tmp/local/etc/stupid-ftpd/stupid-ftpd.conf.aon /tmp/stupid-ftpd.conf
stupid-ftpd
break
fi
sleep 1
: $((i = $i + 1 ))
done

A security issue might be that if the script for some reason times out (although 30 secs should be enough), the ftp deamon may run with the default stupid-ftpd.conf which enables anonymous access. I'll see to adding some code that, if file /tmp/stupid-ftpd.conf is not found, kills any stupid-ftpd running ("killall stupid-ftpd") and unmounts any connected USB-drive ("umount /tmp/harddisk").