RFC: chop down fakeidentd?

Denis Vlasenko vda.linux at googlemail.com
Thu Jan 11 21:53:38 UTC 2007


Hi guys,

Please take a cursory look as networking/fakeidentd.c.
It's outright scary.

I have a feeling that it is sort of bloated out of
all proportions. Seriously.

Why do we write pidfile? Are we ever going to run
a dozen on fakeidentds? "pidfile fakeidentd" is
in fact more reliable than pidfile.

Why do we setuid to "nobody"? What if I don't have "nobody"
in the first place?

Isn't it lame to rely on openlog() having open fd 1
(when we closed all fd's except 0)? Yes, it is,
but what standard guarantees that?

Why we have this MAXCONNS limit in fakeidentd,
maybe we should do it in inetd instead so that ALL services
get this protection from one copy of the code?

Why we care to parse the request - we can use it verbatim:
<- "6191, 23\r\n" - peer asks us "what user connected from your port 6191 to my port 23?"
-> "6193, 23 : USERID : UNIX : nobody\r\n"

IOW: let's replace it with something like this:

int main(int argc, char **argv)
{
        char buf[128];
        char *cur = buf;
        int rem = sizeof(buf)-1;

        alarm(30);
        while (1) {
                char *p;
                int sz = safe_read(0, cur, rem);
                if (sz < 0) return 1;
                rem -= sz;
                cur += sz;
                *cur = '\0';
                p = strpbrk(buf, "\r\n");
                if (p) {
                        *p = '\0';
                        break;
                }
                if (!rem || !sz)
                        break;
        }
        printf("%s : USERID : UNIX : nobody\r\n", buf);
        return 0;
}

Objections?
--
vda



More information about the busybox mailing list