9 |
local webcrlf |
local webcrlf |
10 |
|
|
11 |
# print nothing if quiet mode was requested |
# print nothing if quiet mode was requested |
12 |
[[ ${QUIET} = true ]] && return |
[[ ${QUIET} = 1 ]] && return |
13 |
|
|
14 |
if [[ ${NOCOLORS} = true ]] |
if [[ ${NOCOLORS} = 1 ]] |
15 |
then |
then |
16 |
COLCYAN="" |
COLCYAN="" |
17 |
COLDEFAULT="" |
COLDEFAULT="" |
18 |
fi |
fi |
19 |
|
|
20 |
[[ ${WEBCRLF} = true ]] && webcrlf="<br>" |
[[ ${WEBCRLF} = 1 ]] && webcrlf="<br>" |
21 |
|
|
22 |
# respect -n |
# respect -n |
23 |
case $1 in |
case $1 in |
35 |
local opts |
local opts |
36 |
local webcrlf |
local webcrlf |
37 |
|
|
38 |
if [[ ${NOCOLORS} = true ]] |
if [[ ${NOCOLORS} = 1 ]] |
39 |
then |
then |
40 |
COLRED="" |
COLRED="" |
41 |
COLDEFAULT="" |
COLDEFAULT="" |
42 |
fi |
fi |
43 |
|
|
44 |
[[ ${WEBCRLF} = true ]] && webcrlf="<br>" |
[[ ${WEBCRLF} = 1 ]] && webcrlf="<br>" |
45 |
|
|
46 |
# respect -n |
# respect -n |
47 |
case $1 in |
case $1 in |
59 |
local opts |
local opts |
60 |
local webcrlf |
local webcrlf |
61 |
|
|
62 |
if [[ ${NOCOLORS} = true ]] |
if [[ ${NOCOLORS} = 1 ]] |
63 |
then |
then |
64 |
COLPURPLE="" |
COLPURPLE="" |
65 |
COLDEFAULT="" |
COLDEFAULT="" |
66 |
fi |
fi |
67 |
|
|
68 |
[[ ${WEBCRLF} = true ]] && webcrlf="<br>" |
[[ ${WEBCRLF} = 1 ]] && webcrlf="<br>" |
69 |
|
|
70 |
# respect -n |
# respect -n |
71 |
case $1 in |
case $1 in |
149 |
# this wrapper runs a command in the xsession of the unpriv_user |
# this wrapper runs a command in the xsession of the unpriv_user |
150 |
x11runas() |
x11runas() |
151 |
{ |
{ |
152 |
if [[ -n $(pidof X) ]] || [[ -n $(pidof Xorg) ]] |
if [[ -n $(pidof X) ]] || [[ -n $(pidof Xorg) ]] || [[ -n $(pidof Xorg.bin) ]] |
153 |
then |
then |
154 |
su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@" |
su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@" |
155 |
|
else |
156 |
|
decho "x11runas(): No running X, Xorg or Xorg.bin process found" |
157 |
fi |
fi |
158 |
} |
} |
159 |
|
|
260 |
iface_for_remote_addr() |
iface_for_remote_addr() |
261 |
{ |
{ |
262 |
set -- $(ip -o route get to $1) |
set -- $(ip -o route get to $1) |
263 |
echo $5 |
# honor routes with and without a gateway |
264 |
|
case $@ in |
265 |
|
*via*) echo $5 ;; |
266 |
|
*) echo $3 ;; |
267 |
|
esac |
268 |
|
} |
269 |
|
|
270 |
|
validate_ip_addr() |
271 |
|
{ |
272 |
|
local ip="$1" |
273 |
|
local retval=1 |
274 |
|
local _ifs |
275 |
|
|
276 |
|
if [[ ${ip} =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]] |
277 |
|
then |
278 |
|
_ifs=$IFS |
279 |
|
IFS='.' |
280 |
|
# convert to an array |
281 |
|
ip=($ip) |
282 |
|
IFS=$_ifs |
283 |
|
|
284 |
|
if [[ ${ip[0]} -le 255 ]] && |
285 |
|
[[ ${ip[1]} -le 255 ]] && |
286 |
|
[[ ${ip[2]} -le 255 ]] && |
287 |
|
[[ ${ip[3]} -le 255 ]] |
288 |
|
then |
289 |
|
retval=$? |
290 |
|
fi |
291 |
|
fi |
292 |
|
|
293 |
|
return ${retval} |
294 |
} |
} |
295 |
|
|
296 |
# get ip from dns name |
# get ip from dns name |
297 |
dns_to_ip() |
dns_to_ip() |
298 |
{ |
{ |
299 |
set -- $(getent hosts $1) |
if ! validate_ip_addr $1 |
300 |
|
then |
301 |
|
set -- $(getent hosts $1) |
302 |
|
fi |
303 |
echo $1 |
echo $1 |
304 |
} |
} |
305 |
|
|
403 |
quit |
quit |
404 |
EOF |
EOF |
405 |
} |
} |
406 |
|
|
407 |
|
nsslsay_queue_init() |
408 |
|
{ |
409 |
|
SSLSAY_QUEUE=() |
410 |
|
} |
411 |
|
|
412 |
|
nsslsay_queue_add() |
413 |
|
{ |
414 |
|
SSLSAY_QUEUE+=( "$@" ) |
415 |
|
} |
416 |
|
|
417 |
|
nsslsay_queue_print() |
418 |
|
{ |
419 |
|
local count |
420 |
|
local i |
421 |
|
|
422 |
|
count="${#SSLSAY_QUEUE[*]}" |
423 |
|
for ((i=0; i < count; i++)) |
424 |
|
do |
425 |
|
echo "${SSLSAY_QUEUE[${i}]}" |
426 |
|
done |
427 |
|
} |
428 |
|
|
429 |
|
nsslsay_queue_run() |
430 |
|
{ |
431 |
|
nsslsay "$(nsslsay_queue_print)" |
432 |
|
} |
433 |
|
|
434 |
|
nsslsay_queue_run_fingerprint() |
435 |
|
{ |
436 |
|
nsslsay_fingerprint "$(nsslsay_queue_print)" |
437 |
|
} |
438 |
|
|
439 |
|
# read_cmdline "$variable" |
440 |
|
# eg: read_cmdline "lang=" |
441 |
|
# returns the value of the cmdline variable lang |
442 |
|
# eg: read_cmdline "rd.info" |
443 |
|
# returns bool 1 if the variable was defined |
444 |
|
# |
445 |
|
read_cmdline() |
446 |
|
{ |
447 |
|
local variable="$1" |
448 |
|
local retval |
449 |
|
local i |
450 |
|
|
451 |
|
if [[ -z ${variable} ]] |
452 |
|
then |
453 |
|
eecho "no variable given" |
454 |
|
return 1 |
455 |
|
fi |
456 |
|
|
457 |
|
if [ ! -e /proc/cmdline ] |
458 |
|
then |
459 |
|
eecho "read_cmdline(): /proc/cmdline does not exists" |
460 |
|
return 1 |
461 |
|
fi |
462 |
|
|
463 |
|
for i in $(</proc/cmdline) |
464 |
|
do |
465 |
|
if [[ ${i} = ${variable}* ]] |
466 |
|
then |
467 |
|
case ${variable} in |
468 |
|
*=*) retval="${i#*=}" ;; |
469 |
|
*) retval=1 ;; # bool |
470 |
|
esac |
471 |
|
fi |
472 |
|
done |
473 |
|
|
474 |
|
echo "${retval}" |
475 |
|
return 0 |
476 |
|
} |