This file is indexed.

/usr/bin/freepops-updater-dialog is in freepops 0.2.9-7.

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

#set -x
#set -e

# the return value of functions
RC=""

# XXX should be written at config time
CORE=${CORE:-`which freepopsd`}
FREEPOPS="$CORE -e updater.lua php"
PREAMBLE="dialog --backtitle FreePOPs_Updater"
GAUGE='--defaultno --gauge %s 10 70'
MESSAGE="--title %s --msgbox %s 10 70"
CHECKLIST="--defaultno --separate-output --output-fd 1 --checklist %s 19 78 10" 
MKTEMP="$(which tempfile >/dev/null 2>/dev/null && echo tempfile || echo mktemp)"

# command line argument parsing ##############################################

function parse_args() {
  if [ $# -ge 1 ]; then
    echo -e "\nUsage: freepops-updater-zenity\n\nRun the command without any option\n"
    exit 1
  fi
}

# tempfile handling, with garbage collection #################################
TODELETE=`$MKTEMP`

function erase_tmp_files() {
  rm -f `cat $TODELETE` $TODELETE
}

function mk_temp(){
  local tmp=`$MKTEMP`
  echo $tmp >> $TODELETE
  echo $tmp
}

trap erase_tmp_files EXIT SIGTERM SIGCHLD

# widgets ###################################################################

# text : string 
# items : file which lines are 'name desciption on/off'
# RC: file which lines are name
function checklist() {
	local text="$1"
	local items="$2"

	local CMD=`mk_temp`
	echo -n $PREAMBLE > $CMD
	printf -- " $CHECKLIST " "$text"  >> $CMD
	cat $items >> $CMD

	/bin/bash $CMD
}

# title, message : string
function message(){
	local title="$1"
	local message="$2"
	local CMD=`mk_temp`

	echo -n $PREAMBLE > $CMD
	printf -- " $MESSAGE " "$title" "$message" >> $CMD
	/bin/bash $CMD
}

# helper to access the metadata of a plugin ##################################
function field(){
	local data=$1
	local name=$2

	grep "^$2" $1 | sed "s/^$2 *: *//"
}

# the main has you ###########################################################
function main(){
parse_args "$@"
local AWK=`mk_temp`
cat > $AWK <<EOT
BEGIN { RS = "\n\n+"; FS = "\n"; }
{ 
  cmd = "mktemp -t tmp.freepops." NR ".XXXXXXXX";
  RS = "\n"; 
  cmd | getline tmp; 
  RS = "\n\n+"; 
  print \$0 > tmp; 
  print tmp; 
}
EOT
local ERR=`mk_temp`
local I=0
local CHECKLIST_INPUT=`mk_temp`
local FAILED=`mk_temp`
FILES=`$FREEPOPS fetch_modules_metadata 2>$ERR | awk -f $AWK`
if [ $? != 0 ]; then
	echo "Error fetching metadata" 
	cat $ERR
	exit 1
fi
# register temp files to the garbage collector
echo $FILES >> $TODELETE
N=`echo $FILES | wc -w `
local perc=0
local CMD=`mk_temp`
echo -n $PREAMBLE > $CMD
printf -- " $GAUGE " "'Checking for updates...'" >> $CMD
(for METADATA in $FILES; do
	((perc=$I \* 100 / $N))
	echo $perc
	local M=`field $METADATA module_name`
	local VREQ=`field $METADATA require_version`
	local VLOC=`field $METADATA local_version`
	local VUPS=`field $METADATA version`
	local URL=`field $METADATA url`
	local SHOULD=`field $METADATA should_update`
	local CAN=`field $METADATA can_update`
	local WHY=`field $METADATA why_cannot_update`
	if [ "$CAN" = "true" ]; then
		if [ "$SHOULD" = "true" ]; then
			if [ "$SWAP" = "yes" ]; then
			echo -n on $M "'$VLOC -> $VUPS'" ' ' >> $CHECKLIST_INPUT
			else
			echo -n $M "'$VLOC -> $VUPS'" on ' ' >> $CHECKLIST_INPUT
			fi
		else
			M=$M
		fi
	else	
		if [ "$SHOULD" = "true" ]; then
			echo -n "$M: $WHY\n" >> $FAILED
		else
			M=$M
		fi
	fi
	((I=I+1))
done) | /bin/bash $CMD

if [ -s $CHECKLIST_INPUT ]; then
	local SELECTED=`mk_temp`
	checklist "'Select the plugins to update.'" $CHECKLIST_INPUT > $SELECTED

	for X in `cat $SELECTED`; do
		local ERR=`mk_temp`
		$FREEPOPS fetch_module $X 'true' 2>$ERR
		if [ $? != 0 ]; then
			echo "Error fetching '$M'" 
			cat $ERR
			exit 1
		fi
	done

else
	message "'No updates available'" "'Nothing to update!'"
fi

if [ -s $FAILED ]; then
	message "'Some modules cannot be updated!'" "'`cat $FAILED`'"
fi

}

# here we go! ###############################################################
if [ -z `which dialog 2>/dev/null` ]; then
	echo 'dialog' utility not found.
	echo Please install the dialog package.
	exit 1
fi
if [ ! -x $CORE ]; then
	echo freepopsd not found.
	exit 1
fi

main "$@"

# eof