This file is indexed.

/usr/share/backup-manager/logger.sh is in backup-manager 0.7.10.1-2.

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

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
# Copyright © 2005-2010 Alexis Sukrieh
#
# See the AUTHORS file for details.
#
# 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.

# This is the logger library
# It can print stuff on STDIN, STDERR and send messages
# to syslog.

function check_logger()
{
    if [[ -x /usr/bin/logger ]]; then
        logger=/usr/bin/logger
    else
        BM_LOGGER="false"
    fi
}

#########################################
# The syslog() function should be called 
# for sending messages to syslog.
#
# Note that no messages will be sent to 
# syslog if BM_LOGGER is set to "false".
#
# ex:
#      syslog "info" "message to log"
#
#########################################
function syslog()
{
    if [[ "$BM_LOGGER" = "true" ]]; then  
        level="$1"
        message="$2"
        $logger -t "backup-manager[$$]" -p "${BM_LOGGER_FACILITY}.${level}" -- "$level * $message"  
    fi
}

# The meta function to log something to syslog, and 
# eventually print it to the appropriate STDOUT
#
# $@ should be the same args as for a echo stanza.
# 
# $bm_log_level should be "info", "warning" or "error".
function log() 
{
    # set the default log level if none given
    if [[ -z "$bm_log_level" ]]; then
        bm_log_level="info"
    fi
    
    # choose the good switch to read if needed
    case "$bm_log_level" in
        "debug")
            bm_log_switch=$verbosedebug
        ;;
        "info")
            bm_log_switch=$verbose
        ;;
        "warning")
            bm_log_switch=$warnings
        ;;
        # in the default case, we print stuff
        *)
            bm_log_switch="true"
        ;;
    esac
    
    log_buffer=""
    # if there's the -n switch, we buffer the message 
    if [[ "$1" = "-n" ]]; then
        # output the message to STDOUT
        message=$(echo_translated "$@")
        if [[ "$bm_log_switch" = "true" ]]; then
            echo -n "${message}"
        fi
        BM_LOG_BUFFER="${log_buffer}${message}"
    
    else
        # output the message to STDOUT
        message=$(echo_translated "$@")
        if [[ "$bm_log_switch" == "true" ]]; then
            if [[ "$bm_log_level" == "debug" ]]; then
                echo "${message}" >&2
            else
                echo "${message}"
            fi
            bm_dbus_send_log_message "${bm_log_level}" "${message}"
        fi
        # log the message to syslog
        syslog $bm_log_level "${log_buffer}${message}"
        # we have now to flush the buffer
        BM_LOG_BUFFER=""
    fi
}

# That function is deprecated, soon we'll remove it.
function __debug()
{
    message="$1"
    echo "DEPRECATED DEBUG: $message" >&2
}

function debug()
{
    if [[ "$BM_LOGGER_LEVEL" == "debug" ]]; then
        bm_log_level="debug"
        log "DEBUG: $@"
    fi
}

function info()
{
    if [[ "$BM_LOGGER_LEVEL" == "debug" ]]\
    || [[ "$BM_LOGGER_LEVEL" == "info" ]]; then
        bm_log_level="info"
        log "$@"
    fi
}

function warning()
{
    if [[ "$BM_LOGGER_LEVEL" == "debug" ]]\
    || [[ "$BM_LOGGER_LEVEL" == "info" ]]\
    || [[ "$BM_LOGGER_LEVEL" == "warning" ]]; then
        bm_log_level="warning"
        log "$@"
    fi
}

# Errors are always sent to syslog
function error()
{
    bm_log_level="error"
    log "$@"
    _exit 1
}


# that's the way backup-manager should exit.
# need to remove the lock before, clean the mountpoint and 
# remove the logfile
function _exit()
{
	exit_code="$1"
	exit_context="$2"
	exit_reason="$3"

    if [[ "$exit_context" != "POST_COMMAND" ]]; then
		exec_post_command || error "Unable to exec post-command."
	fi

    umask $BM_UMASK >/dev/null
    info "Releasing lock"
    release_lock
    bm_dbus_send_progress 100 "Finished"
    bm_dbus_send_event "shutdown" "$@"

	if [[ -n "$exit_reason" ]]; then 
		info "Exit reason: \$exit_reason"
	fi
    exit $exit_code
}