Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ldapconf_setup.cc

Go to the documentation of this file.
00001 /*************************************************************************/
00002 /*  LDAPCONF - Linuxconf module for LDAP operation.
00003     
00004     Copyright (C) 1999,2000,2001 Stein Vråle <stein@terminator.net>
00005 
00006     This program is distributed in the hope that it will be useful,
00007     but WITHOUT ANY WARRANTY; without even the implied warranty of
00008     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
00009     GNU General Public License for more details.
00010     
00011 **************************************************************************/
00012 /*! LDAPCONF_SETUP.cc
00013 
00014     This is the setup dialog for the module itself.
00015     It define global defaults, available features, and what type of
00016     ldap operations (submodules) the user want ldapconf to handle on 
00017     this host.
00018     
00019     Most people would need Client and Profiles, on some networks Auth 
00020     will be needed, and some admins may try the Server and Directory submod
00021     for operating a server.
00022 
00023 **************************************************************************/
00024 #include <ctype.h>
00025 #include <stdlib.h>
00026 #include <confdb.h>
00027 #include <dialog.h>
00028 #include <misc.h>
00029 #include "ldapconf_defs.h"
00030 
00031 static const char K_LDAPCONF[] = "ldapconf";
00032 
00033 /*!
00034 
00035     LDAPconf module setup dialog
00036 
00037 */
00038 void ldapconf_setup()
00039 {       
00040     ldapconf_setup_read();
00041 
00042     int nof=0;
00043 
00044     // Have to do this to get the stupid radio button work with integer val
00045     char ldap_protocol = atoi(mode_ldap_protocol.get());
00046     char openldap_version = atoi(mode_openldap_version.get());
00047 
00048     DIALOG dia;
00049 
00050     //  Services/features
00051     dia.newf_title (MSG_U(I_LDAPCONF_INFO,"Info"),1,"",MSG_R(I_LDAPCONF_INFO));
00052     // Check timestamp or release to make sure you are using the latest build
00053     dia.newf_info(MSG_U(I_LDAPCONF_VERSION,"LDAPconf release number"),LDAPCONF_RELEASE);
00054     dia.newf_info(MSG_U(I_LDAPCONF_DATE,"LDAPconf build timestamp"),__DATE__ " "  __TIME__); 
00055 
00056     dia.newf_title (MSG_U(I_MODE_APPS,"Services"),1,"",MSG_R(I_MODE_APPS)); 
00057     dia.newf_chk (MSG_U(F_MODE_FORMCLIENT,"Formclient service"),mode_ldap_formclient,"Enable");
00058     dia.newf_chk (MSG_U(F_MODE_WWWCLIENT,"WWW formclient"),mode_ldap_wwwclient,"Enable");
00059     dia.newf_chk (MSG_U(F_MODE_USERINFO,"User info service"),mode_ldap_userinfo,"Enable");
00060     dia.newf_chk (MSG_U(F_MODE_PWSYNC,"Update ldap password from userconf"),mode_ldap_pwsync,"Enable");
00061     if (mode_ldap_devel) {
00062         dia.newf_chk (MSG_U(F_MODE_USERACCOUNT,"User account service")
00063                       ,mode_ldap_useraccount
00064                       ,"Enable");
00065     }
00066     dia.newf_radio (MSG_U(F_MODE_LDAP_PROTOCOL,"Default LDAP protocol"),ldap_protocol,2,"v2");
00067     dia.newf_radio("",ldap_protocol,3,"v3");
00068     dia.newf_str (MSG_U(F_SLAPD_USER,"slapd daemon user"),mode_slapd_user);
00069     dia.newf_str (MSG_U(F_SLAPD_GROUP,"slapd daemon group"),mode_slapd_group);
00070     dia.newf_str (MSG_U(F_LOGFILE,"Logfile"),mode_logfile);
00071     dia.newf_num (MSG_U(F_LOGLEVEL,"Loglevel (0-7)"),mode_loglevel);
00072 
00073     //  Submodules
00074     dia.newf_title (MSG_U(I_MODE_PARTS,"Submodules"),1,"",MSG_R(I_MODE_PARTS));
00075     dia.newf_chk (MSG_U(F_MODE_CLIENT,"LDAP Client"),mode_ldap_client,"Enable");
00076     dia.newf_chk (MSG_U(F_MODE_SYSTEM,"LDAP Auth"),mode_ldap_system,"Enable");
00077     dia.newf_chk (MSG_U(F_MODE_PROFILE,"LDAP Profile"),mode_ldap_profile,"Enable");
00078     dia.newf_chk (MSG_U(F_MODE_SERVER,"LDAP Server"),mode_ldap_server,"Enable");    
00079     dia.newf_chk (MSG_U(F_MODE_DIRECTORY,"LDAP Directory"),mode_ldap_directory,"Enable");
00080 
00081     //  OpenLDAP config
00082     dia.newf_title (MSG_U(I_MODE_OPENLDAP,"OpenLDAP"),1,"",MSG_R(I_MODE_OPENLDAP));
00083     dia.newf_str (MSG_U(F_MODE_OPENLDAP_PARAMS,"Parameters"),mode_openldap_params);
00084     dia.newf_radio(MSG_U(F_MODE_OPENLDAP_VERSION,"Version"),openldap_version,1,"v 1.x");
00085     dia.newf_radio("",openldap_version,2,"v 2.x");
00086 
00087     //  Development
00088     D(dia.newf_title (MSG_U(I_MODE_DEVEL,"Devel"),1,"",MSG_R(I_MODE_DEVEL)));
00089     D(dia.newf_chk (MSG_U(F_MODE_DEVEL,"Devel dialogs"),mode_ldap_devel,"Enable"));
00090     D(dia.newf_num (MSG_U(F_MODE_DEBUG,"Debug level"),mode_ldap_debug));
00091 
00092     while (1) {
00093         MENU_STATUS code = dia.edit (
00094             MSG_U(T_LDAPCONF_SETUP,"LDAPconf module setup")
00095             ,MSG_U(I_LDAPCONF_SETUP
00096                    ,"Use this dialog to control ldapconf module menus/dialogs.\n"
00097                    "These settings will only affect ldapconf itself,\n"
00098                    "not external packages like openldap,pam,nss etc.")              
00099             ,help_setup
00100             ,nof);
00101         /* Exit */
00102         if (code == MENU_CANCEL || code == MENU_ESCAPE){
00103             break;
00104         }
00105         /* Save */
00106         else if (code == MENU_ACCEPT){
00107             loghandler_init(0,mode_logfile.get(),MAIN_LOG,mode_loglevel,SHOW_DATE | SHOW_TIME | SHOW_LEVEL);
00108             D(loghandler_init(1,"/tmp/ldapconf.debug",MAIN_LOG,mode_ldap_debug + 8, SHOW_CLASS | SHOW_LEVEL));
00109 
00110             // Radiobutton fix
00111             mode_ldap_protocol.setfrom(ldap_protocol);
00112             mode_openldap_version.setfrom(openldap_version);
00113 
00114             ldapconf_setup_write();
00115             break;
00116         }
00117     }
00118 }
00119 
00120 /*! 
00121 
00122     Read ldapconf module setup
00123 
00124 */
00125 void ldapconf_setup_read()
00126 {
00127     CONFDB c_ldapconf(f_ldapconf);
00128 
00129     mode_ldap_client = c_ldapconf.getvalnum (K_LDAPCONF,"client",1);
00130     mode_ldap_server = c_ldapconf.getvalnum (K_LDAPCONF,"server",0); 
00131     mode_ldap_system = c_ldapconf.getvalnum (K_LDAPCONF,"system",1);
00132     mode_ldap_profile = c_ldapconf.getvalnum (K_LDAPCONF,"profile",1);
00133     mode_ldap_directory = c_ldapconf.getvalnum (K_LDAPCONF,"directory",1);
00134     mode_ldap_userinfo = c_ldapconf.getvalnum (K_LDAPCONF,"userinfo",1);
00135     mode_ldap_pwsync = c_ldapconf.getvalnum (K_LDAPCONF,"pwsync",1);
00136     mode_ldap_formclient = c_ldapconf.getvalnum (K_LDAPCONF,"formclient",1);
00137     mode_ldap_useraccount = c_ldapconf.getvalnum (K_LDAPCONF,"useraccount",0);
00138     mode_ldap_wwwclient = c_ldapconf.getvalnum (K_LDAPCONF,"wwwclient",0);
00139     mode_ldap_devel = c_ldapconf.getvalnum (K_LDAPCONF,"devel",0);
00140     mode_ldap_debug = c_ldapconf.getvalnum (K_LDAPCONF,"debug",0);
00141     mode_ldap_protocol = c_ldapconf.getval (K_LDAPCONF,"protocol","2"); // Default is LDAP protocol 2
00142     mode_openldap_params = c_ldapconf.getval (K_LDAPCONF,"openldap_params");
00143     mode_openldap_version = c_ldapconf.getval (K_LDAPCONF,"openldap_version","1"); // OpenLDAP 1.x is default until 2.x is more common
00144     mode_slapd_user = c_ldapconf.getval (K_LDAPCONF,"slapd_user","ldap");
00145     mode_slapd_group = c_ldapconf.getval (K_LDAPCONF,"slapd_group","ldap");
00146     mode_logfile = c_ldapconf.getval (K_LDAPCONF,"logfile","/var/log/ldapconf.log");
00147     mode_loglevel = c_ldapconf.getvalnum (K_LDAPCONF,"loglevel",0);
00148 }
00149 
00150 /*!
00151 
00152     Save ldapconf module setup
00153 
00154 */
00155 void ldapconf_setup_write()
00156 {
00157     CONFDB c_ldapconf(f_ldapconf);
00158 
00159     c_ldapconf.setcursys(subsys_ldap);
00160     
00161     c_ldapconf.replace (K_LDAPCONF,"client",mode_ldap_client);
00162     c_ldapconf.replace (K_LDAPCONF,"server",mode_ldap_server);
00163     c_ldapconf.replace (K_LDAPCONF,"system",mode_ldap_system);
00164     c_ldapconf.replace (K_LDAPCONF,"profile",mode_ldap_profile);
00165     c_ldapconf.replace (K_LDAPCONF,"directory",mode_ldap_directory);
00166     c_ldapconf.replace (K_LDAPCONF,"userinfo",mode_ldap_userinfo);
00167     c_ldapconf.replace (K_LDAPCONF,"pwsync",mode_ldap_pwsync);
00168     c_ldapconf.replace (K_LDAPCONF,"formclient",mode_ldap_formclient);
00169     c_ldapconf.replace (K_LDAPCONF,"useraccount",mode_ldap_useraccount);
00170     c_ldapconf.replace (K_LDAPCONF,"wwwclient",mode_ldap_wwwclient);
00171     c_ldapconf.replace (K_LDAPCONF,"devel",mode_ldap_devel);
00172     c_ldapconf.replace (K_LDAPCONF,"debug",mode_ldap_debug);
00173     c_ldapconf.replace (K_LDAPCONF,"protocol",mode_ldap_protocol);
00174     c_ldapconf.replace (K_LDAPCONF,"openldap_params",mode_openldap_params);
00175     c_ldapconf.replace (K_LDAPCONF,"openldap_version",mode_openldap_version);
00176     c_ldapconf.replace (K_LDAPCONF,"slapd_user",mode_slapd_user);
00177     c_ldapconf.replace (K_LDAPCONF,"slapd_group",mode_slapd_group);
00178     c_ldapconf.replace (K_LDAPCONF,"logfile",mode_logfile);
00179     c_ldapconf.replace (K_LDAPCONF,"loglevel",mode_loglevel);
00180 
00181     c_ldapconf.save(&p_ldap_admin);
00182 }
00183 
00184 
00185 
00186 
00187 
00188 

Generated at Mon Jan 22 08:35:12 2001 for ldapconf by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000