source code of /small-scripts/setuidwrap
Last modified | |
Lines | 33 |
Parent directory Download CGIread sitemap Main page
Quick links: (none)
#!/bin/sh
if [ $# -ne 5 ]; then
echo "Usage: setuidwrap <wrapper> <wrappee> <user> <group> <mode>" \
> /dev/stderr
exit 1
fi
wrapper=$1
wrappee=$2
user=$3
group=$4
mode=$5
gcc -o ${wrapper} -x c - << _EOF_
#include <unistd.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
gid_t gid; uid_t uid;
gid = getegid();
uid = geteuid();
setresuid(uid, uid, uid); setfsuid(uid);
setresgid(gid, gid, gid); setfsgid(gid);
/* ¡You shall not pass, u 3117e f001! */
execv("${wrappee}", argv);
}
_EOF_
sudo chown ${user}:${group} ${wrapper}
sudo chmod ${mode} ${wrapper}