LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Incognito (https://www.linuxquestions.org/questions/incognito-85/)
-   -   Automating detection of Internet USB dongle via udev (https://www.linuxquestions.org/questions/incognito-85/automating-detection-of-internet-usb-dongle-via-udev-736054/)

Sylvester 06-27-2009 12:29 PM

Automating detection of Internet USB dongle via udev
 
I have been following a how-to that explains the normal method of doing this:

http://crazyaboutubuntu.wordpress.co...ick-on-ubuntu/

The normal method is to add a udev rule (/etc/udev/rules.d/) that executes some script the moment udev detects that the dongle has been plugged in.

The problem is that /etc/ is not persistent in incognito.

I am attempting to solve it by executing a script that will write the rule file /etc/udev/rules.d/bla.rules upon start-up

But now I encounter a further problem: how to get a script to execute upon start-up? it seems (from playing around on the command line) that only root can execute a #!/bin/sh script. This seems to rule out placing it in /home/incognito/.kde/Autostart/ - although I am not 100% sure, I have a feeling anything in this folder gets executed as user:incognito rather than user:root

I am a bit stuck. Should I be trying to make /etc persistent? there is probably a good reason it was made non-persistent in the first place, yes?

Sy

Sylvester 06-27-2009 02:51 PM

Could someone please have a go and see if you can get a trivial bash script to execute on start-up?

I have to give up - I have exhausted the freenode channels and nobody seems to have any idea.

The nub of the problem seems to be I cannot execute a bash script if I am not root. it will generate the error /bin/bash: bad interpreter: permission denied.

Oddly enough
/bin/bash -c 'echo foo'
Behaves correctly

And of course executing the script as root works.

I have checked the permissions on bash and sh, and these are all good - they are executable by everyone.

I have checked the permissions on my script, and made sure the owner is root.

Still no luck.

Does it matter what group the script belongs to? I don't really understand groups, and for now I'm exhausted - my hands hurt a lot when I type. so I have to go slow...

Sy

anonym 06-27-2009 07:32 PM

Quote:

Originally Posted by Sylvester (Post 3588327)
The nub of the problem seems to be I cannot execute a bash script if I am not root. it will generate the error /bin/bash: bad interpreter: permission denied.

As I said on irc, this is due to GrSec's Trusted Path Execution (TPE). What I said to you was wrong, though. It's the directory the executable file is located in, not the executable itself, that must be owned by root, and additionally none other than root should have write permission to it. You can fix this with:
Code:

chown root ~/.kde/Austostart
chmod go-w  ~/.kde/Austostart

Quote:

Originally Posted by Sylvester (Post 3588327)
Oddly enough
/bin/bash -c 'echo foo'
Behaves correctly

This isn't strange -- you can run 'echo foo' in a bash shell as the incognito user, right? What I think you meant was that running '/bin/bash ./kde/Austostart/foo.sh' works is weird, but really it's not; in this case what we really execute is /bin/bash (/bin is owned by root and have the nice permissions so TPE won't interfere), but the commands in foo.sh are passed to the bash interpreter. foo.sh isn't executed directly (i.e. running ~/.kde/Austostart/foo.sh) which is the only thing TPE cares about.

Quote:

Originally Posted by Sylvester (Post 3588327)
Does it matter what group the script belongs to?

Not with the standard permissions.

Sylvester 06-28-2009 06:55 AM

Thank you for the post!

Unfortunately I have fallen at the very next hurdle - now I can execute the script, however the sole purpose of the script is to create two symbolic links into /etc/ and /etc/udev/rules.d/, and these cannot be done as non-root.

I have tried putting 'su -' near the beginning of the script. If I simply execute the script from the command line as non-root, it works. But if I allow the script to execute automatically upon start-up, it does not work - I checked these folders on the link has not been created.

Much as I would love to fiddle for days and write up a how-to once I get it all figured, I'm going to have to let go, as my hands cannot cope with the typing. I am still curious as to any possible solutions, and if anonym keeps up this incredible level of technical support I will endeavour to get there.

Sy

anonym 06-28-2009 07:24 AM

Quote:

Originally Posted by Sylvester (Post 3588815)
I have tried putting 'su -' near the beginning of the script. If I simply execute the script from the command line as non-root, it works. But if I allow the script to execute automatically upon start-up, it does not work - I checked these folders on the link has not been created.

'su -' will open a new root shell but the commands listed after won't be executed in the root shell. They will be executed when the root shell has exited (which won't happen unless you switch to it and do it manually). You should do something like this instead:
Code:

su -c 'command'
for each command that require root privileges, e.g.
Code:

su -c 'ln -s ~/some_config /etc'

Sylvester 07-03-2009 10:02 PM

Just to share my latest efforts in this direction:

The Asus EEE PC 901 go has hidden in the battery compartment a slot for inserting a Sim card. So it is possible to get an Internet dongle, take out the Sim card and insert it.

Getting Incognito to correctly connect to this Internet connection might be a marathon -- I don't have any idea where to start. I am guessing lspci would find it and wvdial with the correct settings might get it working. I'm sure it won't be long before someone has figured it out.

So for the time being I'm investigating running incognito as the virtual machine inside XP -- seeing as XP software is installed by default for connecting to the Internet through this little device.

However, I will keep posting to the forum as I figure out some solution.

Sy


All times are GMT -5. The time now is 06:39 PM.