Skip to content
Permalink
b8235dda58
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
32 lines (29 sloc) 548 Bytes
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc,char **argv) {
uid_t uid;
char *end;
int status;
if (argc<3) {
fprintf(stderr,"usage: %s uid cmd...\n",argv[0]);
exit(1);
}
uid=strtoul(argv[1],&end,10);
if (end==argv[1] || *end != '\0') {
fprintf(stderr,"%s: %s: invalid uid\n",argv[0],argv[1]);
exit(1);
}
status=setuid(uid);
if (status==-1) {
perror(argv[0]);
exit(1);
}
status=execvp(argv[2],&argv[2]);
if (status==-1) {
perror(argv[0]);
exit(1);
}
exit(0);
}