File: preauthdaemon.c

package info (click to toggle)
courier-authlib 0.72.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,824 kB
  • sloc: ansic: 15,828; sh: 5,047; cpp: 4,205; makefile: 853; perl: 761
file content (49 lines) | stat: -rw-r--r-- 1,094 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
** Copyright 2000-2004 Double Precision, Inc.  See COPYING for
** distribution information.
*/

#include	"auth.h"
#include	"courierauthstaticlist.h"
#include	"courierauthsasl.h"
#include	<stdlib.h>
#include	<stdio.h>
#include	<string.h>


extern int authdaemondo_meta(struct auth_meta *meta,
			     const char *authreq,
			     int (*func)(struct authinfo *, void *),
			     void *arg);

int auth_getuserinfo(const char *service, const char *uid,
		     int (*callback)(struct authinfo *, void *),
		     void *arg)
{
	struct auth_meta dummy;

	memset(&dummy, 0, sizeof(dummy));

	return auth_getuserinfo_meta(&dummy, service, uid, callback, arg);
}

int auth_getuserinfo_meta(struct auth_meta *meta,
			  const char *service, const char *uid,
			  int (*callback)(struct authinfo *, void *),
			  void *arg)
{
char    *buf=malloc(strlen(service)+strlen(uid)+20);
int     rc;

	if (!buf)
	{
		perror("malloc");
		return (1);
	}
	strcat(strcat(strcat(strcat(strcpy(buf, "PRE . "), service), " "),
		uid), "\n");

	rc=authdaemondo_meta(meta, buf, callback, arg);
	free(buf);
	return (rc);
}