11 #include <sys/types.h>
37 #define LDAP_HOST "localhost"
38 #define LDAP_BASE "ou=mail,o=enterprise"
39 #define LDAP_SCOPE LDAP_SCOPE_SUBTREE
40 #define LDAP_FILTER "(&(uid=%s)(dc=%s))"
41 #define LDAP_UID_PARAM "uid"
42 #define LDAP_HOME_PARAM "mailMessageStore"
43 #define LDAP_BIND_DN "uid=auth,ou=mail,o=enterprise"
44 #define LDAP_BIND_PASSWD "password"
46 #define MAIL_ACCOUNT_NAME "mail"
47 #define MAIL_ACCOUNT_UID 8
48 #define MAIL_ACCOUNT_GID 12
50 #define PROTOCOL_LEN 512
52 static int protocol_fd = 3;
59 int main (
int argc,
char *argv[])
69 fprintf(stderr,
"%s: error opening protocol fd (%d): %s\n",
70 prog, protocol_fd, strerror(errno));
77 fprintf(stderr,
"%s: bad protocol, zero bytes read\n",
prog);
85 fprintf(stderr,
"%s: bad protocol, no username\n",
94 fprintf(stderr,
"%s: bad protocol, no password\n",
104 user = (
char *)malloc(i+1);
111 if ((
user == NULL) || (
host == NULL))
128 fprintf(stderr,
"%s: unable to set supplementary groups: %s\n",
129 prog, strerror(errno));
134 fprintf(stderr,
"%s: unable to set gid : %s\n",
135 prog, strerror(errno));
140 fprintf(stderr,
"%s: unable to set uid : %s\n",
141 prog, strerror(errno));
146 fprintf(stderr,
"%s: unable to change to home dir (%s): %s\n",
151 execvp(argv[1], argv + 1);
152 fprintf(stderr,
"%s: unable to exec %s: %s\n",
prog, argv[1],
159 char *attrs[] = { NULL };
163 LDAPMessage *res, *entry;
168 fprintf(stderr,
"%s: unable to initialise ldap connection\n",
183 fprintf(stderr,
"%s: ldap search failed: %s\n",
prog,
184 ldap_err2string(ret));
188 entry = ldap_first_entry(ld, res);
194 dn = ldap_get_dn(ld, res);
198 ret = ldap_simple_bind_s(ld, dn,
password);
210 char *attrs[] = { NULL };
214 LDAPMessage *res, *entry;
219 fprintf(stderr,
"%s: unable to initialise ldap connection\n",
234 fprintf(stderr,
"%s: ldap search failed: %s\n",
prog,
235 ldap_err2string(ret));
239 entry = ldap_first_entry(ld, res);
244 if (values && values[0])
246 homeparam = malloc(strlen(values[0]) + strlen(
"../../") + 1);
int main(int argc, char *argv[])
int _ldap_get_home_param(void)
#define MAIL_ACCOUNT_NAME