示例#1
0
int
main(int argc, char **argv)
{
    char *target_domain;
    if (argc > 0) {		/* should always be true */
	myname = strrchr(argv[0], '/');
	if (myname == NULL)
	    myname = argv[0];
	else
	    myname++;
    } else {
	myname = "(unknown)";
    }
    mypid = getpid();
    target_domain = process_options(argc, argv);
    debug("ntlm winbindd auth helper build " __DATE__ ", " __TIME__
	" starting up...\n");

    check_winbindd();

    if (target_domain == NULL) {
	target_domain = get_winbind_domain();
    }

    /* initialize FDescs */
    setbuf(stdout, NULL);
    setbuf(stderr, NULL);
    init_random();
    while (manage_request(target_domain)) {
	/* everything is done within manage_request */
    }
    return 0;
}
int
main (int argc, char *argv[])
{
    char *p, *t;
    char buf[BUFSIZE];
    char *username;
    char *group;
    int err = 0;
    const char *groups[512];
    int n;

    if (argc > 0) {	/* should always be true */
	myname=strrchr(argv[0],'/');
	if (myname==NULL)
	    myname=argv[0];
    } else {
        myname="(unknown)";
    }
    mypid=getpid();

    /* make standard output line buffered */
    setvbuf (stdout, NULL, _IOLBF, 0);

    /* Check Command Line */
    process_options(argc, argv);

    debug("External ACL winbindd group helper build " __DATE__ ", " __TIME__
    " starting up...\n");
    if (use_case_insensitive_compare)
        debug("Warning: running in case insensitive mode !!!\n");
 
    check_winbindd();

    /* Main Loop */
    while (fgets (buf, BUFSIZE, stdin))
    {
	if (NULL == strchr(buf, '\n')) {
	    err = 1;
	    continue;
	}
	if (err) {
	    warn("Oversized message\n");
	    goto error;
	}
	
	if ((p = strchr(buf, '\n')) != NULL)
	    *p = '\0';		/* strip \n */
	if ((p = strchr(buf, '\r')) != NULL)
	    *p = '\0';		/* strip \r */

	debug("Got '%s' from Squid (length: %d).\n",buf,strlen(buf));
	
	if (buf[0] == '\0') {
	    warn("Invalid Request\n");
	    goto error;
	}

	username = strwordtok(buf, &t);
	for (n = 0; (group = strwordtok(NULL, &t)) != NULL; n++)
	    groups[n] = group;
	groups[n] = NULL;

        if (NULL == username) {
            warn("Invalid Request\n");
            goto error;
        }

	if (Valid_Groups(username, groups)) {
	    printf ("OK\n");
	} else {
error:
	    printf ("ERR\n");
	}
	err = 0;
    }
    return 0;
}