Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 113791
Collapse All | Expand All

(-)./vpopmail-5.4.13.orig/vldap.c (-1 / +71 lines)
Lines 1335-1341 Link Here
1335
    /* Set verror here and unset it when successful, is ok, because if one of these
1335
    /* Set verror here and unset it when successful, is ok, because if one of these
1336
    three steps fail the whole auth_connection failed */
1336
    three steps fail the whole auth_connection failed */
1337
    verrori = VA_NO_AUTH_CONNECTION;
1337
    verrori = VA_NO_AUTH_CONNECTION;
1338
1338
    
1339
    if (ldap_load_config != 0)
1340
    {
1341
        ldap_perror(ld,"Failed to read LDAP-Configuration");
1342
	return -99;
1343
    }
1344
    
1339
    ld = ldap_init(VLDAP_SERVER, VLDAP_PORT);
1345
    ld = ldap_init(VLDAP_SERVER, VLDAP_PORT);
1340
    if (ld == NULL) {
1346
    if (ld == NULL) {
1341
        ldap_perror(ld,"Failed to inititialize LDAP-Connection");
1347
        ldap_perror(ld,"Failed to inititialize LDAP-Connection");
Lines 1404-1406 Link Here
1404
1410
1405
/***************************************************************************/
1411
/***************************************************************************/
1406
1412
1413
int load_ldap_config (void)
1414
{
1415
    char configfile[256];
1416
    char configline[1024];
1417
    char key[1024];
1418
    char *value;    
1419
    FILE *fp;
1420
1421
    sprintf(configfile, "%s/etc/%s", VPOPMAILDIR, "vpopmail.ldap");
1422
1423
    fp = fopen(configfile, "r");
1424
    if (fp == NULL)
1425
    {
1426
        fprintf(stderr, "vldap: can't read settings from %s\n", configfile);
1427
	return(VA_NO_AUTH_CONNECTION);
1428
    }
1429
1430
    while (fgets(configline, sizeof(configline), fp))
1431
    {
1432
	if (configline[0] == '\n' || configline[0] == '#' || configline[0] == ' ') continue;
1433
	strcpy(key,configline);
1434
	value = strstr(configline,"=");
1435
	value++;
1436
	value[strlen(value)-1] = '\0';
1437
	strtok(key, " ");
1438
	if (strcmp(key,"server") == 0)
1439
	{
1440
		if (VLDAP_SERVER != NULL)
1441
			free (VLDAP_SERVER);
1442
		VLDAP_SERVER = (char *) safe_strdup(value);
1443
	}
1444
	else if (strcmp(key,"port") == 0) 
1445
	    VLDAP_PORT = atoi(value);
1446
	else if (strcmp(key,"user") == 0)
1447
	{
1448
		if (VLDAP_USER != NULL)
1449
			free (VLDAP_USER);
1450
		VLDAP_USER = (char *) safe_strdup(value);
1451
	}
1452
	else if (strcmp(key,"password") == 0)
1453
	{
1454
		if (VLDAP_PASSWORD != NULL)
1455
			free (VLDAP_PASSWORD);
1456
		VLDAP_PASSWORD = (char *) safe_strdup(value);
1457
	}
1458
	else if (strcmp(key,"basedn") == 0)
1459
	{
1460
		if (VLDAP_BASEDN != NULL)
1461
			free (VLDAP_BASEDN);
1462
		VLDAP_BASEDN = (char *) safe_strdup(value);
1463
	}
1464
    }
1465
    
1466
    // check for values
1467
    if (VLDAP_SERVER == NULL || VLDAP_USER == NULL || VLDAP_PASSWORD == NULL || VLDAP_BASEDN == NULL)
1468
    {
1469
        fprintf(stderr, "vldap: some required settings missing in %s\n", configfile);
1470
	return(VA_NO_AUTH_CONNECTION);
1471
    }
1472
    
1473
    return 0;
1474
}
1475
1476
/***************************************************************************/
(-)./vpopmail-5.4.13.orig/vldap.h (-5 / +7 lines)
Lines 28-38 Link Here
28
#ifndef VPOPMAIL_LDAP_H
28
#ifndef VPOPMAIL_LDAP_H
29
#define VPOPMAIL_LDAP_H
29
#define VPOPMAIL_LDAP_H
30
30
31
#define VLDAP_SERVER "localhost"
31
char *VLDAP_SERVER;
32
#define VLDAP_PORT LDAP_PORT
32
int VLDAP_PORT = 389;
33
#define VLDAP_USER "cn=vpopmailuser, o=vpopmail"
33
char *VLDAP_USER;
34
#define VLDAP_PASSWORD "vpoppasswd"
34
char *VLDAP_PASSWORD;
35
#define VLDAP_BASEDN "o=vpopmail"
35
char *VLDAP_BASEDN;
36
37
int ldap_load_config();
36
38
37
#define MAX_BUFF 500
39
#define MAX_BUFF 500
38
40

Return to bug 113791