PDA

View Full Version : stupid ftpd - settings erased



rdk
19-08-2004, 14:17
Hi all!
I just upgraded my router to the latest Oleg Firmware CR5 and I have Samba running and its working great!! :D I newer thought I could do this with my router :)

My problem is with the settings of stupid.ftpd which are stored in the /tmp/stupidftpd.conf file

This file seems to be overwritten always when the router is restarted. As I have changed the ftp_pub directory to the / this is very annoying. What I do now is always killing stupid_ftpd and then starting it again with
stupid_ftpd -f stupid_ftpd.conf which I have stored in /usr/local/init

When i downloaded stupid ftpd from sourceforge the manual says (linux/unix):
stupid_ftpd looks for the config file in usr/local/stupid_ftpd/stupid_ftpd.conf or something like that but this seems not to be true as I have created this directory and file there but I seems not to be taken...

What can I do that stupid_ftpd is started always with my configuration file?

Cheers
Rainer

WlanMan
19-08-2004, 15:16
Hi

Web Config of the Router creates the config on-the-fly after boot and stores it in ram ( /tmp is filesystem in ram) so it gets deleted when rebooting.
You have to build something around the post-boot things in olegs firmware to copy your own config from config flash partition into the ram partion i think ...

Dont wonder where the config lies in the source package you downloadet, this can all be configured at compiletime and so its done in asus :).

Styno
19-08-2004, 15:38
Follow these steps:
- Store the stupid-ftp.conf in '/usr/local'.
- Add '/sbin/stupid_ftpd -f /usr/local/stupid_ftpd.conf' to '/usr/local/init/post-boot'
- Disable ftp in the webinterface (if this creates problems with firewall/routing add 'killall stupid-ftp' to '/usr/local/init/post-boot' before the line where you start your own stupid-ftp config)
- Save changes with 'flashfs save' and 'flashfs commit'
- Reboot

This should automate the startup of you custom stupid-ftp config.

There are other options (e.g. compile the firmware yourself) but these will take more time.

rdk
19-08-2004, 16:56
Wow thanks for the fast reply!
I was thinking about doing something like that.(killing and restarting stupid ftpd) at boot time. Just wanted to make sure there is no "proper" other way to do it :)

Styno
19-08-2004, 17:45
Wow thanks for the fast reply!
I was thinking about doing something like that.(killing and restarting stupid ftpd) at boot time. Just wanted to make sure there is no "proper" other way to do it :)
Well, I can't say its the most beautiful way to accomplish this...

You should try to disable the ftp function through webinterface and add an iptables rule to /usr/local/init/post-firewall to enable access from WAN like this:

iptables -A INPUT -p tcp --dport 21 --syn -j ACCEPT

In my view this should work AND is an elegant solution.

rdk
20-08-2004, 14:50
Hmm its strange i have added something like this in the post-firewall script (when I was searching the forum for enabling wan ssh and ftp access) But I have some troubles dealing with iptables...

What worked for me:
In the webinterface's NAT settings i just added a forwarding rule:
192.168.1.1 port 21 and for ssh 192.168.1.1 port 22 and this works for me without having to deal with iptables and post-firewall script... :)

Styno
20-08-2004, 15:21
So, problem fixed?

rdk
20-08-2004, 15:28
Yes everything working now !! Thanks :D

monnier
20-08-2004, 17:21
Looking at Oleg's page about flashfs and tweaking the boot sequence, there's another funky trick you can play:

% cp /init/ftpdserver /usr/local/init/
% cat >/usr/local/init/pre-boot
#!/bin/sh
mount -o bind /usr/local/init/ftpdserver /init/ftpdserver
^D
% chmod +x /usr/local/init/pre-boot
[... edit /usr/local/init/ftpdserver to do what you want it to...]
% flashfs save
% flashfs commit

I've just used this neat trick to change /init/rc.prnsvr so it doesn't start lpd and infosrv (and the p910nd for the LPT port) any more, since I don't use those services.
The mount "-o bind" argument is the trick to replacing a read-only file with a read-write one if your own choosing.