Mageia Bugzilla – Attachment 3927 Details for
Bug 2808
Sectool not configured for Mageia
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
bash script file for first module
integrity.sh (text/plain), 2.81 KB, created by
George Mitchell
on 2013-05-10 18:19:06 CEST
(
hide
)
Description:
bash script file for first module
Filename:
MIME Type:
Creator:
George Mitchell
Created:
2013-05-10 18:19:06 CEST
Size:
2.81 KB
patch
obsolete
>#!/usr/bin/env bash > >if (( ${DEBUG} == 1 )); then >. "${TESTS_DIRS}/bash_defs_debug.sh" >else >. "${TESTS_DIRS}/bash_defs.sh" >fi ># -------------------------------- # ># Copyright (C) 2008 Red Hat, Inc. ># Written by Dan Kopecek <dkopecek@redhat.com> > ># Modified to fix problems and tested by George Mitchell <george@chinilu.com> 05-09-2013 > ># --- Error IDs ------- # >const ID_CMDSHADOWED=1 >const ID_DIRNOTPRESENT=2 >const ID_VERIFYFAILED=3 >const ID_FILENOTFOUND=4 > >function check_dirs () { > > local RET=${E_OK} > > echo ${DIRECTORY_LIST} | sed -e "s/ /\n/g" | while read dir; do > if [[ ! -d "${dir}" ]]; then > report 'ERROR' $ID_DIRNOTPRESENT "Directory \"${dir}\" does not exist!" > RET=${E_FATAL} > fi > done > > return ${RET} >} > >function check_cmds () { > > local RET=${E_OK} > > OUTPUT="$(${RPMVERIFY} --noscript --nomtime "${COREPKG}" 2> /dev/null)" > if (( $? != 0 )); then > if [[ -n "$(echo -e "${OUTPUT}" | sed -n 's|^[.A-Z0-9]\{8\}[[:space:]]\{1,\}[^c][[:space:]]\{1,\}.*$|&|p')" ]]; then > report 'ERROR' $ID_VERIFYFAILED "Verify failed for package \"${COREPKG}\"!" > test_exit ${E_FATAL} "integrity test failed." > fi > fi > > rpm -ql "${COREPKG}" | grep bin/ | while read path; do > if [[ "$(stat -c '%A' "${path}" | cut -c 1)" != "l" ]]; then > COMMANDNAME="$(basename "${path}")" > COMMANDPATH="$(dirname "${path}")" > COMMANDPATHS="$(echo "${CMDPATH}" | tr ':' ' ' | sed -e "s|[[:space:]]${COMMANDPATH}||g" -e "s|^${COMMANDPATH}[[:space:]]||g")" > unset DUPLICATES > I=0 > find ${COMMANDPATHS} -maxdepth 1 -mindepth 1 -name "${COMMANDNAME}" 2> /dev/null | while read duplicate; do > if [[ -n "${duplicate}" ]]; then > if [[ "$(stat -c '%A' "${duplicate}" | cut -c 1)" != "l" ]]; then > DUPLICATES[$I]="${duplicate}" > I=$(($I + 1)) > if (( $I > 0 )); then > report 'ERROR' $ID_CMDSHADOWED "Command \"${COMMANDNAME}\" (${path}) has duplicates in these locations: ${DUPLICATES[*]}!" > RET=${E_FATAL} > fi > else > DEST="$(readlink -e "${duplicate}" 2> /dev/null)" > if [[ "${DEST}" != "${path}" ]]; then > DUPLICATES[$I]="${duplicate}" > I=$(($I + 1)) > if (( $I > 0 )); then > report 'ERROR' $ID_CMDSHADOWED "Command \"${COMMANDNAME}\" (${path}) has duplicates in these locations: ${DUPLICATES[*]}!" > RET=${E_FATAL} > fi > fi > fi > fi > done > fi > done > > return ${RET} >} > ># --- Main ----------------------- # > > >if (( ${REFRESH} == 1 )); then > test_exit ${E_OK} >fi > >PATH="${CMDPATH}" > >check_dirs || (test $? == ${E_FATAL} && test_exit ${E_FATAL} "Integrity test failed") >check_cmds || (test $? == ${E_FATAL} && test_exit ${E_FATAL} "Integrity test failed") > >test_exit ${E_OK} ># --- EOF ------------------------ #
#!/usr/bin/env bash if (( ${DEBUG} == 1 )); then . "${TESTS_DIRS}/bash_defs_debug.sh" else . "${TESTS_DIRS}/bash_defs.sh" fi # -------------------------------- # # Copyright (C) 2008 Red Hat, Inc. # Written by Dan Kopecek <dkopecek@redhat.com> # Modified to fix problems and tested by George Mitchell <george@chinilu.com> 05-09-2013 # --- Error IDs ------- # const ID_CMDSHADOWED=1 const ID_DIRNOTPRESENT=2 const ID_VERIFYFAILED=3 const ID_FILENOTFOUND=4 function check_dirs () { local RET=${E_OK} echo ${DIRECTORY_LIST} | sed -e "s/ /\n/g" | while read dir; do if [[ ! -d "${dir}" ]]; then report 'ERROR' $ID_DIRNOTPRESENT "Directory \"${dir}\" does not exist!" RET=${E_FATAL} fi done return ${RET} } function check_cmds () { local RET=${E_OK} OUTPUT="$(${RPMVERIFY} --noscript --nomtime "${COREPKG}" 2> /dev/null)" if (( $? != 0 )); then if [[ -n "$(echo -e "${OUTPUT}" | sed -n 's|^[.A-Z0-9]\{8\}[[:space:]]\{1,\}[^c][[:space:]]\{1,\}.*$|&|p')" ]]; then report 'ERROR' $ID_VERIFYFAILED "Verify failed for package \"${COREPKG}\"!" test_exit ${E_FATAL} "integrity test failed." fi fi rpm -ql "${COREPKG}" | grep bin/ | while read path; do if [[ "$(stat -c '%A' "${path}" | cut -c 1)" != "l" ]]; then COMMANDNAME="$(basename "${path}")" COMMANDPATH="$(dirname "${path}")" COMMANDPATHS="$(echo "${CMDPATH}" | tr ':' ' ' | sed -e "s|[[:space:]]${COMMANDPATH}||g" -e "s|^${COMMANDPATH}[[:space:]]||g")" unset DUPLICATES I=0 find ${COMMANDPATHS} -maxdepth 1 -mindepth 1 -name "${COMMANDNAME}" 2> /dev/null | while read duplicate; do if [[ -n "${duplicate}" ]]; then if [[ "$(stat -c '%A' "${duplicate}" | cut -c 1)" != "l" ]]; then DUPLICATES[$I]="${duplicate}" I=$(($I + 1)) if (( $I > 0 )); then report 'ERROR' $ID_CMDSHADOWED "Command \"${COMMANDNAME}\" (${path}) has duplicates in these locations: ${DUPLICATES[*]}!" RET=${E_FATAL} fi else DEST="$(readlink -e "${duplicate}" 2> /dev/null)" if [[ "${DEST}" != "${path}" ]]; then DUPLICATES[$I]="${duplicate}" I=$(($I + 1)) if (( $I > 0 )); then report 'ERROR' $ID_CMDSHADOWED "Command \"${COMMANDNAME}\" (${path}) has duplicates in these locations: ${DUPLICATES[*]}!" RET=${E_FATAL} fi fi fi fi done fi done return ${RET} } # --- Main ----------------------- # if (( ${REFRESH} == 1 )); then test_exit ${E_OK} fi PATH="${CMDPATH}" check_dirs || (test $? == ${E_FATAL} && test_exit ${E_FATAL} "Integrity test failed") check_cmds || (test $? == ${E_FATAL} && test_exit ${E_FATAL} "Integrity test failed") test_exit ${E_OK} # --- EOF ------------------------ #
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 2808
:
3920
|
3926
|
3927
|
3936
|
3937
|
3938
|
3939
|
3940
|
3941
|
3942
|
3943
|
3944
|
3946
|
3947
|
3948
|
3952
|
3953
|
3954
|
3963
|
3964