This file is indexed.

/usr/sbin/update_sqlgrey_config is in sqlgrey 1:1.8.0-1.

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

# We need md5sum, diff and wget
MD5SUM=`which md5sum 2>/dev/null`
if [ $? -ne 0 ]
then
    echo "md5sum not found in PATH, can't continue"
    exit -1
fi
DIFF=`which diff 2>/dev/null`
if [ $? -ne 0 ]
then
    echo "diff not found in PATH, can't continue"
    exit -1
fi
WGET=`which wget 2>/dev/null`
if [ $? -ne 0 ]
then
    echo "wget not found in PATH, can't continue"
    exit -1
fi

# md5sum output parsing need a known locale
LANG=C
LC_ALL=C

MYDIR=/etc/sqlgrey
CONF=$MYDIR/sqlgrey.conf

# Get whitelists host and pidfile from conf
whitelist_host=`grep "^[[:space:]]*whitelists_host" $CONF | cut -d= -f2 | awk '{print $1}'`
if [ -z "$whitelists_host" ]
then
    whitelists_host="sqlgrey.bouton.name"
fi
pidfile=`grep "^[[:space:]]*pidfile" $CONF | cut -d= -f2 | awk '{print $1}'`
if [ -z "$pidfile" ]
then
    pidfile="/var/run/sqlgrey.pid"
fi

# Go into a temp directory
MYTMP=`mktemp -d ${TMPDIR:-/tmp}/sqlgrey.XXXXXX`
[ -n "$MYTMP" -a -d "$MYTMP" ] && cd $MYTMP || {
	echo "Error creating temporary directory"
	exit 1
}

# Setup a clean exit
clean_exit() {
    cd ~sqlgrey
    [ -n "$MYTMP" -a -d "$MYTMP" ] && rm -rf $MYTMP
    exit $1
}
trap clean_exit 2 3 15

# Fetch MD5
$WGET -q http://$whitelists_host/MD5SUMS

# Check installed files
cd $MYDIR
TOUPDATE=`md5sum -c $MYTMP/MD5SUMS 2>/dev/null | grep FAILED | cut -d: -f1`

if [ -z "$TOUPDATE" ]
then
    clean_exit 0
fi

cd $MYTMP
# copy old files
for whitelist in `cat MD5SUMS|awk '{print $2}'`
do
    cp $MYDIR/$whitelist . 2>/dev/null
done
# fetch new ones
for todownload in $TOUPDATE
do
    echo "updating $MYDIR/$todownload:"
    rm $todownload 2>/dev/null
    $WGET -N -q http://$whitelists_host/$todownload
    if [ -f $MYDIR/$todownload ]; then
	$DIFF -u $MYDIR/$todownload $todownload
    else
	echo "new file: $todownload"
    fi
done

md5sum -c MD5SUMS >/dev/null 2>/dev/null
if [ $? -ne 0 ]
then
    # Can only happen if remote site is borked or file got corrupt in transit
    echo "Error fetching new files, try later"
    clean_exit -1
fi

# MD5SUMS isn't needed anymore
rm MD5SUMS
# Replace whitelists
mv * $MYDIR

# Reload whitelists
kill -USR1 `cat $pidfile`

clean_exit 0