diff --git a/src/Makefile.am b/src/Makefile.am index 9ac5f38..7e6c5d2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,7 +4,7 @@ METASOURCES = AUTO # Install this plugin in the KDE modules directory kde_module_LTLIBRARIES = kcm_ldap.la -kcm_ldap_la_SOURCES = ldap.cpp ldapconfigbase.ui realmpropertiesdialog.cpp realmpropertiesbase.ui bondrealmpage.cpp bondrealmpagedlg.ui bondfinishpage.cpp bondfinishpagedlg.ui bondwizard.cpp +kcm_ldap_la_SOURCES = ldap.cpp ldapconfigbase.ui realmpropertiesdialog.cpp realmpropertiesbase.ui bondintropage.cpp bondintropagedlg.ui bondrealmpage.cpp bondrealmpagedlg.ui bondfinishpage.cpp bondfinishpagedlg.ui bondwizard.cpp kcm_ldap_la_LIBADD = -lkio $(LIB_TDEUI) kcm_ldap_la_LDFLAGS = -avoid-version -module -no-undefined \ $(all_libraries) diff --git a/src/bondfinishpage.cpp b/src/bondfinishpage.cpp index cec7bfe..813d06c 100644 --- a/src/bondfinishpage.cpp +++ b/src/bondfinishpage.cpp @@ -35,7 +35,7 @@ BondFinishPage::BondFinishPage(TQWidget *parent, const char *name ) : BondFinishPageDlg(parent,name) { - px_introSidebar->setPixmap(UserIcon("step2.png")); + px_introSidebar->setPixmap(UserIcon("step3.png")); } BondFinishPage::~BondFinishPage(){ diff --git a/src/bondintropage.cpp b/src/bondintropage.cpp new file mode 100644 index 0000000..34b6ab0 --- /dev/null +++ b/src/bondintropage.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2012 by Timothy Pearson * + * kb9vqf@pearsoncomputing.net * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * 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. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bondintropage.h" + +BondIntroPage::BondIntroPage(TQWidget *parent, const char *name ) : BondIntroPageDlg(parent,name) { + + px_introSidebar->setPixmap(UserIcon("step1.png")); +} + +BondIntroPage::~BondIntroPage(){ + // +} + +#include "bondintropage.moc" diff --git a/src/bondintropage.h b/src/bondintropage.h new file mode 100644 index 0000000..b172cb9 --- /dev/null +++ b/src/bondintropage.h @@ -0,0 +1,41 @@ +/*************************************************************************** + * Copyright (C) 2012 by Timothy Pearson * + * kb9vqf@pearsoncomputing.net * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * 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. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef BONDINTROPAGE_H +#define BONDINTROPAGE_H + +#include "ldap.h" + +#include "bondintropagedlg.h" + +class TQStringList; + +/**Abstract class for the first wizard page. Sets the according selection on save() + *@author Timothy Pearson + */ + +class BondIntroPage : public BondIntroPageDlg { + Q_OBJECT +public: + BondIntroPage(TQWidget *parent=0, const char *name=0); + ~BondIntroPage(); +}; + +#endif diff --git a/src/bondintropagedlg.ui b/src/bondintropagedlg.ui new file mode 100644 index 0000000..7ca856e --- /dev/null +++ b/src/bondintropagedlg.ui @@ -0,0 +1,118 @@ + +BondIntroPageDlg + + + BondIntroPageDlg + + + + 0 + 0 + 678 + 452 + + + + + unnamed + + + + px_introSidebar + + + + 0 + 0 + 0 + 0 + + + + + 170 + 430 + + + + Panel + + + Sunken + + + true + + + 0 + + + + + txt_welcome + + + <h3>Welcome to the TDE LDAP Bonding Wizard!</h3> + + + + + TextLabel6 + + + + 1 + 1 + 0 + 0 + + + + <p>This Wizard will help you bond your machine to an LDAP realm in three quick, easy steps.</p> + <p>Please note that you will need administrative access to the LDAP realm you will be bonding with.</p> + <p>If you wish to quit the Wizard, click <b>Cancel</b> at any time.</p> + + + RichText + + + WordBreak|AlignTop|AlignLeft + + + + + + + + + Spacer6 + + + Vertical + + + Fixed + + + + 20 + 30 + + + + + + Spacer5 + + + Vertical + + + Expanding + + + + + + + diff --git a/src/bondrealmpage.cpp b/src/bondrealmpage.cpp index 09d9d31..020c5a5 100644 --- a/src/bondrealmpage.cpp +++ b/src/bondrealmpage.cpp @@ -30,16 +30,35 @@ #include #include #include +#include +#include #include "bondrealmpage.h" BondRealmPage::BondRealmPage(TQWidget *parent, const char *name ) : BondRealmPageDlg(parent,name) { - px_introSidebar->setPixmap(UserIcon("step1.png")); + px_introSidebar->setPixmap(UserIcon("step2.png")); + + connect(txtRealmName, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(validateEntries())); + connect(txtKDC, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(validateEntries())); + connect(txtAdminServer, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(validateEntries())); + + m_parentWizard = dynamic_cast(parent); } -BondRealmPage::~BondRealmPage(){ +BondRealmPage::~BondRealmPage() { // } +void BondRealmPage::validateEntries() { + if (m_parentWizard) { + if ((txtRealmName->text() != "") && (txtKDC->text() != "") && (txtAdminServer->text() != "")) { + m_parentWizard->nextButton()->setEnabled(true); + } + else { + m_parentWizard->nextButton()->setEnabled(false); + } + } +} + #include "bondrealmpage.moc" diff --git a/src/bondrealmpage.h b/src/bondrealmpage.h index 79a0153..5117d7e 100644 --- a/src/bondrealmpage.h +++ b/src/bondrealmpage.h @@ -26,6 +26,7 @@ #include "bondrealmpagedlg.h" class TQStringList; +class KWizard; /**Abstract class for the first wizard page. Sets the according selection on save() *@author Timothy Pearson @@ -33,11 +34,16 @@ class TQStringList; class BondRealmPage : public BondRealmPageDlg { Q_OBJECT + public: BondRealmPage(TQWidget *parent=0, const char *name=0); ~BondRealmPage(); - LDAPRealmConfig m_realmConfig; +public slots: + void validateEntries(); + +private: + KWizard* m_parentWizard; }; #endif diff --git a/src/bondrealmpagedlg.ui b/src/bondrealmpagedlg.ui index e888ea5..3072f75 100644 --- a/src/bondrealmpagedlg.ui +++ b/src/bondrealmpagedlg.ui @@ -47,7 +47,206 @@ 0 - + + + groupRealmInfo + + + Basic Realm Information (required) + + + + unnamed + + + + unnamed + + + Realm Name + + + + + txtRealmName + + + + + unnamed + + + Key Distribution Server [KDC] + + + + + txtKDC + + + + + unnamed + + + port + + + + + txtKDCPort + + + 1 + + + 99999 + + + + + unnamed + + + Administration Server + + + + + txtAdminServer + + + + + unnamed + + + port + + + + + txtAdminServerPort + + + 1 + + + 99999 + + + + + unnamed + + + UID offset + + + + + txtUIDOffset + + + 100 + + + 99999 + + + + + unnamed + + + GID offset + + + + + txtGIDOffset + + + 100 + + + 99999 + + + + + + + groupDomainAliases + + + Realm Domain Aliases (optional) + + + + unnamed + + + + unnamed + + + Enter each domain alias on a new line below + + + + + txtDomains + + + + + + + groupAdvancedPKInit + + + Advanced PKInit Settings (optional) + + + + unnamed + + + + checkRequireEKU + + + Require EKU + + + + + checkRequireKrbtgtOtherName + + + Require KRB TGT Other Name + + + + + checkWin2k + + + Windows 2000 Compatibility + + + + + checkWin2kPkinitRequireBinding + + + Require Windows 2000 Binding + + + + + Spacer6 diff --git a/src/bondwizard.cpp b/src/bondwizard.cpp index 3a7fc17..eeddfa6 100644 --- a/src/bondwizard.cpp +++ b/src/bondwizard.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -38,29 +39,45 @@ #include #include #include +#include +#include +#include #include #include +#include "bondintropage.h" #include "bondrealmpage.h" #include "bondfinishpage.h" #include "bondwizard.h" #include "bondwizard.moc" -BondWizard::BondWizard(TQWidget *parent, const char *name) - : KWizard(parent, name, true) { +BondWizard::BondWizard(LDAPRealmConfigList *realmlist, LDAPConfig *ldapconfig, TQWidget *parent, const char *name) + : KWizard(parent, name, true), m_realmList(realmlist), m_ldapConfig(ldapconfig) { - realmpage= new BondRealmPage(this); - addPage( realmpage, i18n( "Step 1: Introduction" ) ); + setCaption(i18n("LDAP Bonding Wizard")); + + intropage = new BondIntroPage(this); + addPage (intropage, i18n( "Step 1: Introduction" ) ); setHelpEnabled(TQWizard::page(0), false); - finishpage= new BondFinishPage(this); - addPage(finishpage, i18n( "Step 2: I want it my Way..." ) ); + realmpage = new BondRealmPage(this); + addPage (realmpage, i18n( "Step 2: Add New Realm" ) ); setHelpEnabled(TQWizard::page(1), false); - setFinishEnabled(TQWizard::page(1), true); + finishpage = new BondFinishPage(this); + addPage (finishpage, i18n( "Step 3: Bond to New Realm" ) ); + setHelpEnabled(TQWizard::page(2), false); + + // Set up some defaults + realmpage->txtKDCPort->setValue(88); + realmpage->txtAdminServerPort->setValue(749); + realmpage->txtUIDOffset->setValue(5000); + realmpage->txtGIDOffset->setValue(5000); + + setFinishEnabled(TQWizard::page(2), true); setPosition(); } @@ -70,12 +87,38 @@ BondWizard::~BondWizard() { void BondWizard::next() { - if(currentPage()==realmpage) { - realm_dirty=true; // set the dirty flag, changes done that need reverting - // realmpage->save(); + if (currentPage()==intropage) { TQWizard::next(); + realmpage->validateEntries(); } - if(currentPage()==finishpage) { + else if (currentPage()==realmpage) { + // Save realm information + LDAPRealmConfig realm; + + realm.name = realmpage->txtRealmName->text(); + realm.bonded = false; + realm.uid_offset = realmpage->txtUIDOffset->value(); + realm.gid_offset = realmpage->txtGIDOffset->value(); + realm.domain_mappings = TQStringList::split("\n", realmpage->txtDomains->text(), FALSE); + realm.kdc = realmpage->txtKDC->text(); + realm.kdc_port = realmpage->txtKDCPort->value(); + realm.admin_server = realmpage->txtAdminServer->text(); + realm.admin_server_port = realmpage->txtAdminServerPort->value(); + realm.pkinit_require_eku = realmpage->checkRequireEKU->isChecked(); + realm.pkinit_require_krbtgt_otherName = realmpage->checkRequireKrbtgtOtherName->isChecked(); + realm.win2k_pkinit = realmpage->checkWin2k->isChecked(); + realm.win2k_pkinit_require_binding = realmpage->checkWin2kPkinitRequireBinding->isChecked(); + + if (!m_realmList->contains(realm.name)) { + m_realmList->insert(realm.name, realm); + m_ldapConfig->save(); + TQWizard::next(); + } + else { + KMessageBox::error(this, i18n("The specified realm is already known to this system.

