- Chris Hardie <[EMAIL PROTECTED]>:

| Is there any state information stored by qmail in terms of usernames
| and domains?

No surprises of that kind in qmail.  qmail-local looks for and reads
.qmail over again on each delivery.  In fact, a separate copy of
qmail-local is run each time.

But wait!  I have an idea!  It just occured to me that "lindgren" is
exactly 8 characters long, which is exactly the maximum length of a
username on many systems.  So here is my conjecture: When your
system's getpwnam() is fed anything longer than 8 characters, it chops
it down to 8 characters and looks up the remainder in the database.
In fact, looking at the code in qmail-getpw.c, this is the only
reasonable explanation I can come up with (for some unreasonable
definition of "reasonable").

To help verify my hypothesis, try compiling and running the appended
program.  Running it as ./getpwnam lindgren-pat will then return

lindgren-pat: name="lindgren", uid=1021, gid=1021, homedir=/home/lindgren

Here is a sample run on my system:

; gcc -o getpwnam getpwnam.c 
; ./getpwnam hanche operator operator-foo
hanche: name="hanche", uid=1357, gid=1999, homedir=/home/fiinbeck/hanche
operator: name="operator", uid=5, gid=5, homedir=/home-pw/operator
operator-foo: nope.

So what system is this happening on?  I am sure Dan will be
interested, so he can try to harden qmail against this kind of
silliness.

- Harald

#include <sys/types.h>
#include <pwd.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
  struct passwd *pw;

  while (*(++argv)) {
    printf ("%s: ", *argv);
    pw = getpwnam(*argv);
    if (pw)
      printf("name=\"%s\", uid=%d, gid=%d, homedir=%s\n",
             pw->pw_name, pw->pw_uid, pw->pw_gid, pw->pw_dir);
    else
      printf("nope.\n");
  }
}

Reply via email to