/*************************************************************************/ /* LDAPCONF - Linuxconf module for LDAP operation. Copyright (C) 1999,2000,2001 Stein Vråle This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public License for more details. **************************************************************************/ /*! LDAPCONF_SETUP.cc This is the setup dialog for the module itself. It define global defaults, available features, and what type of ldap operations (submodules) the user want ldapconf to handle on this host. Most people would need Client and Profiles, on some networks Auth will be needed, and some admins may try the Server and Directory submod for operating a server. **************************************************************************/ #include #include #include #include #include #include "ldapconf_defs.h" static const char K_LDAPCONF[] = "ldapconf"; /*! LDAPconf module setup dialog */ void ldapconf_setup() { ldapconf_setup_read(); int nof=0; // Have to do this to get the stupid radio button work with integer val char ldap_protocol = atoi(mode_ldap_protocol.get()); char openldap_version = atoi(mode_openldap_version.get()); DIALOG dia; // Services/features dia.newf_title (MSG_U(I_LDAPCONF_INFO,"Info"),1,"",MSG_R(I_LDAPCONF_INFO)); // Check timestamp or release to make sure you are using the latest build dia.newf_info(MSG_U(I_LDAPCONF_VERSION,"LDAPconf release number"),module_version); dia.newf_info(MSG_U(I_LDAPCONF_DATE,"LDAPconf build timestamp"),__DATE__ " " __TIME__); dia.newf_title (MSG_U(I_MODE_APPS,"Services"),1,"",MSG_R(I_MODE_APPS)); char old_mode_posix_accounts = mode_posix_accounts; dia.newf_chk (MSG_U(F_POSIX_ACCOUNTS,"Manage linux accounts") ,mode_posix_accounts ,MSG_U(I_POSIX_ACCOUNTS,"in LDAP")); dia.newf_info ("",MSG_U(I_POSIX_ACCOUNTS2,"Configure the posix_accounts profile")); dia.newf_chk (MSG_U(F_MODE_FORMCLIENT,"Formclient service"),mode_ldap_formclient,"Enable"); dia.newf_chk (MSG_U(F_MODE_WWWCLIENT,"WWW formclient"),mode_ldap_wwwclient,"Enable"); dia.newf_chk (MSG_U(F_MODE_USERINFO,"User info service"),mode_ldap_userinfo,"Enable"); dia.newf_chk (MSG_U(F_MODE_PWSYNC,"Update ldap password from userconf"),mode_ldap_pwsync,"Enable"); if (mode_ldap_devel) { dia.newf_chk (MSG_U(F_MODE_USERACCOUNT,"User account service") ,mode_ldap_useraccount ,"Enable"); } dia.newf_radio (MSG_U(F_MODE_LDAP_PROTOCOL,"Default LDAP protocol"),ldap_protocol,2,"v2"); dia.newf_radio("",ldap_protocol,3,"v3"); dia.newf_str (MSG_U(F_SLAPD_USER,"slapd daemon user"),mode_slapd_user); dia.newf_str (MSG_U(F_SLAPD_GROUP,"slapd daemon group"),mode_slapd_group); dia.newf_str (MSG_U(F_LOGFILE,"Logfile"),mode_logfile); dia.newf_num (MSG_U(F_LOGLEVEL,"Loglevel (0-7)"),mode_loglevel); // Submodules dia.newf_title (MSG_U(I_MODE_PARTS,"Submodules"),1,"",MSG_R(I_MODE_PARTS)); dia.newf_chk (MSG_U(F_MODE_CLIENT,"LDAP Client"),mode_ldap_client,"Enable"); dia.newf_chk (MSG_U(F_MODE_SYSTEM,"LDAP Auth"),mode_ldap_system,"Enable"); dia.newf_chk (MSG_U(F_MODE_PROFILE,"LDAP Profile"),mode_ldap_profile,"Enable"); dia.newf_chk (MSG_U(F_MODE_SERVER,"LDAP Server"),mode_ldap_server,"Enable"); dia.newf_chk (MSG_U(F_MODE_DIRECTORY,"LDAP Directory"),mode_ldap_directory,"Enable"); // OpenLDAP config dia.newf_title (MSG_U(I_MODE_OPENLDAP,"OpenLDAP"),1,"",MSG_R(I_MODE_OPENLDAP)); dia.newf_str (MSG_U(F_MODE_OPENLDAP_PARAMS,"Parameters"),mode_openldap_params); dia.newf_radio(MSG_U(F_MODE_OPENLDAP_VERSION,"Version"),openldap_version,1,"v 1.x"); dia.newf_radio("",openldap_version,2,"v 2.x"); // Development D(dia.newf_title (MSG_U(I_MODE_DEVEL,"Devel"),1,"",MSG_R(I_MODE_DEVEL))); D(dia.newf_chk (MSG_U(F_MODE_DEVEL,"Devel dialogs"),mode_ldap_devel,"Enable")); D(dia.newf_num (MSG_U(F_MODE_DEBUG,"Debug level"),mode_ldap_debug)); while (1) { MENU_STATUS code = dia.edit ( MSG_U(T_LDAPCONF_SETUP,"LDAPconf module setup") ,MSG_U(I_LDAPCONF_SETUP ,"Use this dialog to control ldapconf module menus/dialogs.\n" "These settings will only affect ldapconf itself,\n" "not external packages like openldap,pam,nss etc.") ,help_setup ,nof); /* Exit */ if (code == MENU_CANCEL || code == MENU_ESCAPE){ break; } /* Save */ else if (code == MENU_ACCEPT){ loghandler_init(0,mode_logfile.get(),MAIN_LOG,mode_loglevel,SHOW_DATE | SHOW_TIME | SHOW_LEVEL); D(loghandler_init(1,"/var/log/ldapconf.debug",MAIN_LOG,mode_ldap_debug + 8, SHOW_CLASS | SHOW_LEVEL)); // Radiobutton fix mode_ldap_protocol.setfrom(ldap_protocol); mode_openldap_version.setfrom(openldap_version); ldapconf_setup_write(); if (old_mode_posix_accounts != mode_posix_accounts){ xconf_notice (MSG_U(N_POSIX_ACCOUNTS ,"You have changed the way user accounts are managed.\n" "You must restart Linuxconf to enable this change.")); } break; } } } /*! Read ldapconf module setup */ void ldapconf_setup_read() { CONFDB c_ldapconf(f_ldapconf); mode_ldap_client = c_ldapconf.getvalnum (K_LDAPCONF,"client",1); mode_ldap_server = c_ldapconf.getvalnum (K_LDAPCONF,"server",0); mode_ldap_system = c_ldapconf.getvalnum (K_LDAPCONF,"system",1); mode_ldap_profile = c_ldapconf.getvalnum (K_LDAPCONF,"profile",1); mode_ldap_directory = c_ldapconf.getvalnum (K_LDAPCONF,"directory",1); mode_ldap_userinfo = c_ldapconf.getvalnum (K_LDAPCONF,"userinfo",1); mode_ldap_pwsync = c_ldapconf.getvalnum (K_LDAPCONF,"pwsync",1); mode_ldap_formclient = c_ldapconf.getvalnum (K_LDAPCONF,"formclient",1); mode_ldap_useraccount = c_ldapconf.getvalnum (K_LDAPCONF,"useraccount",0); mode_ldap_wwwclient = c_ldapconf.getvalnum (K_LDAPCONF,"wwwclient",0); mode_ldap_devel = c_ldapconf.getvalnum (K_LDAPCONF,"devel",0); mode_ldap_debug = c_ldapconf.getvalnum (K_LDAPCONF,"debug",0); mode_ldap_protocol = c_ldapconf.getval (K_LDAPCONF,"protocol","2"); // Default is LDAP protocol 2 mode_openldap_params = c_ldapconf.getval (K_LDAPCONF,"openldap_params"); mode_openldap_version = c_ldapconf.getval (K_LDAPCONF,"openldap_version","1"); // OpenLDAP 1.x is default until 2.x is more common mode_slapd_user = c_ldapconf.getval (K_LDAPCONF,"slapd_user","ldap"); mode_slapd_group = c_ldapconf.getval (K_LDAPCONF,"slapd_group","ldap"); mode_logfile = c_ldapconf.getval (K_LDAPCONF,"logfile","/var/log/ldapconf.log"); mode_loglevel = c_ldapconf.getvalnum (K_LDAPCONF,"loglevel",0); mode_posix_accounts = c_ldapconf.getvalnum (K_LDAPCONF,"posix_accounts",0); } /*! Save ldapconf module setup */ void ldapconf_setup_write() { CONFDB c_ldapconf(f_ldapconf); c_ldapconf.setcursys(subsys_ldap); c_ldapconf.replace (K_LDAPCONF,"client",mode_ldap_client); c_ldapconf.replace (K_LDAPCONF,"server",mode_ldap_server); c_ldapconf.replace (K_LDAPCONF,"system",mode_ldap_system); c_ldapconf.replace (K_LDAPCONF,"profile",mode_ldap_profile); c_ldapconf.replace (K_LDAPCONF,"directory",mode_ldap_directory); c_ldapconf.replace (K_LDAPCONF,"userinfo",mode_ldap_userinfo); c_ldapconf.replace (K_LDAPCONF,"pwsync",mode_ldap_pwsync); c_ldapconf.replace (K_LDAPCONF,"formclient",mode_ldap_formclient); c_ldapconf.replace (K_LDAPCONF,"useraccount",mode_ldap_useraccount); c_ldapconf.replace (K_LDAPCONF,"wwwclient",mode_ldap_wwwclient); c_ldapconf.replace (K_LDAPCONF,"devel",mode_ldap_devel); c_ldapconf.replace (K_LDAPCONF,"debug",mode_ldap_debug); c_ldapconf.replace (K_LDAPCONF,"protocol",mode_ldap_protocol); c_ldapconf.replace (K_LDAPCONF,"openldap_params",mode_openldap_params); c_ldapconf.replace (K_LDAPCONF,"openldap_version",mode_openldap_version); c_ldapconf.replace (K_LDAPCONF,"slapd_user",mode_slapd_user); c_ldapconf.replace (K_LDAPCONF,"slapd_group",mode_slapd_group); c_ldapconf.replace (K_LDAPCONF,"logfile",mode_logfile); c_ldapconf.replace (K_LDAPCONF,"loglevel",mode_loglevel); c_ldapconf.replace (K_LDAPCONF,"posix_accounts",mode_posix_accounts); c_ldapconf.save(&p_ldap_admin); } #include static PUBLISH_VARIABLES_MSG setup_var_list1[]={ {"manageaccounts",P_MSG_R(F_POSIX_ACCOUNTS)}, {"formclient",P_MSG_R(F_MODE_FORMCLIENT)}, {"wwwformclient",P_MSG_R(F_MODE_WWWCLIENT)}, {"userinfo",P_MSG_R(F_MODE_USERINFO)}, {"updatepwd",P_MSG_R(F_MODE_PWSYNC)}, {"ldapprotocol",P_MSG_R(F_MODE_LDAP_PROTOCOL)}, {"sladpuser",P_MSG_R(F_SLAPD_USER)}, {"slapdgroup",P_MSG_R(F_SLAPD_GROUP)}, {"logfile",P_MSG_R(F_LOGFILE)}, {"loglevel",P_MSG_R(F_LOGLEVEL)}, {"ldapclient",P_MSG_R(F_MODE_CLIENT)}, {"ldapauth",P_MSG_R(F_MODE_SYSTEM)}, {"ldapprofiles",P_MSG_R(F_MODE_PROFILE)}, {"ldapserver",P_MSG_R(F_MODE_SERVER)}, {"ldapdirectory",P_MSG_R(F_MODE_DIRECTORY)}, {"parameters",P_MSG_R(F_MODE_OPENLDAP_PARAMS)}, {"openldapver",P_MSG_R(F_MODE_OPENLDAP_VERSION)}, { NULL, NULL } }; static REGISTER_VARIABLES main_registry1("ldapsetup",setup_var_list1 ,NULL,ldapconf_setup);