Operating System - HP-UX
1822320 Members
5482 Online
109642 Solutions
New Discussion юеВ

chmod -R 777 from / as root

 
SOLVED
Go to solution
thanga
Occasional Advisor

chmod -R 777 from / as root

Hi all,
By mistake chmode -R 777 from / as root was executed. As a result now ,all the files in all the directories have the permission 777.
Hence any user unknowingly or maliciously might delete it. Another problem is that some files had the SetUid bit set on them and some directories had the sticky bit set on them. Now due to chmod command , they are all lost.
Is there any way to recover to the previous state atleast the system related files and directories like /dev, /etc, /stand, /sbin , / etc. If anybody can help me in recovering the permissions to the previous state, it would be grateful.

Thanks and Regards
Thanga
3 REPLIES 3
Edward Sedgemore
Trusted Contributor
Solution

Re: chmod -R 777 from / as root


Almost all the permissions for your system directories and files are held in Software Distributor. There should be some complex SD command to recommit these permissions but Im loathe if I can remember it.

Anyway, you need to go thru the INFO files for each product under /var/adm/sw/products and check the permissions and then with a simple script you can reset them.

eg. swlist -l bundle shows your main installed bundle should be; HPUXEng64RT (or 32RT). If you do an swlist HPUXEng64RT it lists all the main products which belong to your HP-UX install, eg. OS-CORE, X11, Xserver, etc etc.
For each of these you need to do the following.

Eg. for the main OS-CORE product;
cd /var/adm/sw/products/OS-Core
In there you will see around 30 subdirs for each of the OS-Core filesets. For each one do the following;
cd (eg. cd UX-CORE)
In there you will see several files, the one you want is called INFO.
If you do the following command on the INFO File;
grep -e path -e mode INFO
This will list all files and dirs (starting with the dir / ) and their permissions. path is first, mode is after it. Further down the grep will list lots of paths before it gets to a mode, this means all the above paths have the same mode.
Then you should be able to write a script to process this and reset all your permissions. Dont forget to do all the subdirs under /var/adm/sw/products/OS-Core and above for all other installed software.

This is going to take you some time, it may be quicker to restore from backup! But at least all the permissions are there so you can choose which you want to reset or not, I would at least do ALL of OS-Core/*
thanga
Occasional Advisor

Re: chmod -R 777 from / as root

Hi Edward,

Thanks a lot for your help.
I wrote a generic awk script to get the path and mode permissions and execute the chmod command. Is there any command provided by HP to revert back these permissions.
Thanx a lot for your help. It was very helpful.

Regards
Thanga
David Peacock
Frequent Advisor

Re: chmod -R 777 from / as root

We had the same problem a year ago.

After many heroic efforts that failed we finally retored from a 2 week old make_recovery
tape. This worked. But I had to update the OS
with changes since the tape had been made.
veni, vidi, vmstat