From 27b49086f03315c32d30a0658e44958abd47a3ef Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Fri, 12 Apr 2013 10:20:56 -0500 Subject: [PATCH] Add ability to control PAM options including credential caching and home directory creation --- src/Makefile.am | 2 +- src/ldapbonding.cpp | 29 ++++++++++++++- src/ldapconfigbase.ui | 84 +++++++++++++++++++++++++++++++++++++++++++ src/tdeumaskinput.cpp | 61 +++++++++++++++++++++++++++++++ src/tdeumaskinput.h | 83 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 257 insertions(+), 2 deletions(-) create mode 100644 src/tdeumaskinput.cpp create mode 100644 src/tdeumaskinput.h diff --git a/src/Makefile.am b/src/Makefile.am index 980e2b9..dc29cb1 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_ldapbonding.la -kcm_ldapbonding_la_SOURCES = ldapbonding.cpp ldapconfigbase.ui realmpropertiesdialog.cpp bondintropage.cpp bondintropagedlg.ui bondrealmpage.cpp bondrealmpagedlg.ui bondfinishpage.cpp bondfinishpagedlg.ui bondwizard.cpp ldappasswddlg.cpp +kcm_ldapbonding_la_SOURCES = tdeumaskinput.cpp ldapbonding.cpp ldapconfigbase.ui realmpropertiesdialog.cpp bondintropage.cpp bondintropagedlg.ui bondrealmpage.cpp bondrealmpagedlg.ui bondfinishpage.cpp bondfinishpagedlg.ui bondwizard.cpp ldappasswddlg.cpp kcm_ldapbonding_la_LIBADD = $(LIB_KIO) $(LIB_TDEUI) -ltdeldap kcm_ldapbonding_la_LDFLAGS = -avoid-version -module -no-undefined \ $(all_libraries) diff --git a/src/ldapbonding.cpp b/src/ldapbonding.cpp index fbf1006..9bc23db 100644 --- a/src/ldapbonding.cpp +++ b/src/ldapbonding.cpp @@ -44,6 +44,7 @@ #include +#include "tdeumaskinput.h" #include "ldapbonding.h" #include "bondwizard.h" #include "ldappasswddlg.h" @@ -101,6 +102,12 @@ LDAPConfig::LDAPConfig(TQWidget *parent, const char *name, const TQStringList&) connect(base->passwordHash, TQT_SIGNAL(activated(int)), this, TQT_SLOT(changed())); connect(base->ignoredUsers, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(changed())); + connect(base->pamEnableCachedLogons, TQT_SIGNAL(clicked()), this, TQT_SLOT(changed())); + connect(base->pamCreateHomeDirectory, TQT_SIGNAL(clicked()), this, TQT_SLOT(changed())); + connect(base->pamCreateHomeDirectory, TQT_SIGNAL(clicked()), this, TQT_SLOT(processLockouts())); + connect(base->pamCreateHomeDirectoryUmask, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(changed())); + connect(base->pamCreateHomeDirectorySkelDir, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(changed())); + hostFQDN = LDAPManager::getMachineFQDN(); base->hostFQDN->setEnabled(false); base->hostFQDN->clear(); @@ -158,6 +165,11 @@ void LDAPConfig::load(bool useDefaults ) } base->ignoredUsers->setText(m_clientRealmConfig.ignoredUsers); + base->pamEnableCachedLogons->setChecked(m_clientRealmConfig.pamConfig.enable_cached_credentials); + base->pamCreateHomeDirectory->setChecked(m_clientRealmConfig.pamConfig.autocreate_user_directories_enable); + base->pamCreateHomeDirectoryUmask->setValue(m_clientRealmConfig.pamConfig.autocreate_user_directories_umask); + base->pamCreateHomeDirectorySkelDir->setURL(m_clientRealmConfig.pamConfig.autocreate_user_directories_skel); + updateRealmList(); processLockouts(); @@ -205,6 +217,11 @@ void LDAPConfig::save() { m_clientRealmConfig.passwordHash = base->passwordHash->currentText(); m_clientRealmConfig.ignoredUsers = base->ignoredUsers->text(); + m_clientRealmConfig.pamConfig.enable_cached_credentials = base->pamEnableCachedLogons->isChecked(); + m_clientRealmConfig.pamConfig.autocreate_user_directories_enable = base->pamCreateHomeDirectory->isChecked(); + m_clientRealmConfig.pamConfig.autocreate_user_directories_umask = base->pamCreateHomeDirectoryUmask->value(); + m_clientRealmConfig.pamConfig.autocreate_user_directories_skel = base->pamCreateHomeDirectorySkelDir->url(); + // Write system configuration if (LDAPManager::saveClientRealmConfig(m_clientRealmConfig, systemconfig, &errorstring) != 0) { KMessageBox::error(this, i18n("Unable to save configuration!

Details: %2").arg(errorstring), i18n("Unable to Save Configuration")); @@ -231,7 +248,7 @@ void LDAPConfig::save() { return; } // Write the PAM configuration files - if (LDAPManager::writePAMFiles(&errorstring) != 0) { + if (LDAPManager::writePAMFiles(m_clientRealmConfig.pamConfig, &errorstring) != 0) { KMessageBox::error(this, i18n("Unable to save configuration!

