login success only once

kaimi dishui at gmail.com
Tue Apr 10 23:05:09 PDT 2007


On 4/5/07, Denis Vlasenko <vda.linux at googlemail.com> wrote:
>
> On Monday 02 April 2007 05:08, kaimi wrote:
> > > Can you dig a bit deeper? Where exactly it fails for you?
> >
> > my /etc/profile followed:
> > export LD_LIBRARY_PATH=/lib:/usr/lib
> > echo "export PATH in /etc/profile"
> > export PATH=/bin:/sbin:/usr/bin:/usr/sbin
> >
> > the startup messages followed:
> > ARM login: root
> > Password:
> > export PATH in /etc/profile
> > [root at ARM ~]# logout
> > ARM login: root
> > Password:
> > export PATH in /etc/profile
> > [root at ARM ~]# login
> > ARM login: root
> >
> > you can see, at startup, login works, it works after logout as well, but
> > it's failed if login on shell prompts. how to trace the exact point?
> thanks
>
> You can add printf("marker N\n") into login in various places
> and find out where it stops.
> --
> vda
>

I found out that "c = getchar()" can not return in loginutils/login.c on
bash, while it works well on ash.
static void get_username_or_die(char *buf, int size_buf)
{
    int c, cntdown;
    cntdown = EMPTY_USERNAME_COUNT;
prompt:
    /* skip whitespace */
    print_login_prompt();
    do {
        c = getchar();
        printf("getchar() return %c\n",c);
        if (c == EOF) exit(1);
        if (c == '\n') {
            if (!--cntdown) exit(1);
            goto prompt;
        }
    } while (isspace(c));

    *buf++ = c;
    if (!fgets(buf, size_buf-2, stdin))
        exit(1);
    printf("fgets return %s\n",buf);
    if (!strchr(buf, '\n'))
        exit(1);
    while (isgraph(*buf)) buf++;
    *buf = '\0';
}

the output on ash is followed
Host login: root
getchar() return r
fgets return oot

while, the output on bash has no messages
Host login: root

shell is dead here. What's wrong?

-- 
                           kaimi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://busybox.net/lists/busybox/attachments/20070411/7a10b4c6/attachment.htm 


More information about the busybox mailing list