This file is indexed.

/usr/lib/fai/fai-savelog is in fai-client 5.3.6ubuntu1.

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
#! /bin/bash

#*********************************************************************
#
# fai-save-log -- save log files from fai to a local or remote location
#
# This script is part of FAI (Fully Automatic Installation)
# (c) 2002-2015 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
#*********************************************************************

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
save_log_local() {


    # can be an extern script
    # save log files on local disk

    local logbase=$FAI_ROOT/var/log/fai
    local thislog=$logbase/$HOSTNAME/$FAI_ACTION-$fai_rundate

    find $LOGDIR -xdev -size 0 -type f -exec rm {} \;
    # create the symbolic links forcefully; in case of dirinstalls or
    # softupdates they already exist as the fai script creates them together
    # with the directory $LOGDIR
    ln -snf $FAI_ACTION-$fai_rundate $LOGDIR/../last-$FAI_ACTION
    ln -snf $FAI_ACTION-$fai_rundate $LOGDIR/../last

    [ -d "$thislog" ] && return # nothing to do, if directory already exists

    mkdir -p $thislog
    cp -a $LOGDIR/* $thislog
    chown root:adm $thislog
    chmod 0750 $thislog
    ln -snf $HOSTNAME $logbase/localhost
    ln -snf $FAI_ACTION-$fai_rundate $logbase/$HOSTNAME/last-$FAI_ACTION
    ln -snf $FAI_ACTION-$fai_rundate $logbase/$HOSTNAME/last
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
save_log_remote_shell() {

    local thislogdir
    if [ -n "$LOGREMOTEDIR" ]; then
        thislogdir=$LOGREMOTEDIR/$HOSTNAME
    else
        thislogdir=$HOSTNAME
    fi

    local thislog
    thislog=$thislogdir/$FAI_ACTION-$fai_rundate

    echo "Save log files via $remotesh to $LOGUSER@$LOGSERVER:$thislog"
    find $LOGDIR -xdev -size 0 -type f -exec rm {} \;
    $remotesh -l $LOGUSER $LOGSERVER " \
       mkdir -p $thislog ;\
       cd $thislogdir ;\
       ln -snf $FAI_ACTION-$fai_rundate last-$FAI_ACTION ;\
       ln -snf $FAI_ACTION-$fai_rundate last"

    $remotecp -pr $LOGDIR/* $LOGUSER@$LOGSERVER:$thislog
    error=$?
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
save_log_remote() {

    # save log files to $LOGUSER/$HOSTNAME/.. on $LOGSERVER
    # also create a link last-$FAI_ACTION the the directory of the
    # last action. The name of the log directory contains date and
    # time of the action performed

    if [ -z "$LOGUSER" ]; then
        echo "\$LOGUSER is undefined. Not saving log files to remote."
        return
    fi
    # LOGSERVER is overridable until now
    : ${LOGSERVER:=$SERVER}
    if [ -z "$LOGSERVER" ]; then
        echo "\$LOGSERVER is undefined. Not saving log files to remote."
        return
    fi

    case "$FAI_LOGPROTO" in
        ftp)
            fai-savelog-ftp ;;
        none)
            echo "Don't save logs with remote method, only local storage." ;;
        ssh)
            export remotesh=ssh
            export remotecp=scp
            save_log_remote_shell ;;
        rsh)
            export remotesh=rsh
            export remotecp=rcp
            save_log_remote_shell ;;
	*)
	    echo "ERROR: Unknown value for \$FAI_LOGPROTO." ;;
    esac
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
usage() {

    cat <<EOF
fai-savelog, save log files from fai to a local or remote location

   Copyright (C) 2002-2015 by Thomas Lange

Usage: fai-savelog [OPTION]

   -r       Save log files to \$LOGSERVER using rcp or scp
   -l       Save log files to local directory \$FAI_ROOT/var/log/fai

EOF
exit 0
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

[ "$1" ] || usage

: ${FAI_ACTION:=noaction}
while getopts lr opt ; do
        case "$opt" in
        l) save_log_local ;;
        r) save_log_remote ;;
        *) usage ;;
        esac
done

exit $error