* Fleshed out contemplate_ldap() a bit
authorArt Cancro <ajc@citadel.org>
Fri, 27 Aug 2004 21:39:33 +0000 (21:39 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 27 Aug 2004 21:39:33 +0000 (21:39 +0000)
citadel/ChangeLog
citadel/Makefile.in
citadel/setup.c

index 0be477ce15b0c69894f5f9252c36c3a6c5675673..d71ddc8f4c169244759361e5302be1e36e3e629a 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 625.1  2004/08/27 21:39:33  ajc
+ * Fleshed out contemplate_ldap() a bit
+
  Revision 625.0  2004/08/27 21:06:30  ajc
  * THIS IS 6.25
 
@@ -6000,3 +6003,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index 907288b7eb8295fd649b50c3d085f773bc516dbb..1465b41cc4cb874d602c0c3f0898242734223a5a 100644 (file)
@@ -22,7 +22,7 @@ all: $(TARGETS)
 EXEEXT=@EXEEXT@
 
 CLIENT_TARGETS=citadel$(EXEEXT) whobbs$(EXEEXT) stress$(EXEEXT)
-SERVER_TARGETS=citserver setup $(CHKPWD)
+SERVER_TARGETS=citserver setup $(CHKPWD) citadel-openldap.schema
 SERV_MODULES=serv_chat.o \
        serv_upgrade.o \
        serv_smtp.o \
index 123eb53c6b1a203dc1481197e4eefe3f28352c0b..35f783d31024f4ce2481e9b50894428566690b17 100644 (file)
@@ -46,7 +46,9 @@ char setup_directory[SIZ];
 char init_entry[SIZ];
 int using_web_installer = 0;
 
+#ifdef HAVE_LDAP
 void contemplate_ldap(void);
+#endif
 
 char *setup_titles[] =
 {
@@ -1081,8 +1083,10 @@ NEW_INST:
        chmod("citadel.config", S_IRUSR | S_IWUSR);
        progress("Setting file permissions", 4, 4);
 
+#ifdef HAVE_LDAP
        /* Contemplate the possibility of auto-configuring OpenLDAP */
-       /* contemplate_ldap(); */
+       contemplate_ldap();
+#endif
 
        /* See if we can start the Citadel service. */
        if (strlen(init_entry) > 0) {
@@ -1112,19 +1116,21 @@ NEW_INST:
 }
 
 
+#ifdef HAVE_LDAP
 /*
  * If we're in the middle of an Easy Install, we might just be able to
  * auto-configure a standalone OpenLDAP server.
  */
 void contemplate_ldap(void) {
        char question[SIZ];
-       char base_dn[SIZ];
        FILE *fp;
 
        /* If conditions are not ideal, give up on this idea. */
        if (using_web_installer == 0) return;
        if (getenv("LDAP_CONFIG") == NULL) return;
+       if (getenv("SUPPORT") == NULL) return;
        if (getenv("SLAPD_BINARY") == NULL) return;
+       if (getenv("CITADEL") == NULL) return;
 
        /* Otherwise, prompt the user to create an entry. */
        snprintf(question, sizeof question,
@@ -1139,7 +1145,7 @@ void contemplate_ldap(void) {
        if (yesno(question) == 0)
                return;
 
-       strcpy(base_dn, "dc=example,dc=com");
+       strcpy(config.c_ldap_base_dn, "dc=example,dc=com");
        strprompt("Base DN",
                "\n"
                "Please enter the Base DN for your directory.  This will\n"
@@ -1147,9 +1153,18 @@ void contemplate_ldap(void) {
                "which you receive mail, but it doesn't have to be.  Your\n"
                "LDAP tree will be built using this Distinguished Name.\n"
                "\n",
-               base_dn
+               config.c_ldap_base_dn
        );
 
+       strcpy(config.c_ldap_host, "localhost");
+       config.c_ldap_port = 389;
+       sprintf(config.c_ldap_bind_dn, "cn=manager,%s", config.c_ldap_base_dn);
+
+       /* FIXME ... make the generated password harder to guess */
+       sprintf(config.c_ldap_bind_pw, "%d%ld", getpid(), time(NULL));
+
+       write_config_to_disk();
+
        fp = fopen(getenv("LDAP_CONFIG"), "w");
        if (fp == NULL) {
                sprintf(question, "\nCannot create %s:\n%s\n\n"
@@ -1161,6 +1176,27 @@ void contemplate_ldap(void) {
                important_message("Error", question);
                return;
        }
-       fprintf(fp, "FIXME\n");
+
+       fprintf(fp, "include    %s/citadel-openldap.schema\n",
+               getenv("CITADEL"));
+       fprintf(fp, "pidfile    %s/openldap-data/slapd.pid\n",
+               getenv("CITADEL"));
+       fprintf(fp, "argsfile   %s/openldap-data/slapd.args\n",
+               getenv("CITADEL"));
+       fprintf(fp,     "allow          bind_v2\n"
+                       "database       bdb\n"
+                       "schemacheck    off\n"
+       );
+       fprintf(fp,     "suffix         \"%s\"\n", config.c_ldap_base_dn);
+       fprintf(fp,     "rootdn         \"%s\"\n", config.c_ldap_bind_dn);
+       fprintf(fp,     "rootpw         %s\n", config.c_ldap_bind_pw);
+       fprintf(fp,     "directory      %s/openldap-data\n",
+               getenv("CITADEL"));
+       fprintf(fp,     "index          objectClass     eq\n");
+
        fclose(fp);
+
+       /* This is where our OpenLDAP server will keep its data. */
+       mkdir("openldap-data", 0700);
 }
+#endif /* HAVE_LDAP */