If the realm name is correct, please exit the Wizard and select 'Re-Bond to Realm' in the LDAP configuration module."), i18n("Duplicate Realm Entry Detected")); + } + } + if (currentPage()==finishpage) { finishButton()->setFocus(); } } @@ -90,20 +133,25 @@ void BondWizard::back() { bool BondWizard::askClose(){ TQString text; - if (currentPage()==realmpage) { - text = i18n("

Are you sure you want to quit the LDAP Bonding Wizard?

" - "

If yes, click Quit and all changes will be lost." - "
If not, click Cancel to return and finish your setup.

"); - } else { - text = i18n("

Are you sure you want to quit the LDAP Bonding Wizard?

" - "

If not, click Cancel to return and finish bonding.

"); - } - int status = KMessageBox::warningContinueCancel(this, text, i18n("All Changes Will Be Lost"), KStdGuiItem::quit()); - if(status==KMessageBox::Continue){ - setDefaults(); + if (currentPage()==intropage) { return true; - } else { - return false; + } + else { + if (currentPage()==realmpage) { + text = i18n("

Are you sure you want to quit the LDAP Bonding Wizard?

" + "

If yes, click Quit and all changes will be lost." + "
If not, click Cancel to return and finish your setup.

"); + } else { + text = i18n("

Are you sure you want to quit the LDAP Bonding Wizard?

