[arm-allstar] bug in admin.sh

LaRoy McCann laroy.mccann at gmail.com
Mon Apr 9 14:36:32 EST 2018


 Ok,

I figured out that if "myip" is blank when the shell expands the variable
in the expression, you get a syntax error.

I did this little test script.


*#!/bin/bash*


*myip=echo ${myip::-2}*
I got this error.




*[root at k5tw-45422 tmp]# ./myiptest./myiptest: line 3: -2: substring
expression < 0*
So it looks like "myip" can't be blank.

LaRoy k5tw



On Mon, Apr 9, 2018 at 2:23 PM, LaRoy McCann <laroy.mccann at gmail.com> wrote:

> Dave and Doug,
>
> I have encountered a bug in admin.sh that will only occur if you are using
> a local display and usb
> keyboard and not connected to a network.
>
> When I login, I get logged right back out.  I can not login unless I'm
> connected to a network.
>
> The issue is where "myip" is being set only if the IP is not 127.0.0.1.
> Since I am not connected to the network, my IP will be 127.0.0.1 in which
> case "myip" is blank.
>
> * myip=$(/sbin/ifconfig | awk -F "[: ]+" '/inet / { if ($3 != "127.0.0.1")
> printf ("%s, ", $3) }')*
>
> I am not sure yet but I think the error part is from "myip" being blank in
> the selection function.
> When "myip" is blank, RET = 1 and the menus exits, logging me out.
> When I set "myip" to 127.0.0.1 in admin.sh, the menu loads.
>
> I am not sure 100% how the selection function is working, but if "myip" is
> blank it will logout before it even draws the menu on the screen.
>
>
>
>
>
>
>
>
>
>
> * while true; do                $SOFF                selection=$($D
> --no-tags --colors --title "\Zb\Z1Admin Menu List for: $HOSTNAME
> (${myip::-2})\Zn" --ok-label "Run Selected Item" --cancel-label "Exit /
> Logout" --menu "Please select:" 23 79 17 "${MENU[@]}" 3>&1- 1>&2-
> 2>&3-)                RET=$?                if [ $RET -ne 0 ] ;
> then                        NEEDBOOT=LOGOUT
> break;                fi                script=${SCRIPT_LIST[$*
>
>
>
>
> *selection]}                if [ -f "$script" ];
> then                        $script
> VAL=$?                        if [ $VAL -eq 10 ] ; then         ### Reboot
> needed!                              *
> *  NEEDBOOT=REBOOT                              *
>
>
> *  break                        fi                        if [ $VAL -eq 11
> ] ; then         ### Halt needed!                              *
> *  NEEDBOOT=HALT                              *
>
>
> *  break                        fi                        if [ $VAL -eq 14
> ] ; then         ### Reload needed!                              *
> *  NEEDBOOT=RELOAD                              *
>
>
>
>
>
>
>
>
>
> *  break                        fi                fi        done        if
> [ "$NEEDBOOT" != "RELOAD" ] ; then         ### break from inner
> loop!                break;        fi        NEEDBOOT=NOdone*
>
>
> Thanks
> LaRoy k5tw
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon> Virus-free.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> <#m_1698053909127685991_m_2909187448513030380_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>


More information about the arm-allstar mailing list