seteuid


 
Thread Tools Search this Thread
Top Forums Programming seteuid
# 1  
Old 05-05-2008
seteuid

I am writing programm that changes permission in the running;
I used at the command : seteuid();
the id of the process is changed but the permission not, why??

The program:
Code:
int status;
pid_t child = fork();
if (child == 0)
{
   seteuid(1200); // I checks that "1200" is exist id process
   execl("......");
}
else wait(&status);

In the Hand Mode :The process "1200" can to exec the command.
but in the this programm It can not.

Last edited by Yogesh Sawant; 05-05-2008 at 10:27 AM.. Reason: added code tags
# 2  
Old 05-05-2008
seteuid has different results when run by users with different privilege. Are you running this as root, for example? You should check the return value of seteuid() - it ggives a zero on success -1 on failure. Then check the value of errno, or something. ex:
Code:
#include <stdlib.h>
< other includes requitred for fork(), etc. ...>
void somefunc(void)
{
int status;
pid_t child = fork();

if (child == 0)
{
   status= seteuid(1200); // I checks that "1200" is exist id process
   if(!status)
       execl("......");
   else
   {
        perror("seteuid error");
        exit(1);
    }
   
    status=0;
    wait(&status);
    if(WIFEXITED(status))
    {
         ................
     } 
}

Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

seteuid access denied - openSSH installation

Hi, I have installed openssh in one of my windows servers following SUA community guidelines. I can successfully install and generate RSA DSA keys. But I cannot SSH to server from my Solaris machine. Below is the output from ssh -v <server>. Also I tried to SSH from the K-shell to localhost... (0 Replies)
Discussion started by: vkk
0 Replies
Login or Register to Ask a Question