| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Hello,------------------------------------------------------------------------ ------
I am running a daemon on startup (so it's running as root), and I would
like to create files and set them to be owned by whomever is logged in
at the console. I wrote this code:
if ( GetFullPathname(&newSpec, pathname, 2 ) )
{
char* loginName = getlogin();
CopyPascalStringToC(pathname, pathname);
strcpy(command, "chown ");
if(loginName)
{
strcat(command, loginName);
strcat(command, " \"");
strcat(command, pathname);
strcat(command, "\"");
sprintf(errorCStr, "chown executing command: %s\n", command);
syslog(1, errorCStr);
err = system(command);
if(0 != err)
{
sprintf(errorCStr, "chown failed, err = %d.\n", err, theErr);
syslog(1, errorCStr);
}
}
When I check to see who owns the file using ls -l, sure enough it is
owned by the current console login, with -rw-r--r-- permissions, but
when I am logged in as that user, rm reports "permission denied" when I
try to delete the file. Can anyone explain why this is happening?
Also, how would I go about getting a list of the groups a user is a
member of, from a c program? I know I could do a system call "id -Gn
username" and write the output to a file, but is there a way to get the
list directly?
Thanks for your help,
Michael
_______________________________________________
darwin-userlevel mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-userlevel
Do not post admin requests to the list. They will be ignored.
| References: | |
| >chown problem (From: Michael Domino <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.