Re: system command returning unknown error.
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=tkHPeftHJfZrHTPpAZFwC4KxhlPqO+2rD7QB9ytLk1K/2Gw/I0TrR0uWHdODNZVmshDf5xHtWZVTFaLrjdrclr7xy8bdziLtksazjtRZE8gIDPvf0FGhmgX6a+SRzgF1P13kPGI1Ty3GwAMSLD8GM1MM4DdiL8vYL6Vgm5o9QNg= 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. 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 <mjaffa@gmail.com> wrote:
Yes I am running as a root process.
On 6/14/06, John Francini <francini@mac.com> 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 <francini@mac.com > 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" < justin@mac.com> > To: "darwin-dev@lists.apple.com list" <darwin- dev@lists.apple.com > > 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 ( Darwin-dev@lists.apple.com) > Help/Unsubscribe/Update your Subscription: > http://lists.apple.com/mailman/options/darwin-dev/mtjaffa% 40msn.com > > This email sent to mtjaffa@msn.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list ( Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/francini% 40mac.com
This email sent to francini@mac.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list ( Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/mjaffa%40gmail.com
This email sent to mjaffa@gmail.com
Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... On 6/14/06, John Francini <francini@mac.com> wrote: This email sent to site_archiver@lists.apple.com
participants (1)
-
matt jaffa