1 /* $Id: domain.c 7141 2005-03-17 11:42:46Z vinocur $
3 ** Domain authenticator.
5 ** Compares the domain of the client connection to the first argument given
6 ** on the command line, and returns the host portion of the connecting host
7 ** as the user if it matches.
13 #include "inn/messages.h"
18 main(int argc, char *argv[])
24 die("Usage: domain <domain>");
25 message_program_name = "domain";
27 /* Read the connection information from stdin. */
28 res = get_res_info(stdin);
30 die("did not get ClientHost data from nnrpd");
31 host = res->clienthostname;
33 /* Check the host against the provided domain. Allow the domain to be
34 specified both with and without a leading period; if without, make sure
35 that there is a period right before where it matches in the host. */
36 p = strstr(host, argv[1]);
38 die("host %s matches the domain exactly", host);
39 if (p == NULL || (argv[1][0] != '.' && p != host && *(p - 1) != '.'))
40 die("host %s didn't match domain %s", host, argv[1]);
42 /* Peel off the portion of the host before where the provided domain
43 matches and return it as the user. */
44 if (argv[1][0] != '.')
47 printf("User:%s\n", host);