Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restore Solaris Back To Default Permissions

Administration

Restore Solaris Back To Default Permissions

by  coffeysm  Posted    (Edited  )
Ever have someone perform a chmod 777 .*, chown -R *, etc... here is how to fix it without reinstalling or restoring from tape. You do need root access either locally or remotely though.

Almost all packages installed on a Solaris machine have their settings kept in one file. It is /var/sadm/install/contents.

Code:
cd /var/sadm/install

# Remove = signs and all /devices entries--

egrep -v "=|devices" contents > contents.new

# This command might fail stating "to many fields record number XXX" then you will have to vi contents.new, type :xxx and delete all the SUNW entries all we care about is fields 1,4,5, and 6.

awk '{print $1,$4,$5,$6}' contents.new > contents.new2

# Replace all white spaces with :
sed 's/ /:/g/' contents.new2 > contents.new

vi restore_perms

Create Script with the following:
#!/bin/sh
#########################################################
     for FILE in `cat /var/sadm/install/contents.new`
       do
                FNAME=`echo $FILE | awk -F: '{print $1}'`
                PERM=`echo $FILE | awk -F: '{print $2}'`
                OWNR=`echo $FILE | awk -F: '{print $3}'`
                GRP=`echo $FILE | awk -F: '{print $4}'`

                echo "chown $OWNR:$GRP $FNAME"
                  chown $OWNR:$GRP $FNAME
                echo "chmod $PERM $FNAME"
                  chmod $PERM $FNAME
       done
rm contents.new
# End
#########################################################

chmod 555 restore_perms

./restore_perms
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top