As an experiment in playing with the suid bit, I tried writing a script to run apt-get update from a bash script, and then set the suid bit on it, so I could just run ~/update or something.
apt-get update could be anything here - some program that listens on a privileged socket, or writes to / or anything else that has to be run as root. Please don't latch on to apt-get update here.
First try is this, which didn't work, failing with can't get lock, are you root?. The reason would seem to be Setuid bit seems to have no effect on bash.
#!/bin/bash
apt-get update
So I thought I'd try to bypass the shell, but this didn't work either, for the same reason.
#!/usr/bin/perl
system("apt-get", "update").
I've got the permissions correct (afaik) - sudo chmod 4755 ~/update.
Have I misunderstood setuid, or am I just missing something simple?