The root of what's going on here is that both uarg and garg MAY be a username string or a groupname string.  If a username was supplied in uarg, then the name is translated to an int.  Also, a username will also yield a groupid (Ns_GetUserGid).  If it wasn't a name, Ns_GetUid returns -1, and the code goes for the atoi of what's passed in.  Similar with garg and Ns_GetGid.

Cheers,
Mark

In a message dated 12/24/2002 11:45:10 AM Eastern Standard Time, [EMAIL PROTECTED] writes:

I'm looking at nsmain.c for the fun of it on Christmas Eve.  I don't
understand the difference in the code between the gid and the uid. It
seems like the gid has to be less than zero before it is converted to an
int using atoi. Then it is compared to zero. In the uid case, the uid is
always compared to zero.

Merry Christmas!

  if (garg != NULL) {
  gid = Ns_GetGid(garg);
  if (gid <0) {
    gid = atoi(garg);
    if (gid == 0) {
      Ns_Fatal("nsmain: invalid group '%s'", garg);
    }
  }
}
if (uarg != NULL) {
  uid = Ns_GetUid(uarg);
  gid = Ns_GetUserGid(uarg);
  if (uid <0) {
    uid = atoi(uarg);
  }
  if (uid == 0) {
    Ns_Fatal("nsmain: invalid user '%s'", uarg);
  }
}


Reply via email to