Dumb mistake chmod -R a+rw

Discussion in 'ISPConfig 3 Priority Support' started by pebkac, Oct 25, 2018.

  1. pebkac

    pebkac Member HowtoForge Supporter

    I mistakenly ran chmod -R a+rw web1/ on that web1 folder, meant to unprotect it momentarily to add some files in web1/

    How can I undo that command, as everything seems writable now, all directories are highlighted green.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Here is how the permissions of a website are set:

    Code:
    [email protected]:/var/www/test.tld# ls -la
    total 36
    drwxr-xr-x  9 root root    4096 Feb 27  2018 .
    drwxr-xr-x  4 root root    4096 Oct 18 15:50 ..
    drwxr-xr-x  2 web1 client0 4096 Feb 27  2018 cgi-bin
    drwxr-xr-x  2 root root    4096 Oct 24 11:46 log
    drwx--x---  2 web1 client0 4096 Oct  7 13:00 private
    drwx------  2 web1 client0 4096 Feb 27  2018 .ssh
    drwxr-xr-x  2 root root    4096 Feb 27  2018 ssl
    drwxrwxrwx  2 web1 client0 4096 Aug 15 01:19 tmp
    drwxr-x--x 14 web1 client0 4096 Feb 27  2018 web
     
  3. pebkac

    pebkac Member HowtoForge Supporter

    This is our web1

    drwxr-xr-x 12 root root 4.0K Oct 25 00:48 web1

    if I ran chmod -R o+rw web1/ would it undo the chmod -R a+rw web1/ ????
     
  4. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    No it won't. It wouldn't have any effect because "other" already has rw rights. You can use chmod -R o-rw to remove the rw rights for the user "other" (so not part of web1 user or client1 group).
    This won't restore the previous setting of the chmod of directories and files inside the web1 folder, but simply remove all rw access for "other". If files or dirs had rwxrwxrwx (777) before you executed your a+rw command, this will also have 774 if you remove the rw.
     
  5. pebkac

    pebkac Member HowtoForge Supporter

    Is it ok to leave it as is? Just throws me off seeing all the folders highlighted green.
     
  6. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    Not the best idea as every user has full access to all files and dirs in that web now by using e. g. perl scripts or php shell functions etc. in his own web.
     
  7. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    I'd recommend running
    chmod -R o-rw web1
    and see if there are any problems in that web afterwards.
     
  8. pebkac

    pebkac Member HowtoForge Supporter

    Ok, so would you suggest this as my best method at this point?
    chmod -R o-rw
     
  9. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    Yes, that's what I suggested.
     
  10. pebkac

    pebkac Member HowtoForge Supporter

    Seems to have worked, everything looks good. Thanks!
     
  11. pebkac

    pebkac Member HowtoForge Supporter

    Now when we connect to our FTP, nothing is shown (no directories or files), just blank. Would anything we did here have anything to do with it???
     
  12. pebkac

    pebkac Member HowtoForge Supporter

    Looking at what till posted above with what the permissions should look like, I see ours do not match that.

    Code:
    [email protected]:/var/www/clients/client1/web1# ls -lh
    total 56K
    -rw-r-----  1 web1 client1  487 Oct 25 00:21 amazon_ses.php
    drwxrwx--x  2 web1 client1 4.0K Sep  9  2015 cgi-bin
    -rw-r-----  1 web1 client1  691 Oct 25 00:21 db.php
    -rw-r-----  1 web1 client1  451 Oct 25 00:21 email_send_config.php
    drwxrwx---  3 web1 client1 4.0K Sep 17  2016 home
    drwxrwxr-x  2 root root    4.0K Oct 25 17:01 log
    drwxrwx---  2 web1 client1 4.0K Sep  9  2015 private
    -rw-r-----  1 web1 client1 1.3K Oct 25 01:17 @server_define.php
    drwxrwx--x  2 root root    4.0K Aug  5 16:59 ssl
    drwxrwx--x  3 root root    4.0K Sep 20 10:34 subdomains
    drwxrwx---  2 web1 client1 4.0K Oct 25 19:44 tmp
    -rw-r-----  1 web1 client1  358 Oct 25 00:21 @version_number.php
    drwxrwx--x 28 web1 client1 4.0K Oct 24 23:08 web
    drwxrwx---  2 web1 client1 4.0K Sep  9  2015 webdav
    
     
  13. pebkac

    pebkac Member HowtoForge Supporter

    and here is what web1/ permissions are.

    Code:
    drwxr-x--x 12 root root 4.0K Oct 25 00:48 web1
     
  14. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Do you now have backups so you can restore the files if another mistake happens?
    If you have in addition to chmod run chown, use now chown to correct the file and directory owner and group owner.
     

Share This Page