Annotation of 43BSDReno/contrib/isode-beta/others/quipu/uips/manage/alias_chk, revision 1.1

1.1     ! root        1: #!/bin/sh
        !             2: 
        !             3: #Syntax:               alias_chk       <DN> 
        !             4: #
        !             5: # Think of better name. Tool designed to check recursively through tree for
        !             6: # bad aliases, and what is wrong.
        !             7: 
        !             8: # A file name for the bad aliases and diagnostics to be echoed into...
        !             9: Error_file=ALIAS_ERR_DETCTD
        !            10: 
        !            11: if test -z "$DISHPROC"
        !            12: then
        !            13:         DISHPROC="127.0.0.1 `expr $$ + 10000`"
        !            14:         export DISHPROC
        !            15: fi
        !            16: 
        !            17: if test $# = 0
        !            18: then
        !            19:        echo "We need an object. Aborting..."
        !            20:        exit
        !            21: fi
        !            22: 
        !            23: echo Binding...
        !            24: if test $# -gt 1
        !            25: then
        !            26:        bind -c $2
        !            27: else
        !            28:        bind
        !            29: fi
        !            30: 
        !            31: if ( moveto "$1" )
        !            32: then
        !            33:        echo -n
        !            34: else
        !            35:        echo "Does '$1' exist?"
        !            36:        exit
        !            37: fi
        !            38: 
        !            39: if test `compare -attribute "objectClass=alias" -print -dontdereferencealias 2>&1` = "TRUE"
        !            40: then
        !            41:        Entry=`squid | awk -F: '{if (NR == 2) print $2}' | sed -e "s/ @//"`
        !            42:        echo "Checking alias $Entry"
        !            43:        moveto ..
        !            44: 
        !            45:        # Check that all the 4 correct attributes are present, and no more.
        !            46:        showentry "$1" -dontderef -novalue -all -nosequence > tmp_entry_$$
        !            47:        if [ `grep -c "commonName" tmp_entry_$$` = 0 -o `grep -c "organizationName" tmp_entry_$$` = 0 -o `grep -c "organizationalUnitName" tmp_entry_$$` = 0 ]
        !            48:        then 
        !            49:                cat tmp_entry_$$ | sed -e "s/commonName//" > tmp_entry_$$2
        !            50:                mv tmp_entry_$$2 tmp_entry_$$
        !            51:                cat tmp_entry_$$ | sed -e "s/organizationName//" > tmp_entry_$$2
        !            52:                mv tmp_entry_$$2 tmp_entry_$$
        !            53:                cat tmp_entry_$$ | sed -e "s/organizationalUnitName//" > tmp_entry_$$2
        !            54:                mv tmp_entry_$$2 tmp_entry_$$
        !            55:        else
        !            56:                echo "Common Name attribute missing. Please add." | tee -a Error_file
        !            57:        fi
        !            58:        if test `grep -c "objectClass" tmp_entry_$$` = 0
        !            59:        then 
        !            60:                echo "objectClass attribute missing. Please add." | tee -a Error_file
        !            61:        else
        !            62:                cat tmp_entry_$$ | sed -e "s/objectClass//" > tmp_entry_$$2
        !            63:                mv tmp_entry_$$2 tmp_entry_$$
        !            64:        fi
        !            65:        if test `grep -c "accessControlList" tmp_entry_$$` = 0
        !            66:        then 
        !            67:                echo "ACL attribute missing. Please add." | tee -a Error_file
        !            68:        else
        !            69:                cat tmp_entry_$$ | sed -e "s/accessControlList//" > tmp_entry_$$2
        !            70:                mv tmp_entry_$$2 tmp_entry_$$
        !            71:        fi
        !            72:        if test `grep -c "aliasedObjectName" tmp_entry_$$` = 0
        !            73:        then 
        !            74:                echo "aliasedObjectName attribute missing. Please add." | tee -a Error_file
        !            75:                mv tmp_entry_$$2 tmp_entry_$$
        !            76:        else
        !            77:                cat tmp_entry_$$ | sed -e "s/aliasedObjectName//" > tmp_entry_$$2
        !            78:                mv tmp_entry_$$2 tmp_entry_$$
        !            79:        fi
        !            80:        cat tmp_entry_$$ | sed -e "s/lastModifiedBy//" | sed -e "s/lastModifiedTime//" > tmp_entry_$$2
        !            81:        mv tmp_entry_$$2 tmp_entry_$$
        !            82: 
        !            83:        # Number of words remaining = number of extra attributes.
        !            84:        if  test `cat tmp_entry_$$ | wc -w` != 0
        !            85:        then
        !            86:                echo "Un-necessary attributes present: Please remove" | tee -a Error_file
        !            87:                cat tmp_entry_$$ | awk '{if $0 != "" print $0}'
        !            88:        fi
        !            89: 
        !            90:        # Now to check that the entry "aliasObject" points to, 
        !            91:        # actually exists, and that it points back to this entry. 
        !            92: 
        !            93:        Object=`showentry "$1" -dontderef -type "aliasedObjectName" -edb -nokey -nocache`
        !            94:        showentry "@$Object" -type "seeAlso" -nokey -edb > tmp_entry_$$
        !            95:        if test -s tmp_entry_$$
        !            96:        then
        !            97:                if test `grep -c "$Entry" tmp_entry_$$` = 0
        !            98:                then
        !            99:                        echo "Object does not point back to alias. (Nice but not essential.)"  | tee -a Error_file
        !           100:                fi 
        !           101:        else
        !           102:                echo "Object $Object does not exist, or has no seeAlso attribute." | tee -a Error_file
        !           103:        fi
        !           104: 
        !           105:        rm tmp_entry_$$
        !           106:        exit
        !           107: fi
        !           108: 
        !           109: 
        !           110: echo -n "We are at: "
        !           111: Location=`squid | awk -F: '{if (NR == 2) print $2}' | sed -e "s/ @//"`
        !           112: echo $Location
        !           113: 
        !           114: #Check the aliases in the current entry
        !           115: search -filter "objectClass=alias" -nosequence -dontderef -edb -nosizelimit > tmp_ali_chk_$$
        !           116: 
        !           117: if test -s tmp_ali_chk_$$
        !           118: then
        !           119: cat tmp_ali_chk_$$ | while read i
        !           120: do
        !           121:        showentry "$i" -dontderef -novalue -all > tmp_entry_$$
        !           122:        moveto "$i"
        !           123:        Entry=`squid | awk -F: '{if (NR == 2) print $2}' | sed -e "s/ @//"`
        !           124:        echo "Checking alias $Entry"
        !           125:        moveto ..
        !           126: 
        !           127:        # Check that all the 4 correct attributes are present, and no more.
        !           128:        if [ `grep -c "commonName" tmp_entry_$$` = 0 -o `grep -c "organizationName" tmp_entry_$$` = 0 -o `grep -c "organizationalUnitName" tmp_entry_$$` = 0 ]
        !           129:        then 
        !           130:                cat tmp_entry_$$ | sed -e "s/commonName//" > tmp_entry_$$2
        !           131:                mv tmp_entry_$$2 tmp_entry_$$
        !           132:                cat tmp_entry_$$ | sed -e "s/organizationName//" > tmp_entry_$$2
        !           133:                mv tmp_entry_$$2 tmp_entry_$$
        !           134:                cat tmp_entry_$$ | sed -e "s/organizationalUnitName//" > tmp_entry_$$2
        !           135:                mv tmp_entry_$$2 tmp_entry_$$
        !           136:        else
        !           137:                echo "Common Name attribute missing. Please add." | tee -a Error_file
        !           138:        fi
        !           139:        if test `grep -c "objectClass" tmp_entry_$$` = 0
        !           140:        then 
        !           141:                echo "objectClass attribute missing. Please add." | tee -a Error_file
        !           142:        else
        !           143:                cat tmp_entry_$$ | sed -e "s/objectClass//" > tmp_entry_$$2
        !           144:                mv tmp_entry_$$2 tmp_entry_$$
        !           145:        fi
        !           146:        if test `grep -c "accessControlList" tmp_entry_$$` = 0
        !           147:        then 
        !           148:                echo "ACL attribute missing. Please add." | tee -a Error_file
        !           149:        else
        !           150:                cat tmp_entry_$$ | sed -e "s/accessControlList//" > tmp_entry_$$2
        !           151:                mv tmp_entry_$$2 tmp_entry_$$
        !           152:        fi
        !           153:        if test `grep -c "aliasedObjectName" tmp_entry_$$` = 0
        !           154:        then 
        !           155:                echo "aliasedObjectName attribute missing. Please add." | tee -a Error_file
        !           156:                mv tmp_entry_$$2 tmp_entry_$$
        !           157:        else
        !           158:                cat tmp_entry_$$ | sed -e "s/aliasedObjectName//" > tmp_entry_$$2
        !           159:                mv tmp_entry_$$2 tmp_entry_$$
        !           160:        fi
        !           161:        cat tmp_entry_$$ | sed -e "s/lastModifiedBy//" | sed -e "s/lastModifiedTime//" > tmp_entry_$$2
        !           162:        mv tmp_entry_$$2 tmp_entry_$$
        !           163: 
        !           164:        # Number of words remaining = number of extra attributes.
        !           165:        if  test `cat tmp_entry_$$ | wc -w` != 0
        !           166:        then
        !           167:                echo "Un-necessary attributes present: Please remove" | tee -a Error_file
        !           168:                cat tmp_entry_$$ | awk '{if $0 != "" print $0}'
        !           169:        fi
        !           170: 
        !           171: 
        !           172: 
        !           173:        # Now to check that the entry "aliasObject" points to, 
        !           174:        # actually exists, and that it points back to this entry. 
        !           175: 
        !           176:        Object=`showentry "$i" -dontderef -type "aliasedObjectName" -nokey -edb`
        !           177:        showentry "@$Object" -type "seeAlso" -nokey -edb > tmp_entry_$$
        !           178:        if test -s tmp_entry_$$
        !           179:        then
        !           180:                if test `grep -c "$Entry" tmp_entry_$$` = 0
        !           181:                then
        !           182:                        echo "Object does not point back to alias. (Nice but not essential.)" | tee -a Error_file
        !           183:                fi 
        !           184:        else
        !           185:                echo "Object $Object does not exist, or has no seeAlso attribute." | tee -a Error_file
        !           186:        fi
        !           187:        rm tmp_entry_$$
        !           188:        echo
        !           189: done
        !           190: else
        !           191:        echo "No aliases here. Moving down a level."
        !           192: fi
        !           193: 
        !           194: # Now recurse to the next level.
        !           195: search -filter "objectClass=quipuNonLeafObject" -nosequence -edb -sizelimit 10 > tmp_ali_chk2_$$
        !           196: 
        !           197: if test -s tmp_ali_chk2_$$
        !           198: then
        !           199:        cat tmp_ali_chk2_$$ | while read i
        !           200:        do
        !           201:                alias_chk "$i"
        !           202:                moveto ..
        !           203:        done
        !           204: else
        !           205:        echo "No more levels down here."
        !           206: fi
        !           207: 
        !           208: rm tmp_ali_chk_$$ tmp_ali_chk2_$$

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.