Re: correcting permission on Informix
Posted in 1995
Any such system has to be based on the permissions listed in the *files file-lists in $INFORMIXDIR/etc. I attach a shell archive of my script ixsetperms which can be used (by root) to fix up the permissions on a $INFORMIXDIR. It actually generates a list of commands to be executed to fix the permissions. You can actually fix the permissions by piping the output into the shell (Bourne, Korn or C or ...). Note that it uses a special command, fl, which lists file attributes in a convenient format (somewhat like ls). You will need to simulate that command, and the painful bit of using ls is converting the permissions string into an argument that can be used by chmod. The fl option -o means print owner name, -g print group name, -Q print octal permissions, -n means don't print file name, and -D means list directory information rather than files in directory (like ls -d). The use of sort and nawk at the end is to reduce the number of chmod etc commands executed. It probably doesn't make all that much performance difference if you remove the sort and nawk parts of ixsetperms. I hope this is some help... Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> >Date: Thu, 13 Apr 1995 19:07:02 +0200 (MET DST) >From: ant01 <ant01@margherita.record.unipd.it> >X-Informix-List-Id: <list.5992> > >As it is known, in the directory with the Informix's program files, there is >a necessity that some of these files must have particular rights and/or owner, >group, etc... > >If the permissions or the ownership of these particular files change for one >reason or another, the system stops being operational. > >Is there any method which enables us to restore the correct permissions and/or >ownership of these special files, if by mistake there is a change on them, >without having to re-install the entire environment ? : "@(#)shar.sh 1.9" #! /bin/sh # # This is a shell archive. # Remove everything above this line and run sh on the resulting file. # If this archive is complete, you will see this message at the end: # "All files extracted" # # Created: Fri Apr 14 09:33:00 PDT 1995 by johnl at Informix Software Ltd. # Files archived in this archive: # ixsetperm # #-------------------- if [ -f ixsetperm -a "$1" != "-c" ] then echo shar: ixsetperm already exists else echo 'x - ixsetperm (1225 characters)' sed -e 's/^X//' >ixsetperm <<'SHAR-EOF' X: "@(#)ixsetperm.sh 1.2 95/03/31" X# X# Generate script to set permissions on Informix software X Xcd $INFORMIXDIR X Xsed -e 's/#.*//' \\ X -e '/^[ ]*$/d' \\ X -e '/^PRODUCT/d' \\ X ${INFORMIXDIR:-/usr/informix}/etc/*files | Xsort -u | Xwhile read file owner group perms brand version Xdo X if [ ! -f $file -a ! -d $file ] X then X # File/directory no longer present (or has been moved) X continue X fi X set -- `fl -ogQnD $file` X aowner=$1 X agroup=$2 X aperms=$3 X if [ $aowner != $owner ] X then echo chown $owner $file X fi X if [ $agroup != $group ] X then echo chgrp $group $file X fi X if [ $aperms -ne $perms ] X then echo chmod $perms $file X fi Xdone | Xsort | Xnawk '# Xfunction print_cmd(cmd, arg, list, array, n, i) { X if (length(list) < 128) X print cmd " " arg " " list; X else X { X n = split(list, array) X print "xargs " cmd " " arg " <<!"; X for (i = 1; i < n; i++) X print array[i]; X print "!" X } X} X{ X if ($1 != save_cmd) X { X if (save_cmd != "") X print_cmd(save_cmd, save_arg, files); X save_cmd = $1; X save_arg = $2; X files = ""; X } X else if ($2 != save_arg) X { X print_cmd(save_cmd, save_arg, files); X save_arg = $2; X files = ""; X } X files = files " " $3 X} XEND { X if (files != "") X print_cmd(save_cmd, save_arg, files); X} X#' SHAR-EOF chmod 775 ixsetperm if [ `wc -c <ixsetperm` -ne 1225 ] then echo shar: ixsetperm unpacked with wrong size fi # end of overwriting check fi echo All files extracted exit 0