Hi,
I need to load modules to connect to the internet, so I've created a script.

Script file is called 'connect.sh' is owned by root and has permissions set to 4755, so it is executed as root, even if run by non-root user (at least I think so). I still get errors:

When script comes to line '/sbin/modprobe pppoatm' it gives:
WARNING: Error inserting slhc (/lib/modules/2.6.24.4-64.fc8/kernel/drivers/net/slhc.ko): Operation not permitted
WARNING: Error inserting ppp_generic (/lib/modules/2.6.24.4-64.fc8/kernel/drivers/net/ppp_generic.ko): Operation not permitted
FATAL: Error inserting pppoatm (/lib/modules/2.6.24.4-64.fc8/kernel/net/atm/pppoatm.ko): Operation not permitted

Any idea?

PS: I really would like to avoid changing any other files than the script file 'connect.sh' if possible...

Funnily enough, just last week I wrote a little howto on this (see my website in my signature for more info). The reason for the problem you're experiencing is that while most *nix distributions work fine when the setuid bit on a binary is turned on, the distributions specifically disable the use of setuid bits on shell scripts, due to their insecure nature.

There are two possible workarounds: a) edit the sudoers file so that sudo doesn't require a password for the commands that you need to execute in your shell script, or b) call the script from a C program using the system() call.

Thank you very much for your help! I will check if it works later, but I think it will. Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.