Find the answer to your Linux question:
Results 1 to 4 of 4
Hey guys, I'm running a script which calls a compiled C program called cu. I'm logged in as root and when I run it the C program falls over with ...
  1. #1
    Just Joined!
    Join Date
    Sep 2007
    Posts
    5

    Permission denied even as root

    Hey guys,

    I'm running a script which calls a compiled C program called cu. I'm logged in as root and when I run it the C program falls over with Permission denied when trying to mkdir /usr/spool . I was able to manually create the spool directory but now the program is trying to create files in the spool directory and still has permission denied.

    Why would I get permission denied if I'm running as root ? I also did a chmod 777 on both the script and cu program. I run the script with
    sh ./script.sh

    Any help would be much appreciated.
    Thanks

  2. #2
    Linux Newbie danielsmw's Avatar
    Join Date
    Nov 2006
    Location
    Clemson, SC / Charleston, SC
    Posts
    110
    Have you ensured that your script and cu both have root as their effective uid's? Not sure why they wouldn't, but it's worth checking.

  3. #3
    Just Joined!
    Join Date
    Sep 2007
    Posts
    5
    I think they have, I did a "ls -al" and the names beside them are root, is this the right way to check the uid ?

    Well just after getting the script to work, I manually did
    "chmod -R 777 /usr/spool/"
    which meant that when the program went to write to that directory it definitly had permissions. I know this is more a hack than a solution but I got the script to work which is what I really wanted.

    Nonetheless if anyone knows why the root permissions didn't carry through to the program that was called by the script i'd still like to know.

  4. #4
    Linux Newbie danielsmw's Avatar
    Join Date
    Nov 2006
    Location
    Clemson, SC / Charleston, SC
    Posts
    110
    I'm glad you got it fixed. I know it's not "fixed", but it was a good enough little hack to get the job done. If you're curious, trying making calls to getuid() and geteuid() in your program and see what they give you. To make sure your program is running effectively as root, put in seteuid(0).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...