This file is indexed.

/usr/bin/fai-class is in fai-client 3.4.8ubuntu2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#! /bin/bash

# $Id$
#*********************************************************************
#
# fai-class - determine all classes a host belongs to
#
# This script is part of FAI (Fully Automatic Installation)
# (c) 2002-2009 by Thomas Lange, lange@informatik.uni-koeln.de
# Universitaet zu Koeln
#
#*********************************************************************
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# 
# A copy of the GNU General Public License is available as
# `/usr/share/common-licences/GPL' in the Debian GNU/Linux distribution
# or on the World Wide Web at http://www.gnu.org/copyleft/gpl.html. You
# can also obtain it by writing to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#*********************************************************************

# import variables: $LOGDIR $verbose $debug
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
verbosemsg() {

    # a very nice subroutine
    # write message if the verbose flag is set
    [ "$verbose" ] && echo "$@"
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
debugmsg() {

    # a very nice subroutine
    # write message if the debug flag is set
    [ "$debug" ] && echo "$0: $@"
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
addclass() {

    # append classes to a file
    while read line ; do
	case $line in
	\#*) ;; # strip comments
	  *) debugmsg "Adding class $line"
	     for class in $line ; do
		 echo $class >> $filename
	     done
	esac
    done
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fc_check_status() {

    cmd=$1
    st=$2

    if [ $st -eq 0 ]; then
	res="OK."
    else
	res="FAILED with exit code $st."
    fi
    # put result in the log file and write to stdout
    printf "%-20s $res\n" $cmd | tee -a $LOGDIR/status.log
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
usage() {

    ex=$1
    cat <<-EOF
	fai-class  Copyright (C) 2002-2009 Thomas Lange

	Usage: fai-class [OPTION] DIRECTORY CLASSFILE
	Define classes using files and scripts in DIRECTORY

	Executes scripts in DIRECTORY starting with two digits.
	The standard output of these scripts are names of classes which
	are written to CLASSFILE.
EOF
    exit $ex
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
testclass() {

    # test if some classes are define multiple times
    duplicate=$(sort $filename | uniq -dc)
    if [ -n "$duplicate" ]; then
	echo "$0: WARNING. Following classes are defined multiple times: $duplicate"
	exit 2
    fi
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
setup() {

    # parse options, test and set some basic variables

    while getopts "dhvt:T" opt ; do
        case "$opt" in
        d) debug=1 ;;
        v) verbose=1 ;;
        h) usage 0 ;;
        T) ctest=1 ;;
        t) LOGDIR=$OPTARG; export LOGDIR ;;
        *) usage 1 ;;
	esac
    done
    shift $(($OPTIND - 1))
    [ -z "$2" ] || [ -n "$3" ] && usage 1

    classdir=$1
    filename=$2
    cd $classdir || {
	echo "$0: Can't change dir to $classdir."
	exit 99
    }
    if [ -s $filename ]; then
	verbosemsg "$filename exists. Renaming to $filename.bak"
	mv $filename $filename.bak
    fi
    if [ -z "$LOGDIR" ]; then
	verbosemsg "Setting LOGDIR to default value /tmp/fai"
	LOGDIR=/tmp/fai; export LOGDIR
    fi
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# main program

PATH=.:$PATH    # so scripts in /fai/class are found
export PATH

setup "$@"
verbosemsg "fai-class: Defining classes."

echo DEFAULT | addclass

# define classes by executing scripts
# alphabetical sort is important
if [ "$debug" ]; then
    scripts=$(echo [0-9][0-9]*)
else
    scripts=$(echo [0-9][0-9]* 2>/dev/null)
fi
debugmsg "Scripts found: $scripts"

for f in $scripts ; do
    [ -f $f ] || continue # skip sockets, pipes, symlinks
    debugmsg "File $f found."
    if [ ! -x $f ]; then
	echo "Warning: File $f is not executable, so it's not used for defining classes."
	continue
    fi
    classes=$(cat $filename)
    export classes
    case $f in
	*~|*.bak) debugmsg "Skipping backup file $f" ;;
	*.source)
	    verbosemsg "Executing $classdir/$f."
	    # this script can define $newclasses
	    newclasses=
	    . $f
	    fc_check_status $f $?
	    echo $newclasses | addclass ;; 
	*)
	    verbosemsg "Executing $classdir/$f."
	    classes=$($f </dev/null)
	    fc_check_status $f $?
	    echo $classes | addclass
	    ;;
    esac
done

# $LOGDIR should not be writable by everybody
# scripts can also write additional classes to a file, if they
# can't print them to stdout. Define these classes.

if [ -f $LOGDIR/additional-classes ]; then
    cat $LOGDIR/additional-classes | addclass
    if [ "$debug" ]; then
	mv $LOGDIR/additional-classes $LOGDIR/additional-classes.used
    else
        # remove the file after it was used. Do not use the same file more than once.
	rm -f $LOGDIR/additional-classes
    fi
fi

# add all classes which are listed in a file with the hostname
if [ -f "$HOSTNAME" ]; then
	verbosemsg "Using classes from file $classdir/$HOSTNAME"
	grep -v "^#" $HOSTNAME | addclass
fi

echo ${ADDCLASSES//,/ } | addclass

# now add the hostname (the only class in lowercase) and LAST to
# the list of classes
echo $HOSTNAME LAST | addclass

# show all classes if verbose
debugmsg List of all classes: $(cat $filename)
[ "$ctest" ] && testclass
exit 0