uid, euidの設定

#include < sys/types.h >
#include < unistd.h >

#include < stdio.h >

static void
printuid()
{
    printf("uid = %d euid = %d\n",
           (int)getuid(),(int)geteuid());
}

int main() {
    uid_t uid, euid;
    
    uid = getuid();
    euid=geteuid();
    
    printuid();
    
    if(setuid(uid) < 0){
        perror("setuid");
        return 1;
    }
    printuid();
    
    if(setuid(euid) < 0){
        perror("setuid");
        return 1;
    }
    printuid();
    
    return 0;
}