Results 1 to 20 of 20
  1. #1
    Join Date
    Mar 2004
    Location
    Toronto
    Posts
    51

    prevent users from deleting a directory in their account?

    Basically.. what the topic asks is what I am attempting to achieve.

    I have access_log being written to a "logs" directory in the user's account.

    I want to remove the ability for THEM to delete that directory...is this possible and how could I achieve this?

    Any thoughts?

    Thanks!

    Aaron

  2. #2
    Join Date
    Feb 2002
    Posts
    3,727
    You could try changing ownership of that directory to root?
    Have you Floble'd today?

  3. #3
    Any directory/file written by the server (root account) can not be deleted by your users, unless the log directory can be access by the website (in html folder), then the user can write a php script to delete it, as for php scripts run as root users. Hope this helps ya.
    To assume perfection is merely a display of ignorance.

  4. #4
    Join Date
    Mar 2004
    Location
    Toronto
    Posts
    51
    Well... lets explore this.

    If the user HAPPENED to delete the /home/username/logs/ directory...what is the worst that could happen?

    When my logrotate script is executed, it will gracefully restart apache which will call an error because the Directory does not exist. Everytime someon accesses the site... an error will be produced because the directory and file doesn't exist.

    Does that cause undue stress/overload on the server itself?

    A

  5. #5
    is the log directory accessible through a browser or is it in a directory behind the mainwebsite-html directory?
    To assume perfection is merely a display of ignorance.

  6. #6
    Join Date
    Mar 2004
    Location
    Toronto
    Posts
    51
    Originally posted by HotLinkHost
    is the log directory accessible through a browser or is it in a directory behind the mainwebsite-html directory?
    Looks like this:

    etc
    logs
    mail
    public_ftp
    public_html
    tmp
    www -> public_html


    So it's outside the main website directory. However, I guess it can be readable because webstats can be configured to read from it.

    A

  7. #7
    Well, the directory seems to be created by the root admin for the (dedicated?) server. If so no user account should be able to delete it as they are not above the root user of the server. PhP scripts can run as the root user for the server but as it isn't a directory accessible through a web browser (www.yoursite.com/logs/) no php scripts can touch it.
    To assume perfection is merely a display of ignorance.

  8. #8
    Join Date
    Mar 2004
    Location
    Toronto
    Posts
    51
    Here's the ls -l of the logs directory:

    drwxr-xr-x 2 martekho martekho 4096 Mar 25 14:54 logs

    A

  9. #9
    Join Date
    Jun 2003
    Posts
    673
    The ownership/permissions of the "logs" directory only affect whether users can rename/delete/create files inside of it. If you want to prevent them from deleting the "logs" directory, change the permissions of their home directory so it is not writable by them. This will also prevent them from creating new directories at the top level of their home directory, though, and it might break other things as well.

  10. #10
    Join Date
    Apr 2003
    Location
    UK
    Posts
    2,560
    set it undeletable with chattr?

    [email protected]:~# mkdir test
    [email protected]:~# chattr +a test
    [email protected]:~# rm -rf test
    rm: cannot remove directory `test': Operation not permitted
    [email protected]:~# chattr -a test
    [email protected]:~# rm -rf test

  11. #11
    Join Date
    Jun 2003
    Posts
    673
    You probably don't want to set the 'a' attribute on the logs directory, as files inside of it will not be able to be deleted or renamed, which will break the log rotation stuff. Setting it on their home directory might do the trick, though (that's what you meant, I assume).

  12. #12
    Join Date
    Mar 2003
    Location
    Rio de Janeiro - Brazil
    Posts
    291
    Humm...

    PHP should NOT run as root, and keeping files owned by root and with write permission in the user's directories is usually a bad idea.

    Take a look at chattr (man chattr), you may find out something.

  13. #13
    Your best bet is to stick the logs directory one level deeper (if your rotation software can support that), and set the immutable bit on the directory above it as recommended by Slidey.

  14. #14
    Join Date
    Jun 2003
    Posts
    673
    Just to clarify, it's not immutable, it's "append-only". If possible, I would recommend using normal Unix permissions instead, as chattr will only work on ext2/3 filesystems, and if you set any flags with it, they will not be included in your backups.

  15. #15
    Join Date
    Mar 2003
    Location
    Rio de Janeiro - Brazil
    Posts
    291
    Originally posted by dan_erat
    Just to clarify, it's not immutable, it's "append-only". If possible, I would recommend using normal Unix permissions instead, as chattr will only work on ext2/3 filesystems, and if you set any flags with it, they will not be included in your backups.
    you can mark it to be undeletable. If the point is to avoid users being able to delete it, may be an option.

  16. #16
    Join Date
    Aug 2002
    Location
    UK
    Posts
    846
    Originally posted by HotLinkHost
    Any directory/file written by the server (root account) can not be deleted by your users, unless the log directory can be access by the website (in html folder), then the user can write a php script to delete it, as for php scripts run as root users. Hope this helps ya.
    No they don't, PHP runs as nobody, not root, if your PHP runs as root I will laugh at you and likely root your box inside 10 seconds.

  17. #17
    For fiel access php runs with same permissions as root.
    To assume perfection is merely a display of ignorance.

  18. #18
    Join Date
    Mar 2003
    Location
    Rio de Janeiro - Brazil
    Posts
    291
    Originally posted by HotLinkHost
    For fiel access php runs with same permissions as root.
    No, it doesn't. At least it shouldn't

    If php scripts run as root in your system, get worried...

  19. #19
    Join Date
    Aug 2002
    Location
    UK
    Posts
    846
    Originally posted by rsferreira
    No, it doesn't. At least it shouldn't

    If php scripts run as root in your system, get worried...
    No, if they run as root, give me the IP, I need a server of my own atm

  20. #20
    Join Date
    Oct 2002
    Location
    MO, USA
    Posts
    1,104
    PhP scripts can run as the root user for the server but as it isn't a directory accessible through a web browser (www.yoursite.com/logs/) no php scripts can touch it.
    Even run as the default user, some php scripts can do quite a bit including viewing the root directory of the server which is outside of the http website path.

Posting Permissions

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