From 3a19cd6cdf382ccb6c693401ea41a03232165ca8 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 17 Jan 2004 04:23:28 +0000 Subject: [PATCH] * Sysconfig commands for specifying where the LDAP server lives --- citadel/ChangeLog | 4 ++++ citadel/citadel.h | 6 ++++-- citadel/citadel_ipc.c | 1 + citadel/citserver.c | 5 +++++ citadel/control.c | 16 ++++++++++++++++ citadel/ipcdef.h | 1 + citadel/routines2.c | 27 +++++++++++++++++++++++---- citadel/serv_upgrade.c | 4 ++++ citadel/serv_vandelay.c | 4 ++++ citadel/techdoc/session.txt | 7 +++++++ 10 files changed, 69 insertions(+), 6 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index d14b0a067..029ac20ae 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ + Revision 614.4 2004/01/17 04:23:28 ajc + * Sysconfig commands for specifying where the LDAP server lives + Revision 614.3 2004/01/17 03:26:17 ajc * Changed a diagnostic in msgbase.c to a higher logging level so it doesn't make as much noise. @@ -5222,3 +5225,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/citadel.h b/citadel/citadel.h index 3d74cec02..b88dc9d4e 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -44,9 +44,9 @@ extern "C" { * usually more strict because you're not really supposed to dump/load and * upgrade at the same time. */ -#define REV_LEVEL 614 /* This version */ +#define REV_LEVEL 615 /* This version */ #define REV_MIN 591 /* Oldest compatible database */ -#define EXPORT_REV_MIN 614 /* Oldest compatible export files */ +#define EXPORT_REV_MIN 615 /* Oldest compatible export files */ #define SERVER_TYPE 0 /* zero for stock Citadel/UX; other developers please obtain SERVER_TYPE codes for your implementations */ @@ -130,6 +130,8 @@ struct config { char c_aideroom[ROOMNAMELEN]; /* Name of aideroom (Aide) */ int c_purge_hour; /* Hour during which db purges run */ struct ExpirePolicy c_mbxep; /* Expire policy for mailbox rooms */ + char c_ldap_host[128]; /* Host where LDAP service lives */ + int c_ldap_port; /* Port on host where LDAP lives */ }; /* diff --git a/citadel/citadel_ipc.c b/citadel/citadel_ipc.c index 7f26170b9..9ef8c5174 100644 --- a/citadel/citadel_ipc.c +++ b/citadel/citadel_ipc.c @@ -645,6 +645,7 @@ int CtdlIPCServerInfo(CtdlIPC *ipc, struct CtdlServInfo *ServInfo, char *cret) case 11: ServInfo->serv_paging_level = atoi(buf); break; case 13: ServInfo->serv_supports_qnop = atoi(buf); + case 14: ServInfo->serv_supports_ldap = atoi(buf); break; } } diff --git a/citadel/citserver.c b/citadel/citserver.c index 7c6492a2a..887b4ae39 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -343,6 +343,11 @@ void cmd_info(void) { cprintf("1\n"); /* 1 = we support the extended paging options */ cprintf("%s\n", CC->cs_nonce); cprintf("1\n"); /* 1 = yes, this system supports the QNOP command */ +#ifdef HAVE_LDAP + cprintf("1\n"); /* 1 = yes, this server is LDAP-enabled */ +#else + cprintf("0\n"); /* 1 = no, this server is not LDAP-enabled */ +#endif cprintf("000\n"); } diff --git a/citadel/control.c b/citadel/control.c index 01d2e9d80..207291faf 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -196,6 +196,13 @@ void cmd_conf(char *argbuf) cprintf("%d\n", config.c_disable_newu); cprintf("%d\n", config.c_aide_mailboxes); cprintf("%d\n", config.c_purge_hour); +#ifdef HAVE_LDAP + cprintf("%s\n", config.c_ldap_host); + cprintf("%d\n", config.c_ldap_port); +#else + cprintf("\n"); + cprintf("0\n"); +#endif cprintf("000\n"); } @@ -335,6 +342,15 @@ void cmd_conf(char *argbuf) config.c_purge_hour = atoi(buf); } break; +#ifdef HAVE_LDAP + case 32: + safestrncpy(config.c_ldap_host, buf, + sizeof config.c_ldap_host); + break; + case 33: + config.c_ldap_port = atoi(buf); + break; +#endif } ++a; } diff --git a/citadel/ipcdef.h b/citadel/ipcdef.h index 6f2e26b84..36b82633a 100644 --- a/citadel/ipcdef.h +++ b/citadel/ipcdef.h @@ -45,6 +45,7 @@ struct CtdlServInfo { int serv_ok_floors; int serv_paging_level; int serv_supports_qnop; + int serv_supports_ldap; }; #define QR_PERMANENT 1 /* Room does not purge */ diff --git a/citadel/routines2.c b/citadel/routines2.c index c3d4269f9..640a16e68 100644 --- a/citadel/routines2.c +++ b/citadel/routines2.c @@ -642,8 +642,11 @@ void read_bio(CtdlIPC *ipc) */ void do_system_configuration(CtdlIPC *ipc) { + +#define NUM_CONFIGS 34 + char buf[SIZ]; - char sc[32][SIZ]; + char sc[NUM_CONFIGS][SIZ]; char *resp = NULL; struct ExpirePolicy *site_expirepolicy = NULL; struct ExpirePolicy *mbx_expirepolicy = NULL; @@ -661,7 +664,7 @@ void do_system_configuration(CtdlIPC *ipc) while (strlen(resp)) { extract_token(buf, resp, 0, '\n'); remove_token(resp, 0, '\n'); - if (a < 32) { + if (a < NUM_CONFIGS) { strcpy(&sc[a][0], buf); } ++a; @@ -747,6 +750,22 @@ void do_system_configuration(CtdlIPC *ipc) a = (a ? 0 : 1); snprintf(sc[25], sizeof sc[25], "%d", a); + /* LDAP settings */ + if (serv_info.serv_supports_qnop) { + a = strlen(&sc[32][0]); + a = (a ? 1 : 0); /* Set only to 1 or 0 */ + a = boolprompt("Connect this Citadel to an LDAP directory", a); + if (a) { + strprompt("Host name of LDAP server", + &sc[32][0], 127); + strprompt("Port number of LDAP service", + &sc[33][0], 5); + } + else { + strcpy(&sc[32][0], ""); + } + } + /* Expiry settings */ strprompt("Default user purge time (days)", &sc[16][0], 5); strprompt("Default room purge time (days)", &sc[17][0], 5); @@ -811,14 +830,14 @@ void do_system_configuration(CtdlIPC *ipc) scr_printf("Save this configuration? "); if (yesno()) { r = 1; - for (a = 0; a < 32; a++) + for (a = 0; a < NUM_CONFIGS; a++) r += 1 + strlen(sc[a]); resp = (char *)calloc(1, r); if (!resp) { err_printf("Can't save config - out of memory!\n"); logoff(ipc, 1); } - for (a = 0; a < 32; a++) { + for (a = 0; a < NUM_CONFIGS; a++) { strcat(resp, sc[a]); strcat(resp, "\n"); } diff --git a/citadel/serv_upgrade.c b/citadel/serv_upgrade.c index 5edbb9138..8a8c49213 100644 --- a/citadel/serv_upgrade.c +++ b/citadel/serv_upgrade.c @@ -164,6 +164,10 @@ void update_config(void) { config.c_purge_hour = 3; } + if (CitControl.version < 615) { + config.c_ldap_port = 389; + } + put_config(); } diff --git a/citadel/serv_vandelay.c b/citadel/serv_vandelay.c index 831535029..4dc0a2c39 100644 --- a/citadel/serv_vandelay.c +++ b/citadel/serv_vandelay.c @@ -285,6 +285,8 @@ void artv_do_export(void) { cprintf("%d\n", config.c_purge_hour); cprintf("%d\n", config.c_mbxep.expire_mode); cprintf("%d\n", config.c_mbxep.expire_value); + cprintf("%s\n", config.c_ldap_host); + cprintf("%d\n", config.c_ldap_port); /* Export the control file */ get_control(); @@ -344,6 +346,8 @@ void artv_import_config(void) { client_gets(buf); config.c_purge_hour = atoi(buf); client_gets(buf); config.c_mbxep.expire_mode = atoi(buf); client_gets(buf); config.c_mbxep.expire_value = atoi(buf); + client_gets(config.c_ldap_host); + client_gets(buf); config.c_ldap_port = atoi(buf); put_config(); lprintf(7, "Imported config file\n"); } diff --git a/citadel/techdoc/session.txt b/citadel/techdoc/session.txt index 69942b0a8..10a4b9519 100644 --- a/citadel/techdoc/session.txt +++ b/citadel/techdoc/session.txt @@ -590,6 +590,8 @@ parts of the listing: authentication. If this field is present, clients may authenticate in this manner. Line 14 - Set to nonzero if this server supports the QNOP command. + Line 15 - Set to nonzero if this server is capable of connecting to a + directory service using LDAP. *** NOTE! *** The "server type" code is intended to promote global compatibility in a scenario in which developers have added proprietary @@ -1755,12 +1757,17 @@ fails for any reason, ERROR is returned. 30. Flag (0 or 1) - disable self-service new user registration 31. Flag (0 or 1) - Aides are allowed access to all mailboxes 32. Hour (0 through 23) during which database auto-purge jobs are run + 33. Name of host where an LDAP service may be found + 34. Port number of LDAP service on above host CONF also accepts two additional commands: GETSYS and PUTSYS followed by an arbitrary MIME type (such as application/x-citadel-internet-config) which provides a means of storing generic configuration data in the Global System Configuration room without the need to add extra get/set commands to the server. + + Please note that the LDAP-specific configs have no effect on Citadel servers +in which LDAP support is not enabled. -- 2.39.2