From 0792d5408516a0a4c04e56cabefa7d1ffc440899 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 5 Jun 2012 01:05:35 -0500 Subject: [PATCH] Move dns lookup routine to ldap library --- src/ldap.desktop | 4 ++-- src/ldapbonding.cpp | 38 +++++--------------------------------- src/ldapbonding.h | 4 ---- 3 files changed, 7 insertions(+), 39 deletions(-) diff --git a/src/ldap.desktop b/src/ldap.desktop index 5c4fe29..d931e39 100644 --- a/src/ldap.desktop +++ b/src/ldap.desktop @@ -13,7 +13,7 @@ X-KDE-SubstituteUID=true [Desktop Entry] Encoding=UTF-8 -Comment=A KControl tool for managing TDE connections to LDAP realms. +Comment=A KControl tool for managing TDE bonding to LDAP realms. Keywords=ldap manager -Name=LDAP Realm Configuration +Name=LDAP Realm Bonding Categories=Qt;KDE;X-KDE-settings-components; diff --git a/src/ldapbonding.cpp b/src/ldapbonding.cpp index 9c9d9b5..d0d5346 100644 --- a/src/ldapbonding.cpp +++ b/src/ldapbonding.cpp @@ -18,10 +18,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include - #include #include @@ -108,14 +104,17 @@ 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())); - m_fqdn = getMachineFQDN(); + m_fqdn = LDAPManager::getMachineFQDN(); base->hostFQDN->setEnabled(false); base->hostFQDN->clear(); base->hostFQDN->insertItem(m_fqdn); load(); - if (getuid() != 0 || !systemconfig->checkConfigFilesWritable( true )) { + systemconfig->setGroup(NULL); + TQString ldapRole = systemconfig->readEntry("LDAPRole", "Workstation"); + + if ((getuid() != 0) || (!systemconfig->checkConfigFilesWritable( true )) || (ldapRole != "Workstation")) { base->systemEnableSupport->setEnabled(false); } @@ -126,33 +125,6 @@ LDAPConfig::~LDAPConfig() { delete systemconfig; } -// FIXME -// This should be moved to a TDE core library -TQString LDAPConfig::getMachineFQDN() { - struct addrinfo hints, *info, *p; - int gai_result; - - char hostname[1024]; - hostname[1023] = '\0'; - gethostname(hostname, 1023); - - memset(&hints, 0, sizeof hints); - hints.ai_family = AF_UNSPEC; // IPV4 or IPV6 - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_CANONNAME; - - if ((gai_result = getaddrinfo(hostname, NULL, &hints, &info)) != 0) { - return TQString(hostname); - } - TQString fqdn = TQString(hostname); - for (p=info; p!=NULL; p=p->ai_next) { - fqdn = TQString(p->ai_canonname); - } - freeaddrinfo(info); - - return fqdn; -} - void LDAPConfig::load() { kgs = new KGlobalSettings(); diff --git a/src/ldapbonding.h b/src/ldapbonding.h index ac7979a..ebe4973 100644 --- a/src/ldapbonding.h +++ b/src/ldapbonding.h @@ -58,10 +58,6 @@ class LDAPConfig: public KCModule int bondRealm(LDAPRealmConfig realmcfg, TQString adminUserName, const char * adminPassword, TQString adminRealm, TQString *errstr=0); int unbondRealm(LDAPRealmConfig realmcfg, TQString adminUserName, const char * adminPassword, TQString adminRealm, TQString *errstr=0); - // FIXME - // This should be moved to a TDE core library - TQString getMachineFQDN(); - private slots: void processLockouts(); void bondToNewRealm();