I need a script that can be run as a user that will modify the MAC address of eth0
. I have come up with the following script:
#!/bin/bash
/etc/init.d/networking stop
ifconfig eth0 hw ether 00:50:56:98:00:19
/etc/init.d/networking start
I set setuid permission and assigned it to root:
-rwsr-xr-x 1 root root 110 May 24 14:22 ChangeMac.sh
but it still would give me the following output when I run it as user:
$ ./ChangeMac.sh
stop: Rejected send message, 1 matched rules; type="method_call", sender=":1.100" (uid=1000 pid=6746 comm="stop networking ") interface="com.ubuntu.Upstart0_6.Job" member="Stop" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")
SIOCSIFHWADDR: Operation not permitted
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.103" (uid=1000 pid=6753 comm="start networking ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")
Why is this? How can I make it so that a user can invoke it but it gets executed as root?
Operation not permitted
errors. – stdcerr May 24 '17 at 22:23