View Single Post
xfirestorm
Member
Join Date: Mar 2012
Old 03-07-2013 , 07:04   Re: Protecting your server!
Reply With Quote #65

Don't know if this has been mentioned in those 7 pages, but you have an error at setting permissions in linux.

If you chmod 644 a dir, the dir will no longer be accessible by anyone. Dirs in linux need execute permissions for it to be accessible.

Example:
PHP Code:
[cserv@tantive ~]$ mkdir test
[cserv@tantive ~]$ touch test/test.sh
[cserv@tantive ~]$ echo "Hello world" test/test.sh
[cserv@tantive ~]$ cd test/
[
cserv@tantive test]$ ls
test
.sh
[cserv@tantive test]$ cd ..
[
cserv@tantive ~]$ cat test/test.sh
Hello world
[cserv@tantive ~]$ chmod 644 test
[cserv@tantive ~]$ cd test
-bashcdtestPermission denied
[cserv@tantive ~]$ cat test/test.sh
cat
test/test.shPermission denied
[cserv@tantive ~]$ rm -rf test
rm
cannot remove `test/test.sh': Permission denied
[cserv@tantive ~]$ chmod 755 test/
[cserv@tantive ~]$ rm -rf test
[cserv@tantive ~]$ 
What I would suggest, is make two users:
servrun (runs the server)
servupd (updates the server)
Then, the magic, so you don't fux up your execute permissions on dirs:
PHP Code:
chown -R servupd:servrun /path/to/server/
chmod -R g-w+/path/to/server/
chmod -R g+/path/to/server/install_dir/mod/<the dirs that need write permissionslogs,cache,addons/sourcemod/logs...> 
This way servupd user will have write permissions to the whole server install, so if you run your update script with that user you wont have trouble updating it, and the user that's running it will only have permissions to write in those dirs that you give it perms in the last command, plus you wont fux up your dirs in the process. ;)

If you want to further limit you can also remove all rights to "other" like so:
PHP Code:
chmod -R o-rwx /path/to/server
Just my 2 cents.

Last edited by xfirestorm; 03-07-2013 at 07:04.
xfirestorm is offline