Re: system command returning unknown error.
Re: system command returning unknown error.
- Subject: Re: system command returning unknown error.
- From: "matt jaffa" <email@hidden>
- Date: Wed, 14 Jun 2006 14:21:30 -0600
nvm got it working, I am really really missing it today. So operation
not permitted errno 1 has to do with permissions. Found out where we
were losing root permissions.
Thanks for the replys and help.
On 6/14/06, John Francini <email@hidden> wrote:
I'm not sure what's going on then, unless it has something to do with
requiring the real UID to be root rather than 'merely' the effective
UID. But then again, I may be talking through my hat.
Anyone else got an idea?
John Francini
On 14 Jun 2006, at 16:09, matt jaffa wrote:
> I tried to switch to using the reboot(int howto) command instead of
> system("/sbin/shutdown -r now") and I am getting back errno = 1,
> operation not permitted. I am running as root since I set setuid(0)
> before running the command. And the permissions on my commandline app
> allow me to setuid(0) as bad as some might think, this is the only way
> this tool will work for our product.
>
> But operation not permitted hasn't anything to do with priviliges I
> think. Cause I can go to the terminal and do a sudo /sbin/reboot just
> fine.
>
> On 6/14/06, matt jaffa <email@hidden> wrote:
>> Yes I am running as a root process.
>>
>>
>>
>> On 6/14/06, John Francini <email@hidden> wrote:
>> > /sbin/shutdown must be run by root. Running as a user with
>> > Administrator privilege is not sufficient.
>> >
>> > Is the parent process running as root or setuid to root?
>> >
>> > John
>> >
>> >
>> > On 14 Jun 2006, at 15:15, matt jaffa wrote:
>> >
>> > > Ok so I admit I read it wrong regarding the return status,
>> always got
>> > > 0 for everything else I executed so I assumed 0 good and only
>> -1 was
>> > > returned if bad.
>> > >
>> > > soo I am getting 32256 by executing
>> system("/sbin/shutdown -r
>> > > now");
>> > >
>> > >
>> > > On 6/14/06, John Francini <email@hidden > wrote:
>> > >> Rather than having people say "Yes, I did, No, I didn't",
>> let's cut
>> > >> the Gordian knot.
>> > >>
>> > >> The man page on 10.4.6 reads as follows:
>> > >>
>> > >> SYSTEM(3) BSD Library Functions Manual
>> > >> SYSTEM(3)
>> > >>
>> > >> NAME
>> > >> system -- pass a command to the shell
>> > >>
>> > >> LIBRARY
>> > >> Standard C Library (libc, -lc)
>> > >>
>> > >> SYNOPSIS
>> > >> #include <stdlib.h>
>> > >>
>> > >> int
>> > >> system(const char *string);
>> > >>
>> > >> DESCRIPTION
>> > >> The system() function hands the argument string to the
>> command
>> > >> inter-
>> > >> preter sh(1). The calling process waits for the shell to
>> > >> finish execut-
>> > >> ing the command, ignoring SIGINT and SIGQUIT, and blocking
>> > >> SIGCHLD.
>> > >>
>> > >> If string is a NULL pointer, system() will return non-
>> zero if
>> > >> the command
>> > >> interpreter sh(1) is available, and zero if it is not.
>> > >>
>> > >> The system() function returns the exit status of the
>> shell as
>> > >> returned by
>> > >> waitpid(2), or -1 if an error occurred when invoking
>> fork(2) or
>> > >> waitpid(2). A return value of 127 means the execution
>> of the
>> > >> shell
>> > >> failed.
>> > >>
>> > >> SEE ALSO
>> > >> sh(1), execve(2), fork(2), waitpid(2), popen(3)
>> > >>
>> > >> STANDARDS
>> > >> The system() function conforms to ISO/IEC 9899:1990 (``ISO
>> > >> C90'') and is
>> > >> expected to be IEEE Std 1003.2 (``POSIX.2'') compatible.
>> > >>
>> > >> BSD June 4,
>> > >> 1993 BSD
>> > >>
>> > >> Given this, your error of 32256 is being generated by the
>> shell --
>> > >> meaning the command you ran exited with that status.
>> > >>
>> > >> It might be more helpful if you can give a concise example of
>> the
>> > >> specific code that is failing.
>> > >>
>> > >> John Francini
>> > >>
>> > >>
>> > >>
>> > >>
>> > >>
>> > >> On 14 Jun 2006, at 14:12, Matthew Jaffa wrote:
>> > >>
>> > >> > Yes I read the man page, and it says -1 if not successful,
>> 0 if
>> > >> > successful, and returns non-zero if the command you pass in is
>> > >> > NULL, but I know I didn't pass in null cause I log it right
>> before
>> > >> > I execute the command.
>> > >> >
>> > >> > Matt
>> > >> >
>> > >> >
>> > >> >> From: "Justin C. Walker" < email@hidden>
>> > >> >> To: "email@hidden list" <darwin-
>> email@hidden >
>> > >> >> Subject: Re: system command returning unknown error.
>> > >> >> Date: Wed, 14 Jun 2006 10:38:46 -0700
>> > >> >>
>> > >> >>
>> > >> >> On Jun 14, 2006, at 10:30 , matt jaffa wrote:
>> > >> >>
>> > >> >>> Hi,
>> > >> >>>
>> > >> >>> I am calling system(char* command) in my .cpp file. But
>> this is
>> > >> >>> returning
>> > >> >>> error 32256. This error no. is not documented so I don't
>> know
>> > >> >>> why it is not
>> > >> >>> working.
>> > >> >>> Anyone seen this error number before and know what it means.
>> > >> >>
>> > >> >> Did you read the man page for the 'system()' call?
>> > >> >>
>> > >> >> Regards,
>> > >> >>
>> > >> >> Justin
>> > >> >>
>> > >> >> --
>> > >> >> Justin C. Walker, Curmudgeon at Large
>> > >> >> Director
>> > >> >> Institute for the Enhancement of the Director's Income
>> > >> >> -----------
>> > >> >> Nobody knows the trouble I've been
>> > >> >> -----------
>> > >> >>
>> > >> >>
>> > >> >>
>> > >> >> _______________________________________________
>> > >> >> Do not post admin requests to the list. They will be ignored.
>> > >> >> Darwin-dev mailing list ( email@hidden)
>> > >> >> Help/Unsubscribe/Update your Subscription:
>> > >> >>
>> > >> 40msn.com
>> > >> >>
>> > >> >> This email sent to email@hidden
>> > >> >
>> > >> >
>> > >> > _______________________________________________
>> > >> > Do not post admin requests to the list. They will be ignored.
>> > >> > Darwin-dev mailing list ( email@hidden)
>> > >> > Help/Unsubscribe/Update your Subscription:
>> > >> >
>> > >> 40mac.com
>> > >> >
>> > >> > This email sent to email@hidden
>> > >>
>> > >> _______________________________________________
>> > >> Do not post admin requests to the list. They will be ignored.
>> > >> Darwin-dev mailing list ( email@hidden)
>> > >> Help/Unsubscribe/Update your Subscription:
>> > >>
>> > >>
>> > >> This email sent to email@hidden
>> > >>
>> >
>> >
>>
>>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden