示例#1
0
struct userdata *
courier_lookup(const char *user)
{
	courier_udata = NULL;
	if (auth_getuserinfo(__progname, user, courier_callback, NULL) != 0)
		return (NULL);
	return (courier_udata);
}
示例#2
0
文件: main.c 项目: Rupreht/cpquota
int main(int argc, char** argv) {
    char *token, *last;
    char sep[2];
    sep[1] = '=';
    sep[2] = '\0';

    if (argc > 1) {
        if (strstr(argv[1], "-d")) debug = 1;
        if (strstr(argv[1], "-X")) debug = 2;
        }

    clearerr(stdin);
    while (fgets(line, sizeof (line), stdin) != NULL) {

    if (debug>1) {
        syslog(LOG_DEBUG, line);
    }

        token = strtok_r(line, sep, &last);
        if (!strcmp(token, "recipient"))
            strcpy(recipient, strtok_r(NULL, "=", &last));
        if (!strcmp(token, "size"))
            strcpy(size, strtok_r(NULL, "=", &last));
        if (!strcmp(token, "queue_id"))
            strcpy(queue_id, strtok_r(NULL, "=", &last));
        if (!strcmp(token, "client_address"))
            strcpy(client_address, strtok_r(NULL, "=", &last));
        if (!strcmp(token, "sender"))
            strcpy(sender, strtok_r(NULL, "=", &last));

        if (!strcmp(token, "request")) {
            echo = 0;
            strcpy(recipient, "");
            strcpy(size, "");
            continue;
        }

        if (!strcmp(line, "\n") && strcmp(recipient, "")
                && strcmp(size, "")) {

            if (auth_getuserinfo("login", recipient, &callback, NULL))
                smtpd_access_policy("dunno");

            if (!echo) smtpd_access_policy("dunno");
            echo = 0;
            strcpy(recipient, "");
            strcpy(size, "");
        }

    }
    return (0);
}
示例#3
0
int auth_generic(const char *service,
		 const char *authtype,
		 char *authdata,
		 int (*callback_func)(struct authinfo *, void *),
		 void *callback_arg)
{
	char	tbuf[NUMBUFSIZE];
	size_t	l=strlen(service)+strlen(authtype)+strlen(authdata)+2;
	char	*n=libmail_str_size_t(l, tbuf);
	char	*buf=malloc(strlen(n)+l+20);
	int	rc;

	courier_authdebug_login_init();

	if (!buf)
		return 1;

	strcat(strcat(strcpy(buf, "AUTH "), n), "\n");
	strcat(strcat(buf, service), "\n");
	strcat(strcat(buf, authtype), "\n");
	strcat(buf, authdata);

	rc=strcmp(authtype, "EXTERNAL") == 0
		? auth_getuserinfo(service, authdata, callback_func,
				   callback_arg)
		: authdaemondo(buf, callback_func, callback_arg);
	free(buf);

	if (courier_authdebug_login_level)
	{
	struct timeval t;

		/* short delay to try and allow authdaemond's courierlogger
		   to finish writing; otherwise items can appear out of order */
		t.tv_sec = 0;
		t.tv_usec = 100000;
		select(0, 0, 0, 0, &t);
	}

	return rc;
}
示例#4
0
文件: auth.c 项目: MhdAlyan/courier
int prelogin(const char *u)
{
	return auth_getuserinfo("webmail", u, doauthlogin, (void *)u);
}
示例#5
0
int main(int argc, char **argv)
{
int	argn;
const char *service="login";

	for (argn=1; argn<argc; argn++)
	{
	const char *argp;

		if (argv[argn][0] != '-')	break;
		if (argv[argn][1] == 0)
		{
			++argn;
			break;
		}

		argp=argv[argn]+2;

		switch (argv[argn][1])	{
		case 's':
			if (!*argp && argn+1 < argc)
				argp=argv[++argn];
			service=argp;
			break;
		default:
			usage();
		}
	}
	if (argc - argn <= 0)
		usage();

	courier_authdebug_login_level = 2;

	if (argc - argn >= 3)
	{
		if (auth_passwd(service, argv[argn],
				argv[argn+1],
				argv[argn+2]))
		{
			perror("Authentication FAILED");
			exit(1);
		}
		else
		{
			fprintf(stderr, "Password change succeeded.\n");
			exit(0);
		}
	}
	if (argc - argn >= 2)
	{
		if (auth_login(service, argv[argn],
			       argv[argn+1],
			       callback_pre,
			       NULL))
		{
			perror("Authentication FAILED");
			exit(1);
		}
	}
	else if (argc - argn >= 1)
	{
		if (auth_getuserinfo(service, argv[argn],
				     callback_pre,
				     NULL))
		{
			perror("Authentication FAILED");
			exit(1);
		}
	}
	exit(0);
}