Reset permissions /
Hello guys,
I accidently executed a command in the wrong ssh-box, and this is bad. I executed the next command (as root, since I just have this server up): chown -R halfleven:gameservers * (it was ment to be executed on the gameserverfiles wich I copied with the root-user to the home-directory) I executed this on the root (/) of my harddisk, so it's messed up. Next I did a chown to root (due security issues), but this wasn't a perfect sollution (screen doesn't work anymore, lot's of my permissions are messed up, ...) I only can access the server remotly, but I have a HP webpanel where I can enter the serverconsole (a virtual keyboard and monitor attached to the server). Any sollutions for this problem? I hope it's possible to restore everything... BTW, I'm working with Debian Etch (latest release) Thanks a lot, Wim Mariën //edit: in mean time, I entered this command: chmod -R a+rx bin/ opt/ sbin/ sys/ usr/ var/ chmod 777 /var (the last command can be stupid; I know that; but it was my last sollution to get it work) is it still secure enough? I will be the only person on the server (or maybe I'll give an account to a friend of me...) |
Do you have access to another system running Debian Etch that you can get the correct permissions off of? If so, we can set you up with a small script to run on that system to collect the proper ownerships/permissions and store them in a file that you can then move to the corrupted system. The correct ownerships/permissions can then be extracted and applied to that system.
Let me know, Forrest |
Well I always can install a virtual machine on my desktop (My old pc near my is my home-server, but it's debian 3.1. I guess this is not good enough?).
I guess I will be able to do this with PHP, won't I? Or do you allready have this script (if not, I'll write it on my own and publish it for other stupid system administrators :-)) |
Debian 3.1 would probably work ~95%. As far as the scripts go, I would use /bin/sh, but that is me.
|
Well, I created this little PHP script, which will work fine I guess.
However, the server is to important to mess up, so I will install a virtual server tomorrow (it's now 11PM, I'm back tomorrow @ 1PM or so) Code:
<?php chown -R user:group /exact/path/to/file/or/dir chown -R user:group /exact/path/to/file2/or/dir3 chown -R user:group /exact/path/to/file3/or/dir3 Wim Mariën |
Not as good with PHP, but I can tell that you will need to output the filename with quotes around it (to handle special characters and spaces. Also, you want to avoid some top level directories (like proc and dev). The following script will make the chown changes for the server if run on a default layout (fix the list of GOODDIRs to match your system:
Code:
#!/bin/sh Forrest |
I updated the script to take care of permissions. Any sticky bits will just give a warning as trying to figure out which permission it went with was a bit much (maybe a future version).
Code:
#!/bin/sh Forrest |
In the GOODDIR line you have 2 empty strings (either side of "sys") in both your initial and revised script. Doesn't make sense to me, but I'm no acclaimed scriptwriter ;) If these are correct, would you mind explaining what they are for?
|
awk: line 2: function strtonum never defined
Fixed by installing gawk. (just a post for users who do the same stupid thing in the future and get the same error) |
Dutch Master, that was a typo on a line I never tested. I had a copy of that line with only "tmp" defined to test with. Good eye, they don't belong. I'll edit the script and leave this as proof that you weren't hallucinating about the errors. :)
Forrest |
Does the debian system have a verify option where you can compare ownerships & permissions of your system with the permissions stored in the package?
Or do you have a backup that can be listed including permissions? such as "tar --list --verbose -f backup.tar" |
All times are GMT -5. The time now is 04:17 PM. |