Now ready to add kadmin interaction code

pull/1/head
Timothy Pearson 12 years ago
parent 94ba247eec
commit 9468495702

@ -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();

@ -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;

@ -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">

Loading…
Cancel
Save