How to make a script run setuid?

Hello All,

I want to run the following code setuid through a shell script.I setuid the script,but the setuid bit is not honoured.Could anybody suggest how to do it?
The code is below:

#!/bin/sh
/usr/sbin/usb_modeswitch -v 0x19d2 -p 0xfff5 -m 0x05 -M "5553424312345678c00000008000069f030000000000000000000000000000"

The immediate reason is,the user is in a remote area where USB modem is the only option to connect to internet.The user is a computer-illiterate.The modem in question,is actually in the database of usb_modeswitch program,but inspite of the corresponding rule in /etc/udev/rules.d/51–usb_modeswitch.rules,udev action for this device is not triggered.[Please see the rule line quoted below]But manual invocation as above triggers mode-switch and knetworkmanager recognition.

Now I do not want to expose the user to root’s password.I plan to write a script,make root the owner and setuid the script and crealte a launcher which will execute that.It did not work,the bit is ignored.How can I do it?OR any other alternative?

UDEV rule which fails to trigger is below.I have done a ‘udevadm info’ check to see that the rules match.

SUBSYSTEM=="usb", ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="fff5", RUN+=/usr/sbin/usb_modeswitch -v 0x19d2 -p 0xfff5 -m 0x05 -M "5553424312345678c00000008000069f030000000000000000000000000000"

Hi,

as far as I know it is not allowed to set suid bit for bash scripts. If you do this it gets ignored.

As a workaround I would suggest to use sudo. You can configure sudo so that some commands don’t require a password. Look at the sudo manpage for more details.

Hope this helps

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Exactly. Google for ‘set uid script’ and quite a bit will be returned.
The first hit is this:
http://www.faqs.org/faqs/unix-faq/faq/part4/section-7.html

Good luck.

Monex wrote:
> Hi,
>
> as far as I know it is not allowed to set suid bit for bash scripts. If
> you do this it gets ignored.
>
> As a workaround I would suggest to use sudo. You can configure sudo so
> that some commands don’t require a password. Look at the sudo manpage
> for more details.
>
> Hope this helps
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJLWzcrAAoJEF+XTK08PnB5PJUQAMDZLPsF1U1H2rUz8A/Y0LCm
tcZLEeOBp4/Cckh2RArceLxUSqh/6K9p8Or34ua649yqUuHtiKkRGJSm2Z7mvSmZ
NWRxRofkkVY7n7gNO39knDdZHqMpAzPYbbVoXWN97SligEKUwMtoq8cFL2keJ+tm
NjoHw+br+iJbSgaogBHJ72fRm+J/AMA5wg8wszqTPwM4yM26rCX7qqUuY1kO8oYh
lfXdf0Fz/eP/1I/jJVJ5/6NkfCFqQhniW16UPrWh2+/Q6naWMqRKxcSEhbiF/9/F
9qX+tyIfq2LCr6Fw/alLLtF2QRZNC42VQHERaGxmG5vivdAk4x61tpfphiI2eowv
is781+A4RKF9F+LV0n5pPGyE6yPmwyVWejxaEnsN+icCG2WeVYUBo/QNFi7nOfeN
UzfxATu0NANOwdzUHLsY8ONmqoMtv7hKcwlqes3SBfz9K4I6zbP9sPZuSxlmuLLL
e5hSSFgP10Hamd2jqxkSXKmktoynoKR+lhOyF3HW59EStFlMsAZv+u0yGUBdrNXj
UBB0YDA/NEOYCRgfHIlb8hOHa/NQJicC1jlbJNqXzHRZkaLHGzn4TYjN73SwX36H
+aEdLa8CY+dPy/4/zAejervk0ij6j7kjkYOzxUlH5IfRy9jmbu791lAHNMVnWKvf
6fKS6j86yyKi0TQDQg1/
=tsDW
-----END PGP SIGNATURE-----

Thanks.

I did exactly that;configure sudo for running usb_modeswitch without using password.