#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2010
    Posts
    35
    Rep Power
    5

    Mkdir: cannot create directory `/builds/somedir/': Permission denied


    Hi,


    I am trying to run a shell script which contains an mkdir command as part of the execution. The script fails with the following error:
    mkdir: cannot create directory `/builds/somedir/': Permission denied

    The user running the script is 'harry' and belongs to group 'school'. The target directory is owned by another user ‘sally’.

    ls -ld /builds/somedir/
    drwxr-xr-x+ 14 sally bin 1024 May 31 18:01 /builds/somedir/

    The above path (/builds/somedir/) is a Samba share.

    To make it work, I tried few things but to no avail:
    --------------------------------------------------
    1. setfacl -d -m u:harry:rwx /builds/somedir
    setfacl -d -m g:school:rwx /builds/somedir

    2. Added following entry in /etc/sudoers file
    # User privilege specification
    harry ALL=(ALL) ALL
    --------------------------------------------------

    After making these changes, I tried running the mkdir command manually also but no luck.

    The OS is GNU\Linux.

    There is one thing weird that I just noticed: even with root user, I was not able to create directory in the given path. Does it has anything to do with Samba share?

    After noticing this behavior, I removed the above entry from sudoers file, and instead added the following but still no luck.
    -----------------------
    harry ALL=(sally) ALL
    -----------------------

    Any ideas\inputs?


    Regards,
    Gaurav
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2010
    Posts
    35
    Rep Power
    5
    To update, things are working now. I think i now know what blunder i was committing: i was running this script as follows:
    Code:
    sudo sh scriptname.sh
    'su' must be assuming that my intended user is 'root', and since even root user was not able to create directory in the given path, the script was failing. When i changed it to the following, it worked:
    Code:
    sudo sally sh scriptname.sh

IMN logo majestic logo threadwatch logo seochat tools logo