![]() |
|
|
|
|
|||||||
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
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);
but in the this programm It can not. Last edited by Yogesh Sawant; 05-05-2008 at 06:27 AM. Reason: added code tags |
| Forum Sponsor | ||
|
|
|
|||
|
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))
{
................
}
}
|
|||
| Google UNIX.COM |
| Thread Tools | |
| Display Modes | |
|
|