diff options
-rw-r--r-- | cmdline/main.cpp | 71 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/groupconfigdlg.cpp | 2 | ||||
-rw-r--r-- | src/ldapconfigbase.ui | 10 | ||||
-rw-r--r-- | src/ldapmgr.cpp | 25 | ||||
-rw-r--r-- | src/ldapmgr.h | 1 | ||||
-rw-r--r-- | src/machineconfigbase.ui | 195 | ||||
-rw-r--r-- | src/machineconfigdlg.cpp | 99 | ||||
-rw-r--r-- | src/machineconfigdlg.h | 50 | ||||
-rw-r--r-- | src/userconfigdlg.cpp | 2 |
10 files changed, 433 insertions, 24 deletions
diff --git a/cmdline/main.cpp b/cmdline/main.cpp index 65364b0..0650d4c 100644 --- a/cmdline/main.cpp +++ b/cmdline/main.cpp @@ -58,10 +58,12 @@ static const TDECmdLineOptions options[] = { "givenname <first name>", I18N_NOOP("Sets the first name of the specified account to the given value"), 0 }, { "surname <last name>", I18N_NOOP("Sets the last name of the specified account to the given value"), 0 }, { "group <groupname>", I18N_NOOP("Sets membership of the specified account in the groups listed on the command line, and revokes membership in any groups not listed. This option may be used multiple times."), 0 }, + { "primarygroup <groupname>", I18N_NOOP("Sets membership of the specified account in the group listed on the command line, and sets that group as the user's primary group."), 0 }, { "revokeallgroups", I18N_NOOP("Revokes membership of the specified account for all groups"), 0 }, { "adminusername <username>", I18N_NOOP("Specifies the username of the administrative user with permissions to perform the requested task"), 0 }, { "adminpasswordfile <password file>", I18N_NOOP("Specifies the location of a file which contains the password of the administrative user"), 0 }, - { "!+command", I18N_NOOP("The command to execute on the Kerberos realm. Valid commands are: adduser deluser"), 0 }, + { "anonymous", I18N_NOOP("Do not use authentication when contacting the realm controller"), 0 }, + { "!+command", I18N_NOOP("The command to execute on the Kerberos realm. Valid commands are: adduser deluser listusers"), 0 }, { "!+realm", I18N_NOOP("The Kerberos realm on which to execute the specified command. Example: MY.REALM"), 0 }, { "", I18N_NOOP("This utility will use GSSAPI to connect to the realm controller. You must own an active, valid Kerberos ticket in order to use this utility!"), 0 }, TDECmdLineLastOption // End of options. @@ -103,20 +105,22 @@ int main(int argc, char *argv[]) systemconfig.setGroup("LDAPRealm-" + realm); TQString host = systemconfig.readEntry("admin_server"); LDAPCredentials credentials; - if (args->isSet("adminusername") && args->isSet("adminpasswordfile")) { - TQString passFileName = args->getOption("adminpasswordfile"); - TQFile passFile(passFileName); - if (!passFile.open(IO_ReadOnly)) { - printf("[ERROR] Unable to open specified password file '%s'\n\r", passFileName.ascii()); fflush(stdout); - return -1; + if (!args->isSet("anonymous")) { + if (args->isSet("adminusername") && args->isSet("adminpasswordfile")) { + TQString passFileName = args->getOption("adminpasswordfile"); + TQFile passFile(passFileName); + if (!passFile.open(IO_ReadOnly)) { + printf("[ERROR] Unable to open specified password file '%s'\n\r", passFileName.ascii()); fflush(stdout); + return -1; + } + TQTextStream stream(&passFile); + credentials.username = args->getOption("adminusername"); + credentials.password = stream.readLine(); + passFile.close(); + } + else { + credentials.use_gssapi = true; } - TQTextStream stream(&passFile); - credentials.username = args->getOption("adminusername"); - credentials.password = stream.readLine(); - passFile.close(); - } - else { - credentials.use_gssapi = true; } credentials.realm = realm; LDAPManager ldapmanager(realm, host, &credentials); @@ -174,6 +178,10 @@ int main(int argc, char *argv[]) printf("[ERROR] You must specify a surname when adding a user\n\r"); return -1; } + if (!args->isSet("primarygroup")) { + printf("[ERROR] You must specify a primary group when adding a user\n\r"); + return -1; + } // Get user data user.name = args->getOption("username"); @@ -214,7 +222,7 @@ int main(int argc, char *argv[]) if ((groupList.count() > 0) || revoke_all) { LDAPGroupInfoList groupInfoList = ldapmanager.groups(&retcode); if (retcode != 0) { - printf("[ERROR] Unable to retrieve list of users from realm controller\n\r"); + printf("[ERROR] Unable to retrieve list of groups from realm controller\n\r"); return -1; } LDAPGroupInfoList::Iterator it; @@ -235,6 +243,20 @@ int main(int argc, char *argv[]) } } } + bool primary_gid_found = false; + TQString primaryGroupName = args->getOption("primarygroup"); + for (it = groupInfoList.begin(); it != groupInfoList.end(); ++it) { + LDAPGroupInfo group = *it; + if (primaryGroupName == group.name) { + user.primary_gid = group.gid; + primary_gid_found = true; + break; + } + } + if (!primary_gid_found) { + printf("[ERROR] Invalid primary group specified\n\r"); + return -1; + } } if (user.new_password != "") { @@ -289,6 +311,25 @@ int main(int argc, char *argv[]) } // FIXME } + else if (command == "listusers") { + TQString errorString; + if (ldapmanager.bind(&errorString) != 0) { + printf("[ERROR] Unable to bind to Kerberos realm controller\n\r[ERROR] Detailed debugging information: %s\n\r", errorString.ascii()); + return -1; + } + + LDAPUserInfoList userInfoList = ldapmanager.users(&retcode); + if (retcode != 0) { + printf("[ERROR] Unable to retrieve list of users from realm controller\n\r"); + return -1; + } + + LDAPUserInfoList::Iterator it; + for (it = userInfoList.begin(); it != userInfoList.end(); ++it) { + LDAPUserInfo user = *it; + printf("%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n\r", user.uid, user.name.ascii(), user.commonName.ascii(), user.givenName.ascii(), user.initials.ascii(), user.surName.ascii(), user.shell.ascii(), user.homedir.ascii()); fflush(stdout); + } + } else { TDECmdLineArgs::usage(i18n("An invalid command was specified")); return -1; diff --git a/src/Makefile.am b/src/Makefile.am index 6f0e15e..3dd58bb 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_ldapmanager.la -kcm_ldapmanager_la_SOURCES = ldapmgr.cpp ldapconfigbase.ui userconfigbase.ui groupconfigbase.ui serviceconfigbase.ui userconfigdlg.cpp groupconfigdlg.cpp serviceconfigdlg.cpp +kcm_ldapmanager_la_SOURCES = ldapmgr.cpp ldapconfigbase.ui userconfigbase.ui groupconfigbase.ui machineconfigbase.ui serviceconfigbase.ui userconfigdlg.cpp groupconfigdlg.cpp machineconfigdlg.cpp serviceconfigdlg.cpp kcm_ldapmanager_la_LIBADD = -ltdeio $(LIB_TDEUI) -lldap -ltdeldap kcm_ldapmanager_la_LDFLAGS = -avoid-version -module -no-undefined \ $(all_libraries) diff --git a/src/groupconfigdlg.cpp b/src/groupconfigdlg.cpp index 38e2850..6898e2a 100644 --- a/src/groupconfigdlg.cpp +++ b/src/groupconfigdlg.cpp @@ -50,7 +50,7 @@ GroupConfigDialog::GroupConfigDialog(LDAPGroupInfo group, LDAPConfig* parent, co m_base->groupName->setEnabled(false); } - m_base->detailsIcon->setPixmap(SmallIcon("kdmconfig.png")); + m_base->detailsIcon->setPixmap(SmallIcon("tdmconfig.png")); connect(m_base->addToGroup, TQT_SIGNAL(clicked()), this, TQT_SLOT(addSelectedUserToGroup())); connect(m_base->removeFromGroup, TQT_SIGNAL(clicked()), this, TQT_SLOT(removeSelectedUserFromGroup())); diff --git a/src/ldapconfigbase.ui b/src/ldapconfigbase.ui index 0214857..d6ff638 100644 --- a/src/ldapconfigbase.ui +++ b/src/ldapconfigbase.ui @@ -429,13 +429,21 @@ <string>Refresh</string> </property> </widget> - <widget class="TQGroupBox" row="1" column="0" colspan="3"> + <widget class="TQGroupBox" row="1" column="0" colspan="4"> <property name="name"> <cstring>groupGroupDetails</cstring> </property> <property name="title"> <string>Group Members</string> </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>1</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> <grid> <property name="name"> <cstring>unnamed</cstring> diff --git a/src/ldapmgr.cpp b/src/ldapmgr.cpp index 5da7169..3d7e581 100644 --- a/src/ldapmgr.cpp +++ b/src/ldapmgr.cpp @@ -48,6 +48,7 @@ #include "ldappasswddlg.h" #include "userconfigdlg.h" #include "groupconfigdlg.h" +#include "machineconfigdlg.h" #include "serviceconfigdlg.h" // FIXME @@ -91,7 +92,7 @@ LDAPConfig::LDAPConfig(TQWidget *parent, const char *name, const TQStringList&) base->service_author->setEnabled(false); base->user_icon->setPixmap(SmallIcon("personal.png")); - base->group_icon->setPixmap(SmallIcon("kdmconfig.png")); + base->group_icon->setPixmap(SmallIcon("tdmconfig.png")); base->machine_icon->setPixmap(SmallIcon("system.png")); base->service_icon->setPixmap(SmallIcon("kcmsystem.png")); @@ -108,6 +109,7 @@ LDAPConfig::LDAPConfig(TQWidget *parent, const char *name, const TQStringList&) connect(base->user_buttonAdd, TQT_SIGNAL(clicked()), this, TQT_SLOT(addNewUser())); connect(base->group_buttonAdd, TQT_SIGNAL(clicked()), this, TQT_SLOT(addNewGroup())); + connect(base->machine_buttonAdd, TQT_SIGNAL(clicked()), this, TQT_SLOT(addNewMachine())); connect(base->service_buttonAdd, TQT_SIGNAL(clicked()), this, TQT_SLOT(addNewService())); connect(base->user_buttonModify, TQT_SIGNAL(clicked()), this, TQT_SLOT(modifySelectedUser())); connect(base->group_buttonModify, TQT_SIGNAL(clicked()), this, TQT_SLOT(modifySelectedGroup())); @@ -235,11 +237,9 @@ void LDAPConfig::processLockouts() { else { base->machine_buttonDelete->setEnabled(false); } + base->machine_buttonAdd->setEnabled(connected); // FIXME - // Disable machine add/modify as they are not implemented - // In fact, I don't know if I CAN implement them! - // Think about it...yes you can add the 'add' feature...kadmin 'ank --random-key host/HOSTNAME.FQDN'... - base->machine_buttonAdd->setEnabled(false); + // Disable machine modify as it is not yet implemented base->machine_buttonModify->setEnabled(false); base->machine_buttonRefresh->setEnabled(connected); @@ -777,6 +777,21 @@ void LDAPConfig::addNewGroup() { updateAllInformation(); } +void LDAPConfig::addNewMachine() { + // Launch a dialog to add the machine + LDAPMachineInfo machine; + + MachineConfigDialog machineconfigdlg(machine, m_ldapmanager->realm(), this); + if (machineconfigdlg.exec() == TQDialog::Accepted) { + machine = machineconfigdlg.m_machine; + TQString errorstring; + if (m_ldapmanager->addMachineInfo(machine, &errorstring) != 0) { + KMessageBox::error(0, i18n("<qt>Unable to add new machine!<p>%1</qt>").arg(errorstring), i18n("Internal Failure")); + } + } + updateAllInformation(); +} + void LDAPConfig::addNewService() { // Launch a dialog to add the service LDAPServiceInfo service; diff --git a/src/ldapmgr.h b/src/ldapmgr.h index bb3e407..48fe954 100644 --- a/src/ldapmgr.h +++ b/src/ldapmgr.h @@ -67,6 +67,7 @@ class LDAPConfig: public TDECModule void serviceHighlighted(); void addNewUser(); void addNewGroup(); + void addNewMachine(); void addNewService(); void modifySelectedUser(); void modifySelectedGroup(); diff --git a/src/machineconfigbase.ui b/src/machineconfigbase.ui new file mode 100644 index 0000000..bc05add --- /dev/null +++ b/src/machineconfigbase.ui @@ -0,0 +1,195 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> + <class>LDAPMachineConfigBase</class> + <widget class="TQWidget"> + <property name="name"> + <cstring>LDAPMachineConfigBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>519</width> + <height>356</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQTabWidget" row="0" column="0"> + <property name="name"> + <cstring>TabWidget2</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <widget class="TQWidget"> + <property name="name"> + <cstring>detailsTab</cstring> + </property> + <attribute name="title"> + <string>Kerberos Machine</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLayoutWidget" row="1" column="0" colspan="3"> + <property name="name"> + <cstring>unnamed_layoutwidget</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0" colspan="1"> + <property name="name"> + <cstring>detailsIcon</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>4</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + <widget class="TQLabel" row="0" column="1" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Machine Name</string> + </property> + </widget> + <widget class="KLineEdit" row="0" column="2" colspan="1"> + <property name="name"> + <cstring>machineName</cstring> + </property> + </widget> + <widget class="TQLabel" row="0" column="3" colspan="1"> + <property name="name"> + <cstring>realmNameLabel</cstring> + </property> + <property name="text"> + <string></string> + </property> + </widget> + </grid> + </widget> + <widget class="TQLayoutWidget" row="2" column="0" colspan="3"> + <property name="name"> + <cstring>unnamed_layoutwidget</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQButtonGroup" row="2" column="0" colspan="4"> + <property name="name"> + <cstring>validBox</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="lineWidth"> + <number>0</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>Plain</enum> + </property> + <property name="title"> + <string></string> + </property> + <property name="exclusive"> + <bool>true</bool> + </property> + <property name="radioButtonExclusive"> + <bool>true</bool> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQRadioButton" row="0" column="0" colspan="1"> + <property name="name"> + <cstring>autoGeneratePassword</cstring> + </property> + </widget> + <widget class="TQLabel" row="0" column="1" colspan="2"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <cstring>Generate new random password</cstring> + </property> + </widget> + <widget class="TQRadioButton" row="1" column="0" colspan="1"> + <property name="name"> + <cstring>manuallySpecifyPassword</cstring> + </property> + </widget> + <widget class="TQLabel" row="1" column="1" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <cstring>Set specified password</cstring> + </property> + </widget> + <widget class="KPasswordEdit" row="1" column="2" colspan="1"> + <property name="name"> + <cstring>specifiedPassword</cstring> + </property> + <property name="enabled"> + <cstring>true</cstring> + </property> + </widget> + <spacer row="1" column="2"> + <property name="name" stdset="0"> + <cstring>Spacer2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + </grid> + </widget> + </grid> + </widget> + </widget> + </grid> + </widget> + <includes> + <include location="local" impldecl="in implementation">LDAPMachineConfigBase.ui.h</include> + </includes> + <includes> + <include location="local" impldecl="in implementation">kdialog.h</include> + <include location="local" impldecl="in declaration">kpassdlg.h</include> + </includes> + <layoutdefaults spacing="3" margin="6"/> + <layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +</UI>
\ No newline at end of file diff --git a/src/machineconfigdlg.cpp b/src/machineconfigdlg.cpp new file mode 100644 index 0000000..37954be --- /dev/null +++ b/src/machineconfigdlg.cpp @@ -0,0 +1,99 @@ +/*************************************************************************** + * Copyright (C) 2013 by Timothy Pearson * + * [email protected] * + * * + * 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 <tdelocale.h> +#include <klineedit.h> +#include <ktextedit.h> +#include <knuminput.h> +#include <tdeactionselector.h> +#include <tqlistbox.h> +#include <kpushbutton.h> +#include <tqpixmap.h> +#include <tqiconset.h> +#include <tqlabel.h> +#include <kurlrequester.h> +#include <kcombobox.h> +#include <tqradiobutton.h> +#include <tqcheckbox.h> +#include <kdatetimewidget.h> +#include <kiconloader.h> + +#include "ldapmgr.h" +#include "machineconfigdlg.h" + +MachineConfigDialog::MachineConfigDialog(LDAPMachineInfo machine, TQString realmName, LDAPConfig* parent, const char* name) + : KDialogBase(parent, name, true, i18n("LDAP Machine Properties"), Ok|Cancel, Ok, true), m_machine(machine), m_ldapconfig(parent) +{ + m_base = new LDAPMachineConfigBase(this); + setMainWidget(m_base); + + m_base->detailsIcon->setPixmap(SmallIcon("system.png")); + + m_base->realmNameLabel->setText("."+realmName.lower()); + + connect(m_base->machineName, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(processLockouts())); + connect(m_base->specifiedPassword, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(processLockouts())); + connect(m_base->autoGeneratePassword, TQT_SIGNAL(clicked()), this, TQT_SLOT(processLockouts())); + connect(m_base->manuallySpecifyPassword, TQT_SIGNAL(clicked()), this, TQT_SLOT(manuallySpecifyPasswordClicked())); + + m_base->autoGeneratePassword->setChecked(true); + m_base->manuallySpecifyPassword->setChecked(false); + + m_base->machineName->setFocus(); + + processLockouts(); +} + +void MachineConfigDialog::slotOk() { + m_machine.name = m_base->machineName->text(); + if (m_base->autoGeneratePassword->isOn() == true) { + m_machine.newPassword = TQString(); + } + else if (m_base->manuallySpecifyPassword->isOn() == true) { + m_machine.newPassword = m_base->specifiedPassword->password(); + } + + accept(); +} + +void MachineConfigDialog::processLockouts() { + m_base->specifiedPassword->setEnabled(m_base->manuallySpecifyPassword->isOn()); + + if (((m_base->manuallySpecifyPassword->isOn() == true) && (strcmp(m_base->specifiedPassword->password(), "") == 0)) || (m_base->machineName->text() == "")) { + enableButton(KDialogBase::Ok, false); + } + else { + enableButton(KDialogBase::Ok, true); + } +} + +void MachineConfigDialog::manuallySpecifyPasswordClicked() { + processLockouts(); + + if (m_base->specifiedPassword->isEnabled()) { + m_base->specifiedPassword->setFocus(); + } +} + +LDAPMachineInfo MachineConfigDialog::machineProperties() { + return m_machine; +} + +#include "machineconfigdlg.moc" diff --git a/src/machineconfigdlg.h b/src/machineconfigdlg.h new file mode 100644 index 0000000..25f2554 --- /dev/null +++ b/src/machineconfigdlg.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2013 by Timothy Pearson * + * [email protected] * + * * + * 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 _MACHINECONFIGDIALOG_H_ +#define _MACHINECONFIGDIALOG_H_ + +#include <kdialogbase.h> + +#include "libtdeldap.h" +#include "machineconfigbase.h" + +class MachineConfigDialog : public KDialogBase +{ + Q_OBJECT + +public: + MachineConfigDialog(LDAPMachineInfo machine, TQString realmName, LDAPConfig* parent = 0, const char* name = 0); + LDAPMachineInfo machineProperties(); + +public slots: + void slotOk(); + void processLockouts(); + void manuallySpecifyPasswordClicked(); + +public: + LDAPMachineConfigBase *m_base; + LDAPMachineInfo m_machine; + +private: + LDAPConfig* m_ldapconfig; +}; + +#endif // _MACHINECONFIGDIALOG_H_ diff --git a/src/userconfigdlg.cpp b/src/userconfigdlg.cpp index 0eabcaa..8f23ed5 100644 --- a/src/userconfigdlg.cpp +++ b/src/userconfigdlg.cpp @@ -58,7 +58,7 @@ UserConfigDialog::UserConfigDialog(LDAPUserInfo user, LDAPConfig* parent, const m_base->enabledIcon->setPixmap(SmallIcon("decrypted.png")); m_base->disabledIcon->setPixmap(SmallIcon("encrypted.png")); m_base->userIcon->setPixmap(SmallIcon("personal.png")); - m_base->groupsIcon->setPixmap(SmallIcon("kdmconfig.png")); + m_base->groupsIcon->setPixmap(SmallIcon("tdmconfig.png")); m_base->passwordIcon->setPixmap(SmallIcon("password.png")); connect(m_base->loginName, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(processLockouts())); |