summaryrefslogtreecommitdiffstats
path: root/src/ldap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ldap.cpp')
-rw-r--r--src/ldap.cpp51
1 files changed, 50 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();