writing to directory with permission 755

Discussion in 'Apache' started by pthona, Feb 26, 2007.

Thread Status:
Not open for further replies.
  1. #1
    I am not able to write to a directory who permissions are 755 with the php script.

    And the only way to write to that directory is via changing the mod to 777. and i believe that is not a secure option.

    Do you know how can write to a directory with permission 755. Actually i am uploading the images to that.
     
    pthona, Feb 26, 2007 IP
  2. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #2
    You can try using setuid() unix call on your PHP. I think it's posix_setuid(), but I have not tried, and maybe it's not a secure action.
     
    ajsa52, Feb 26, 2007 IP
  3. Mxhub

    Mxhub Active Member

    Messages:
    474
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #3
    it had to be set to 777. minimum 666. no way you can upload to directory with 755. just make sure your script allow only image files.
     
    Mxhub, Feb 26, 2007 IP
  4. rootbinbash

    rootbinbash Peon

    Messages:
    2,198
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    0
    #4

    you cant write because the httpd server you are using runs as user 'nobody',you have to change the directory permissions to 766( or 777) or you can disable httpd running as user nobody (dont do this :D )
     
    rootbinbash, Feb 26, 2007 IP
  5. tespio

    tespio Peon

    Messages:
    16
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Or .. you can change the folder permissions to be the same as httpd user. As a side note httpd running as nobody is a bit insecure afaik. I am however aquinted with Debian way of setup where apache is running as www-data user.

    Basic Linux tip looks like:

    chown httpuser.httpduser directory
    then
    chmod 755 directory (in case it wasnt done already)
     
    tespio, Feb 26, 2007 IP
    mushroom likes this.
  6. pthona

    pthona Active Member

    Messages:
    327
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #6
    okey thanks for all responses. I have changed it to 755 and made sure that nothing other then images can be uploaded to that folder. Thanks
     
    pthona, Feb 27, 2007 IP
Thread Status:
Not open for further replies.