示例#1
0
文件: auth.c 项目: zixia/wmail
static int doauthlogin(struct authinfo *a, void *vp)
{
        authsuccess(a->homedir, a->sysuserid ? 0:a->sysusername,
			a->sysuserid, &a->sysgroupid,
			a->address, a->fullname);
	if (login_maildir(a->maildir))
		return (-1);
	return (0);
}
示例#2
0
文件: auth.c 项目: MhdAlyan/courier
static int doauthlogin(struct authinfo *a, void *vp)
{
	const char *p=auth_getoption(a->options ? a->options:"",
				     "disablewebmail");
	const char *c=(const char *)vp;

	static char *authaddr=NULL;
	static char *authfullname=NULL;
	static char *authoptions=NULL;
	static char *authenticated=NULL;
	const char *n;
	char *b;
	int rc;


	if (p && atoi(p))
		return -1;

	if ((rc = auth_callback_default(a)) != 0)
	{
		if (rc > 0)
			perror("ERR: authentication error");
		return -1;
	}

	if (login_maildir(a->maildir))
	{
		error("Unable to open the maildir for this account -- the maildir doesn't exist or has incorrect ownership or permissions.");
		return (-1);
	}

	b=malloc(sizeof("AUTHADDR=")+strlen(c));

	if (!b)
		enomem();
	strcat(strcpy(b, "AUTHADDR="), c);
	putenv(b);
	if (authaddr)
		free(authaddr);
	authaddr=b;


	n=a->fullname;
	if (!n) n="";
	b=malloc(sizeof("AUTHFULLNAME=")+strlen(n));

	if (!b)
		enomem();
	strcat(strcpy(b, "AUTHFULLNAME="), n);
	putenv(b);
	if (authfullname)
		free(authfullname);
	authfullname=b;

	n=a->options;
	if (!n) n="";

	b=malloc(sizeof("OPTIONS=")+strlen(n));

	if (!b)
		enomem();
	strcat(strcpy(b, "OPTIONS="), n);
	putenv(b);
	if (authoptions)
		free(authoptions);
	authoptions=b;

	n=a->address;
	if (!n) n="";

	b=malloc(sizeof("AUTHENTICATED=")+strlen(n));

	if (!b)
		enomem();
	strcat(strcpy(b, "AUTHENTICATED="), n);
	putenv(b);
	if (authenticated)
		free(authenticated);
	authenticated=b;

	return (0);
}
示例#3
0
文件: auth.c 项目: zixia/wmail
static const char *do_login(const char *u, const char *p, const char **driver,
			    int *has_changepwd)
{
char	*buf;
static char	*uid=0;
int	i;

#if 0
struct	preinfo pi;
int	rc;

/*
** We first need to check if sqwebmail saved its own password in sqwebmail-pass.
** To do that, we call the authlib preauthentication functions until we find
** one that accepts our userid.  However, if it succeeds, we will no longer
** as root.  Therefore, let's fork, and do our thing in the child proc.
*/

	pi.haswebpass=0;
	pi.i=0;

	rc=authstaticlist_search(u, "webmail", MODULEFILE,
		&pre_callback, &pi);

	if (rc)
		return (0);

#if ENABLE_WEBPASS
	if (pi.haswebpass)
	{
		if ((*authstaticmodulelist[pi.i]->auth_prefunc)(u, "webmail",
                        &doauthlogin, 0))
		{
			return (0);
		}

		if (check_sqwebpass(p) == 0)
		{
			*driver=authstaticmodulelist[pi.i]->auth_name;
			*has_changepwd=
				authstaticmodulelist[pi.i]->auth_changepwd
				!= 0;
			return (u);
		}
		return (0);
	}
#endif

#endif

	/* Let the authlib library check the password instead, then we'll
	** adopt it as our own.
	*/

	if ((buf=malloc(strlen(u)+strlen(p)+3)) == 0)
		enomem();

	strcat(strcat(strcat(strcpy(buf, u), "\n"), p), "\n");

	if (uid)	free(uid);

	uid=authlogin_search(MODULEFILE, "webmail", AUTHTYPE_LOGIN, buf,
			     0, NULL, NULL, &i);
	free(buf);

	if (uid != 0)
	{
		if (login_maildir(getenv("MAILDIR")))
			error("Unable to open the maildir for this account -- the maildir doesn't exist or has incorrect ownership or permissions.");

		*driver=authstaticmodulelist[i]->auth_name;
		*has_changepwd=
			authstaticmodulelist[i]->auth_changepwd
			!= 0;
		return (uid);
	}
	return (0);
}