" + "

If not, click Cancel to return and finish bonding.

"); + } + int status = KMessageBox::warningContinueCancel(this, text, i18n("All Changes Will Be Lost"), KStdGuiItem::quit()); + if(status==KMessageBox::Continue){ + setDefaults(); + return true; + } else { + return false; + } } } @@ -137,14 +185,19 @@ void BondWizard::setDefaults(){ /** there seems to be a bug in TQWizard, that makes this evil hack necessary */ void BondWizard::setPosition() { - TQSize hint = realmpage->sizeHint(); + TQSize hint = intropage->sizeHint(); + TQSize realm_size = realmpage->sizeHint(); TQSize finish_size = finishpage->sizeHint(); // get the width of the broadest child-widget + if ( hint.width() < realm_size.width() ) + hint.setWidth(realm_size.width()); if ( hint.width() < finish_size.width() ) hint.setWidth(finish_size.width()); // get the height of the highest child-widget + if ( hint.height() < realm_size.height() ) + hint.setHeight(realm_size.height()); if ( hint.height() < finish_size.height() ) hint.setHeight(finish_size.height()); diff --git a/src/bondwizard.h b/src/bondwizard.h index 0cdfafd..4296bb7 100644 --- a/src/bondwizard.h +++ b/src/bondwizard.h @@ -28,8 +28,11 @@ #include #include +#include "ldap.h" + /** prototypes */ class KLanguageCombo; +class BondIntroPage; class BondRealmPage; class BondFinishPage; @@ -38,7 +41,7 @@ class BondWizard : public KWizard { Q_OBJECT public: /** construtor */ - BondWizard(TQWidget* parent=0, const char *name=0); + BondWizard(LDAPRealmConfigList *realmlist, LDAPConfig *ldapconfig, TQWidget* parent=0, const char *name=0); /** destructor */ ~BondWizard(); @@ -64,9 +67,12 @@ private: void setPosition(); private: + BondIntroPage* intropage; BondRealmPage* realmpage; BondFinishPage* finishpage; bool realm_dirty; + LDAPRealmConfigList* m_realmList; + LDAPConfig* m_ldapConfig; protected: // Protected methods // the close button on the titlebar sets e->accept() which we don't want. diff --git a/src/ldap.cpp b/src/ldap.cpp index 861ed40..a3afbbf 100644 --- a/src/ldap.cpp +++ b/src/ldap.cpp @@ -64,14 +64,17 @@ LDAPConfig::LDAPConfig(TQWidget *parent, const char *name, const TQStringList&) base = new LDAPConfigBase(this); layout->add(base); + base->ldapRealmList->setAllColumnsShowFocus(true); setRootOnlyMsg(i18n("Bonded LDAP realms take effect system wide, and require administrator access to modify
To alter the system's bonded LDAP realms, click on the \"Administrator Mode\" button below.")); setUseRootOnlyMsg(true); - connect(base->systemEnableSupport, TQT_SIGNAL(clicked()), TQT_SLOT(changed())); - connect(base->systemEnableSupport, TQT_SIGNAL(clicked()), TQT_SLOT(processLockouts())); + connect(base->systemEnableSupport, TQT_SIGNAL(clicked()), this, TQT_SLOT(changed())); + connect(base->systemEnableSupport, TQT_SIGNAL(clicked()), this, TQT_SLOT(processLockouts())); + connect(base->ldapRealmList, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(processLockouts())); connect(base->btnBondRealm, TQT_SIGNAL(clicked()), TQT_SLOT(bondToNewRealm())); + connect(base->btnRemoveRealm, TQT_SIGNAL(clicked()), TQT_SLOT(removeRealm())); load(); @@ -102,12 +105,13 @@ void LDAPConfig::load(bool useDefaults ) base->systemEnableSupport->setChecked(systemconfig->readBoolEntry("EnableLDAP", false)); // Load realms + m_realms.clear(); TQStringList cfgRealms = systemconfig->groupList(); for (TQStringList::Iterator it(cfgRealms.begin()); it != cfgRealms.end(); ++it) { if ((*it).startsWith("LDAPRealm-")) { systemconfig->setGroup(*it); TQString realmName=*it; - realmName.remove(strlen("LDAPRealm-")); + realmName.remove(0,strlen("LDAPRealm-")); if (!m_realms.contains(realmName)) { // Read in realm data LDAPRealmConfig realmcfg; @@ -124,18 +128,28 @@ void LDAPConfig::load(bool useDefaults ) realmcfg.pkinit_require_krbtgt_otherName = systemconfig->readBoolEntry("pkinit_require_krbtgt_otherName"); realmcfg.win2k_pkinit = systemconfig->readBoolEntry("win2k_pkinit"); realmcfg.win2k_pkinit_require_binding = systemconfig->readBoolEntry("win2k_pkinit_require_binding"); - // Add realm to lists + // Add realm to list m_realms.insert(realmName, realmcfg); - (void)new TQListViewItem(base->ldapRealmList, ((realmcfg.bonded)?i18n("Bonded"):i18n("Deactivated")), realmName); } } } + updateRealmList(); + processLockouts(); emit changed(useDefaults); } +void LDAPConfig::updateRealmList() { + base->ldapRealmList->clear(); + LDAPRealmConfigList::Iterator it; + for (it = m_realms.begin(); it != m_realms.end(); ++it) { + LDAPRealmConfig realmcfg = it.data(); + (void)new TQListViewItem(base->ldapRealmList, ((realmcfg.bonded)?i18n("Bonded"):i18n("Deactivated")), realmcfg.name); + } +} + void LDAPConfig::defaults() { } @@ -165,6 +179,23 @@ void LDAPConfig::save() { systemconfig->writeEntry("win2k_pkinit", realmcfg.win2k_pkinit); systemconfig->writeEntry("win2k_pkinit_require_binding", realmcfg.win2k_pkinit_require_binding); } + + // Delete any realms that do not exist in the m_realms database + TQStringList cfgRealms = systemconfig->groupList(); + for (TQStringList::Iterator it(cfgRealms.begin()); it != cfgRealms.end(); ++it) { + if ((*it).startsWith("LDAPRealm-")) { + systemconfig->setGroup(*it); + TQString realmName=*it; + realmName.remove(0,strlen("LDAPRealm-")); + if (!m_realms.contains(realmName)) { + systemconfig->deleteGroup(*it); + } + } + } + + systemconfig->sync(); + + load(); } void LDAPConfig::processLockouts() { @@ -174,11 +205,19 @@ void LDAPConfig::processLockouts() { TQListViewItem *selrealm = base->ldapRealmList->selectedItem(); if (selrealm) { + LDAPRealmConfig realmcfg = m_realms[selrealm->text(1)]; base->btnBondRealm->setEnabled(true); base->btnReBondRealm->setEnabled(true); - base->btnDeactivateRealm->setEnabled(true); // RAJA FIXME only if realm is bonded - base->btnRemoveRealm->setEnabled(true); // RAJA FIXME only if realm is not bonded - base->btnRealmProperties->setEnabled(true); // RAJA FIXME only if realm is not bonded + if (realmcfg.bonded) { + base->btnDeactivateRealm->setEnabled(true); + base->btnRemoveRealm->setEnabled(false); + base->btnRealmProperties->setEnabled(false); + } + else { + base->btnDeactivateRealm->setEnabled(false); + base->btnRemoveRealm->setEnabled(true); + base->btnRealmProperties->setEnabled(true); + } } else { base->btnBondRealm->setEnabled(true); @@ -195,13 +234,22 @@ void LDAPConfig::bondToNewRealm() { // Something will probably change save(); - BondWizard *bondwizard = new BondWizard(this); - bondwizard->exec(); + BondWizard bondwizard(&m_realms, this, this); + bondwizard.exec(); // Something probably changed load(); } +void LDAPConfig::removeRealm() { + TQListViewItem *selrealm = base->ldapRealmList->selectedItem(); + if (selrealm) { + m_realms.remove(selrealm->text(1)); + updateRealmList(); + changed(); + } +} + int LDAPConfig::buttons() { return KCModule::Apply|KCModule::Help; } diff --git a/src/ldap.h b/src/ldap.h index 370018e..3494c12 100644 --- a/src/ldap.h +++ b/src/ldap.h @@ -77,6 +77,10 @@ class LDAPConfig: public KCModule private slots: void processLockouts(); void bondToNewRealm(); + void removeRealm(); + + private: + void updateRealmList(); private: KAboutData *myAboutData; diff --git a/src/ldapconfigbase.ui b/src/ldapconfigbase.ui index ef5bd4f..fa14933 100644 --- a/src/ldapconfigbase.ui +++ b/src/ldapconfigbase.ui @@ -137,7 +137,7 @@ - + Spacer4