Magellan Linux

Diff of /mcore-src/trunk/mcore-tools/src/include/common.global.class.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2479 by niro, Thu Sep 10 08:48:45 2015 UTC revision 2809 by niro, Fri Apr 7 07:17:48 2017 UTC
# Line 149  clearconfig() Line 149  clearconfig()
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    
# Line 261  iface_for_remote_addr() Line 263  iface_for_remote_addr()
263   echo $5   echo $5
264  }  }
265    
266    validate_ip_addr()
267    {
268     local ip="$1"
269     local retval=1
270     local _ifs
271    
272     if [[ ${ip} =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]
273     then
274     _ifs=$IFS
275     IFS='.'
276     # convert to an array
277     ip=($ip)
278     IFS=$_ifs
279    
280     if [[ ${ip[0]} -le 255 ]] &&
281     [[ ${ip[1]} -le 255 ]] &&
282     [[ ${ip[2]} -le 255 ]] &&
283     [[ ${ip[3]} -le 255 ]]
284     then
285     retval=$?
286     fi
287     fi
288    
289     return ${retval}
290    }
291    
292  # get ip from dns name  # get ip from dns name
293  dns_to_ip()  dns_to_ip()
294  {  {
295   set -- $(getent hosts $1)   if ! validate_ip_addr $1
296     then
297     set -- $(getent hosts $1)
298     fi
299   echo $1   echo $1
300  }  }
301    
# Line 368  $@ Line 399  $@
399  quit  quit
400  EOF  EOF
401  }  }
402    
403    nsslsay_queue_init()
404    {
405     SSLSAY_QUEUE=()
406    }
407    
408    nsslsay_queue_add()
409    {
410     SSLSAY_QUEUE+=( "$@" )
411    }
412    
413    nsslsay_queue_print()
414    {
415     local count
416     local i
417    
418     count="${#SSLSAY_QUEUE[*]}"
419     for ((i=0; i < count; i++))
420     do
421     echo "${SSLSAY_QUEUE[${i}]}"
422     done
423    }
424    
425    nsslsay_queue_run()
426    {
427     nsslsay "$(nsslsay_queue_print)"
428    }
429    
430    nsslsay_queue_run_fingerprint()
431    {
432     nsslsay_fingerprint "$(nsslsay_queue_print)"
433    }
434    
435    # read_cmdline "$variable"
436    # eg: read_cmdline "lang="
437    #       returns the value of the cmdline variable lang
438    # eg: read_cmdline "rd.info"
439    #      returns bool 1 if the variable was defined
440    #
441    read_cmdline()
442    {
443     local variable="$1"
444     local retval
445     local i
446    
447     if [[ -z ${variable} ]]
448     then
449     eecho "no variable given"
450     return 1
451     fi
452    
453     if [ ! -e /proc/cmdline ]
454     then
455     eecho "read_cmdline(): /proc/cmdline does not exists"
456     return 1
457     fi
458    
459     for i in $(</proc/cmdline)
460     do
461     if [[ ${i} = ${variable}* ]]
462     then
463     case ${variable} in
464     *=*) retval="${i#*=}" ;;
465     *) retval=1 ;; # bool
466     esac
467     fi
468     done
469    
470     echo "${retval}"
471     return 0
472    }

Legend:
Removed from v.2479  
changed lines
  Added in v.2809