Details: %2").arg(errorstring), i18n("Unable to Save Configuration")); return; } @@ -284,6 +301,7 @@ void LDAPConfig::processLockouts() { base->groupRealms->setEnabled(panelIsEnabled); base->groupKrbDefaults->setEnabled(panelIsEnabled); base->groupConnectionParameters->setEnabled(panelIsEnabled); + base->groupPamConfig->setEnabled(panelIsEnabled); TQListViewItem *selrealm = base->ldapRealmList->selectedItem(); if (selrealm) { @@ -308,6 +326,15 @@ void LDAPConfig::processLockouts() { base->btnRemoveRealm->setEnabled(false); base->btnRealmProperties->setEnabled(false); } + + if (base->pamCreateHomeDirectory->isChecked()) { + base->pamCreateHomeDirectoryUmask->setEnabled(true); + base->pamCreateHomeDirectorySkelDir->setEnabled(true); + } + else { + base->pamCreateHomeDirectoryUmask->setEnabled(false); + base->pamCreateHomeDirectorySkelDir->setEnabled(false); + } } void LDAPConfig::bondToNewRealm() { diff --git a/src/ldapconfigbase.ui b/src/ldapconfigbase.ui index bbc48fa..a889ac9 100644 --- a/src/ldapconfigbase.ui +++ b/src/ldapconfigbase.ui @@ -427,6 +427,89 @@ + + + groupPamConfig + + + Authentication Settings + + + + unnamed + + + + pamCreateHomeDirectory + + + &Create home directory on first logon + + + + + pamEnableCachedLogons + + + &Enable logon credentials cache + + + + + unnamed + + + Home directory mode creation mask + + + + 0 + 0 + 0 + 0 + + + + + + pamCreateHomeDirectoryUmask + + + 8 + + + 0 + + + 7777 + + + + + unnamed + + + Home directory skeleton location + + + + 0 + 0 + 0 + 0 + + + + + + pamCreateHomeDirectorySkelDir + + + 18 + + + + Spacer4 @@ -454,6 +537,7 @@ kdialog.h + tdeumaskinput.h diff --git a/src/tdeumaskinput.cpp b/src/tdeumaskinput.cpp new file mode 100644 index 0000000..b1b2513 --- /dev/null +++ b/src/tdeumaskinput.cpp @@ -0,0 +1,61 @@ +/* + * tdeumaskinput.cpp + * + * Copyright (c) 2013 Timothy Pearson + * + * Requires the Qt widget libraries, available at no cost at + * http://www.troll.no/ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "tdeumaskinput.h" + +TDEUmaskInput::TDEUmaskInput(TQWidget *parent, const char *name) + : KIntSpinBox(parent, name) +{ + // +} + +TDEUmaskInput::TDEUmaskInput(int lower, int upper, int step, int value, int base, + TQWidget* parent, const char* name) + : KIntSpinBox(lower, upper, step, value, base, parent, name) +{ + // +} + +TDEUmaskInput::~TDEUmaskInput() +{ + // +} + +void TDEUmaskInput::setBase(int base) +{ + KIntSpinBox::setBase(base); +} + +int TDEUmaskInput::base() const +{ + return KIntSpinBox::base(); +} + +TQString TDEUmaskInput::mapValueToText (int v) { + TQString baseText = KIntSpinBox::mapValueToText(v); + while (baseText.length() < 4) { + baseText.prepend("0"); + } + return baseText; +} \ No newline at end of file diff --git a/src/tdeumaskinput.h b/src/tdeumaskinput.h new file mode 100644 index 0000000..e2c1898 --- /dev/null +++ b/src/tdeumaskinput.h @@ -0,0 +1,83 @@ +/* + * tdeumaskinput.h + * + * Copyright (c) 2013 Timothy Pearson + * + * Requires the Qt widget libraries, available at no cost at + * http://www.troll.no/ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef TDE_UMASKINPUT_H +#define TDE_UMASKINPUT_H + +#include + +class TDEUI_EXPORT TDEUmaskInput : public KIntSpinBox +{ + Q_OBJECT + + TQ_PROPERTY( int base READ base WRITE setBase ) + + public: + /** + * Constructor. + * + * Constructs a widget with an integer inputline with a little scrollbar + * and a slider, with minimal value 0, maximal value 99, step 1, base 10 + * and initial value 0. + */ + TDEUmaskInput( TQWidget *parent=0, const char *name=0); + + /** + * Constructor. + * + * Constructs a widget with an integer inputline with a little scrollbar + * and a slider. + * + * @param lower The lowest valid value. + * @param upper The greatest valid value. + * @param step The step size of the scrollbar. + * @param value The actual value. + * @param base The base of the used number system. + * @param parent The parent of the widget. + * @param name The Name of the widget. + */ + TDEUmaskInput(int lower, int upper, int step, int value, int base = 10, TQWidget* parent = 0, const char* name = 0); + + /** + * Destructor. + */ + virtual ~TDEUmaskInput(); + + public: + /** + * Sets the base in which the numbers in the spin box are represented. + */ + void setBase(int base); + + /** + * @return the base in which numbers in the spin box are represented. + */ + int base() const; + + protected: + virtual TQString mapValueToText(int); + +}; + +#endif // TDE_UMASKINPUT_H \ No newline at end of file