File: bastille

package info (click to toggle)
bastille 1:1.3.0-2.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,576 kB
  • ctags: 397
  • sloc: perl: 8,407; sh: 1,879; ansic: 638; makefile: 203; csh: 17
file content (138 lines) | stat: -rwxr-xr-x 4,700 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/sh

##################################################################
# File: $Id: bastille,v 1.5 2001/10/15 21:54:07 tyler_e Exp $
# This script does the following:
#   1) Determines if Perl and the required modules are installed
#   2) Configures the paths to ensure Bastille runs correctly on
#      all supported operating systems.
##################################################################

export PATH="/bin:/usr/bin:/usr/sbin:$PATH"
export PERL5LIB="/opt/sec_mgmt/bastille/lib:/usr/lib/perl5/site_perl:/usr/lib/Bastille"


set +o privileged # perl will not accept -m options while suid otherwise
# minimum version of perl is 5.005
MIN_V_MAJ=5
MIN_V_MIN=005
PARSED_PATH="`echo $PATH | sed -e 's/:/ /g'`"
PERL_PATHS="/opt/perl/bin /usr/local/bin /usr/bin /bin /usr/contrib/bin $PARSED_PATH"

  ERRORWARN='WARNING: '
  ERRSPACES='         '

retval=0    # holds current error condition only values are 0 - Success,
            # and 2 - warning for install, and either error or
            # warning for run-time execution

printErr () {
  cat >&2 << EOF!!!
$ERRORWARN Unable to find perl version $MIN_V_MAJ.$MIN_V_MIN or greater
$ERRSPACES in either your path or in the standard places for perl.
$ERRSPACES Bastille cannot function without perl $MIN_V_MAJ.$MIN_V_MIN or higher.
$ERRSPACES You may to do one of the following to resolve this problem:
$ERRSPACES   1) Install perl. It is available from
$ERRSPACES      http://www.cpan.org/ports/index.html
$ERRSPACES   2) Create a symbolic link from the correct
$ERRSPACES      version of perl to /usr/local/bin or some element in your path
$ERRSPACES      with ln -s <correct_perl> <directory in your path>/perl
$ERRSPACES   3) If you can not insert a link to one of the above directories,
$ERRSPACES      and you are sure your Perl installation is correct, you may
$ERRSPACES      elect to run Bastille without its internal checks
$ERRSPACES      by typing: <correct_perl> <path to desired perl script>

EOF!!!
}

# Look under common locations for Perl, and then the user's path

for CURRENT_PERL_PATH in $PERL_PATHS
do
  if [ ! -x ${CURRENT_PERL_PATH}/perl ]; then
    FOUND=no;
  else
    FOUND=yes;break
  fi
done


if [ $FOUND = 'no' ]; then
   printErr
   exit 2
fi

# Now we have some version of perl
# We check that the version is at least the minimum

PERL_VERSION=`${CURRENT_PERL_PATH}/perl -version | head -2 | tr " "  "\n" |\
              sed -e "s/^v//" | grep "^[1-9]\." | sed -e "s/_*$//"`
PERL_V_MAJ=${PERL_VERSION%.*}
PERL_V_MIN=`echo ${PERL_VERSION#*.}| sed -e "s/_.*$//"` # remove _<patch level>
                                                        #can't do with "right
                                                        #pattern match"

if (( $PERL_V_MAJ < $MIN_V_MAJ )) ||  (( $PERL_V_MAJ == $MIN_V_MAJ && $PERL_V_MIN < $MIN_V_MIN )); then  # we hav
e an invalid version of Perl
  printErr
  retval=2
else
# We have a valid version of perl! Verify that all the required
# modules can be found.
if [[ "${1}x" != "-bx" && "${1}x" != "-ux" ]]; then
    missingmod=0 # flag to indicate if missing mod found.
    for mod in "Tk"
    do
	# see if perl can find the module
	${CURRENT_PERL_PATH}/perl -M$mod < /dev/null > /dev/null 2>&1
	if [ $? != 0 ]; then
	# Cannot find module
	retval=2
	if [ $missingmod = 0 ]; then
	    # First error message printed here
	    missingmod=1;
	    print >&2 "$ERRORWARN ${CURRENT_PERL_PATH}/perl cannot find Perl module $mod."
	else
	    print >&2 "$ERRSPACES ${CURRENT_PERL_PATH}/perl cannot find Perl module $mod."
	fi
	fi
    done
    if [ $missingmod = 1 ]; then # There were missing modules
    cat >&2 << EOF!!!
$ERRSPACES The above module(s) is/are required to correctly display the Bastille User Interface
$ERRSPACES Most Perl ports contain all the required modules, and are found at:
$ERRSPACES http://www.cpan.org/ports/index.html
$ERRSPACES if the port listed for your OS does not contain these modules, they can be 
$ERRSPACES found at http://www.cpan.org/modules/01modules.index.html


EOF!!!
    fi
  fi
fi


if [ -e /opt/sec_mgmt/bastille/bin/bastille ]; then
    scripts_location=/opt/sec_mgmt/bastille/bin
elif [ -e /usr/sbin/InteractiveBastille ]; then
    scripts_location=/usr/sbin
else
    echo "Can not find Bastille scripts..."
    retval=1
fi

if [ $retval != 0 ]; then  # exit if any problems earlier in script
    exit $retval
fi

if [ "${1}x" = "-bx" ]; then # run correct program
    shift
    ${CURRENT_PERL_PATH}/perl $scripts_location/BastilleBackEnd $@
elif [ "${1}x" = "-ux" ]; then
    shift
    ${CURRENT_PERL_PATH}/perl $scripts_location/UndoBastille $@
else
    ${CURRENT_PERL_PATH}/perl $scripts_location/InteractiveBastille $@
fi