summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-05-20 14:37:46 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-05-20 14:37:46 -0500
commit94684957020e61e1089cbe2ea4357d86a4de9c55 (patch)
treec5133927a83327f7d7e98ee97969acd7635135d1
parent94ba247eec24814e287c4bebf4085de0565bbcd2 (diff)
downloadkcmldap-94684957.tar.gz
kcmldap-94684957.zip
Now ready to add kadmin interaction code
-rw-r--r--src/ldap.cpp51
-rw-r--r--src/ldap.h5
-rw-r--r--src/ldapconfigbase.ui21
3 files changed, 76 insertions, 1 deletions
diff --git a/src/ldap.cpp b/src/ldap.cpp
index 2394b03..3197f28 100644
--- a/src/ldap.cpp
+++ b/src/ldap.cpp
@@ -18,6 +18,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
#include <tqlayout.h>
#include <klocale.h>
@@ -98,6 +102,11 @@ 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();
+ base->hostFQDN->setEnabled(false);
+ base->hostFQDN->clear();
+ base->hostFQDN->insertItem(m_fqdn);
+
load();
if (getuid() != 0 || !systemconfig->checkConfigFilesWritable( true )) {
@@ -111,6 +120,33 @@ 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();
@@ -120,6 +156,7 @@ void LDAPConfig::load() {
void LDAPConfig::load(bool useDefaults )
{
int i;
+ bool thisIsMyMachine;
//Update the toggle buttons with the current configuration
systemconfig->setReadDefaults( useDefaults );
@@ -128,6 +165,12 @@ void LDAPConfig::load(bool useDefaults )
base->systemEnableSupport->setChecked(systemconfig->readBoolEntry("EnableLDAP", false));
m_defaultRealm = systemconfig->readEntry("DefaultRealm", TQString::null);
m_ticketLifetime = systemconfig->readNumEntry("TicketLifetime", 86400);
+ if (m_fqdn == systemconfig->readEntry("HostFQDN", "")) {
+ thisIsMyMachine = true;
+ }
+ else {
+ thisIsMyMachine = false;
+ }
m_ldapVersion = systemconfig->readNumEntry("ConnectionLDAPVersion", 3);
m_ldapTimeout = systemconfig->readNumEntry("ConnectionLDAPTimeout", 2);
@@ -148,7 +191,12 @@ void LDAPConfig::load(bool useDefaults )
// Read in realm data
LDAPRealmConfig realmcfg;
realmcfg.name = realmName;
- realmcfg.bonded = systemconfig->readBoolEntry("bonded");
+ if (thisIsMyMachine) {
+ realmcfg.bonded = systemconfig->readBoolEntry("bonded");
+ }
+ else {
+ realmcfg.bonded = false;
+ }
realmcfg.uid_offset = systemconfig->readNumEntry("uid_offset");
realmcfg.gid_offset = systemconfig->readNumEntry("gid_offset");
realmcfg.domain_mappings = systemconfig->readListEntry("domain_mappings");
@@ -220,6 +268,7 @@ void LDAPConfig::save() {
// Write system configuration
systemconfig->setGroup(NULL);
systemconfig->writeEntry("EnableLDAP", base->systemEnableSupport->isChecked());
+ systemconfig->writeEntry("HostFQDN", m_fqdn);
m_defaultRealm = base->defaultRealm->currentText();
m_ticketLifetime = base->ticketLifetime->value();
diff --git a/src/ldap.h b/src/ldap.h
index 7e2e236..e974034 100644
--- a/src/ldap.h
+++ b/src/ldap.h
@@ -77,6 +77,10 @@ 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();
@@ -95,6 +99,7 @@ class LDAPConfig: public KCModule
KGlobalSettings *kgs;
LDAPConfigBase *base;
LDAPRealmConfigList m_realms;
+ TQString m_fqdn;
TQString m_defaultRealm;
int m_ticketLifetime;
diff --git a/src/ldapconfigbase.ui b/src/ldapconfigbase.ui
index ee6e963..aa1d15e 100644
--- a/src/ldapconfigbase.ui
+++ b/src/ldapconfigbase.ui
@@ -53,6 +53,27 @@
<string>&amp;Enable LDAP Realm Support</string>
</property>
</widget>
+ <widget class="TQLabel" row="0" column="1">
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="text">
+ <string>Fully Qualified Domain Name</string>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="0" column="2" >
+ <property name="name">
+ <cstring>hostFQDN</cstring>
+ </property>
+ </widget>
</grid>
</widget>
<widget class="TQGroupBox" row="1" column="0">