summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2013-01-15 23:53:15 -0600
committerTimothy Pearson <[email protected]>2013-01-15 23:53:15 -0600
commitf90df49b284a4027fe75ff1be59c7a38fe38c17a (patch)
treee06de5271c580ba7f4dbf40bd5a743156a8d4865
parent937cb8d13055b13da6e267989404ac529b0633d6 (diff)
downloadkcmldapcontroller-f90df49b284a4027fe75ff1be59c7a38fe38c17a.tar.gz
kcmldapcontroller-f90df49b284a4027fe75ff1be59c7a38fe38c17a.zip
Use libtdeldap kadmin talker method
Minor GUI enhancements
-rw-r--r--src/ldapcontroller.cpp137
-rw-r--r--src/primaryrealmwizard/primaryrealmwizard.cpp17
-rw-r--r--src/secondaryrealmwizard/secondaryrealmwizard.cpp13
3 files changed, 101 insertions, 66 deletions
diff --git a/src/ldapcontroller.cpp b/src/ldapcontroller.cpp
index 6c2fed6..92832fa 100644
--- a/src/ldapcontroller.cpp
+++ b/src/ldapcontroller.cpp
@@ -902,34 +902,6 @@ int LDAPController::controlLDAPServer(sc_command command, uid_t userid, gid_t gr
return -2;
}
-// WARNING
-// kadmin does not have a standard "waiting for user input" character or sequence
-// To make matters worse, the colon does not uniquely designate the end of a line; for example the response "kadmin: ext openldap/foo.bar.baz: Principal does not exist"
-// One way around this would be to see if the first colon is part of a "kadmin:" string; if so, then the colon is not a reliable end of line indicator for the current line
-// (in fact only '\r' should be used as the end of line indicator in that case)
-TQString readFullLineFromPtyProcess(PtyProcess* proc) {
- TQString result = "";
- while ((!result.contains("\r")) &&
- (!result.contains(">")) &&
- (!((!result.contains("kadmin:")) && result.contains(":"))) &&
- (!((result.contains("kadmin:")) && result.contains("\r")))
- ) {
- result = result + TQString(proc->readLine(false));
- tqApp->processEvents();
- if (!TQFile::exists(TQString("/proc/%1/exe").arg(proc->pid()))) {
- result.replace("\n", "");
- result.replace("\r", "");
- if (result == "") {
- result = "TDE process terminated";
- }
- break;
- }
- }
- result.replace("\n", "");
- result.replace("\r", "");
- return result;
-}
-
int LDAPController::initializeNewKerberosRealm(TQString realmName, TQString *errstr) {
TQCString command = "kadmin";
QCStringList args;
@@ -939,51 +911,58 @@ int LDAPController::initializeNewKerberosRealm(TQString realmName, TQString *err
PtyProcess kadminProc;
kadminProc.enableLocalEcho(false);
kadminProc.exec(command, args);
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
prompt = prompt.stripWhiteSpace();
if (prompt == "kadmin>") {
command = TQCString("init "+realmName);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(command, true);
do { // Discard our own input
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
printf("(kadmin) '%s'\n\r", prompt.ascii());
} while (prompt == TQString(command));
prompt = prompt.stripWhiteSpace();
if (prompt.contains("authentication failed")) {
- if (errstr) *errstr = prompt;
+ if (errstr) *errstr = LDAPManager::detailedKAdminErrorMessage(prompt);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
else if (prompt.startsWith("Realm max")) {
command = "unlimited";
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(command, true);
do { // Discard our own input
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
printf("(kadmin) '%s'\n\r", prompt.ascii());
} while (prompt == TQString(command));
prompt = prompt.stripWhiteSpace();
if (prompt.startsWith("Realm max")) {
command = "unlimited";
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(command, true);
do { // Discard our own input
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
printf("(kadmin) '%s'\n\r", prompt.ascii());
} while (prompt == TQString(command));
prompt = prompt.stripWhiteSpace();
}
if (prompt != "kadmin>") {
- if (errstr) *errstr = prompt;
+ if (errstr) *errstr = LDAPManager::detailedKAdminErrorMessage(prompt);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
// Success!
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 0;
}
// Failure
- if (errstr) *errstr = prompt;
+ if (errstr) *errstr = LDAPManager::detailedKAdminErrorMessage(prompt);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
@@ -1002,40 +981,45 @@ int LDAPController::addHostEntryToKerberosRealm(TQString kerberosHost, TQString
TQString prompt;
PtyProcess kadminProc;
kadminProc.exec(command, args);
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
prompt = prompt.stripWhiteSpace();
if (prompt == "kadmin>") {
command = TQCString("ext "+hoststring);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(command, true);
do { // Discard our own input
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
printf("(kadmin) '%s'\n\r", prompt.ascii());
} while (prompt == TQString(command));
prompt = prompt.stripWhiteSpace();
if (prompt.contains("authentication failed")) {
- if (errstr) *errstr = prompt;
+ if (errstr) *errstr = LDAPManager::detailedKAdminErrorMessage(prompt);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
else if (prompt.endsWith("Principal does not exist")) {
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
prompt = prompt.stripWhiteSpace();
if (prompt != "kadmin>") {
- if (errstr) *errstr = prompt;
+ if (errstr) *errstr = LDAPManager::detailedKAdminErrorMessage(prompt);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
command = TQCString("ank --random-key "+hoststring);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(command, true);
do { // Discard our own input
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
printf("(kadmin) '%s'\n\r", prompt.ascii());
} while (prompt == TQString(command));
prompt = prompt.stripWhiteSpace();
// Use all defaults
while (prompt != "kadmin>") {
if (prompt.contains("authentication failed")) {
- if (errstr) *errstr = prompt;
+ if (errstr) *errstr = LDAPManager::detailedKAdminErrorMessage(prompt);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
@@ -1049,39 +1033,45 @@ int LDAPController::addHostEntryToKerberosRealm(TQString kerberosHost, TQString
defaultParam = prompt.mid(leftbracket, rightbracket-leftbracket);
}
command = TQCString(defaultParam);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(command, true);
do { // Discard our own input
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
printf("(kadmin) '%s'\n\r", prompt.ascii());
} while (prompt == TQString(command));
prompt = prompt.stripWhiteSpace();
}
}
command = TQCString("ext "+hoststring);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(command, true);
do { // Discard our own input
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
printf("(kadmin) '%s'\n\r", prompt.ascii());
} while (prompt == TQString(command));
prompt = prompt.stripWhiteSpace();
if (prompt != "kadmin>") {
- if (errstr) *errstr = prompt;
+ if (errstr) *errstr = LDAPManager::detailedKAdminErrorMessage(prompt);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
// Success!
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 0;
}
else if (prompt == "kadmin>") {
// Success!
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 0;
}
// Failure
- if (errstr) *errstr = prompt;
+ if (errstr) *errstr = LDAPManager::detailedKAdminErrorMessage(prompt);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
@@ -1100,40 +1090,45 @@ int LDAPController::addLDAPEntryToKerberosRealm(TQString ldapProcessOwnerName, T
TQString prompt;
PtyProcess kadminProc;
kadminProc.exec(command, args);
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
prompt = prompt.stripWhiteSpace();
if (prompt == "kadmin>") {
command = TQCString("ext --keytab="+TQString(LDAP_KEYTAB_FILE)+" "+hoststring);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(command, true);
do { // Discard our own input
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
printf("(kadmin) '%s'\n\r", prompt.ascii());
} while (prompt.startsWith("ext --keytab="));
prompt = prompt.stripWhiteSpace();
if (prompt.contains("authentication failed")) {
- if (errstr) *errstr = prompt;
+ if (errstr) *errstr = LDAPManager::detailedKAdminErrorMessage(prompt);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
else if (prompt.endsWith("Principal does not exist")) {
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
prompt = prompt.stripWhiteSpace();
if (prompt != "kadmin>") {
- if (errstr) *errstr = prompt;
+ if (errstr) *errstr = LDAPManager::detailedKAdminErrorMessage(prompt);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
command = TQCString("ank --random-key "+hoststring);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(command, true);
do { // Discard our own input
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
printf("(kadmin) '%s'\n\r", prompt.ascii());
} while (prompt == TQString(command));
prompt = prompt.stripWhiteSpace();
// Use all defaults
while (prompt != "kadmin>") {
if (prompt.contains("authentication failed")) {
- if (errstr) *errstr = prompt;
+ if (errstr) *errstr = LDAPManager::detailedKAdminErrorMessage(prompt);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
@@ -1147,39 +1142,45 @@ int LDAPController::addLDAPEntryToKerberosRealm(TQString ldapProcessOwnerName, T
defaultParam = prompt.mid(leftbracket, rightbracket-leftbracket);
}
command = TQCString(defaultParam);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(command, true);
do { // Discard our own input
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
printf("(kadmin) '%s'\n\r", prompt.ascii());
} while (prompt == TQString(command));
prompt = prompt.stripWhiteSpace();
}
}
command = TQCString("ext --keytab="+TQString(LDAP_KEYTAB_FILE)+" "+hoststring);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(command, true);
do { // Discard our own input
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
printf("(kadmin) '%s'\n\r", prompt.ascii());
} while (prompt.startsWith("ext --keytab="));
prompt = prompt.stripWhiteSpace();
if (prompt != "kadmin>") {
- if (errstr) *errstr = prompt;
+ if (errstr) *errstr = LDAPManager::detailedKAdminErrorMessage(prompt);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
// Success!
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 0;
}
else if (prompt == "kadmin>") {
// Success!
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 0;
}
// Failure
- if (errstr) *errstr = prompt;
+ if (errstr) *errstr = LDAPManager::detailedKAdminErrorMessage(prompt);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
@@ -1200,54 +1201,62 @@ int LDAPController::setKerberosPasswordForUser(LDAPCredentials user, TQString *e
TQString prompt;
PtyProcess kadminProc;
kadminProc.exec(command, args);
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
prompt = prompt.stripWhiteSpace();
if (prompt == "kadmin>") {
command = TQCString("passwd "+user.username);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(command, true);
do { // Discard our own input
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
printf("(kadmin) '%s'\n\r", prompt.ascii());
} while (prompt == TQString(command));
prompt = prompt.stripWhiteSpace();
if (prompt.contains("authentication failed")) {
- if (errstr) *errstr = prompt;
+ if (errstr) *errstr = LDAPManager::detailedKAdminErrorMessage(prompt);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
else if ((prompt.endsWith(" Password:")) && (prompt.startsWith(TQString(user.username + "@")))) {
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(user.password, true);
do { // Discard our own input
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
printf("(kadmin) '%s'\n\r", prompt.ascii());
} while (prompt == "");
prompt = prompt.stripWhiteSpace();
if ((prompt.endsWith(" Password:")) && (prompt.startsWith("Verify"))) {
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(user.password, true);
do { // Discard our own input
- prompt = readFullLineFromPtyProcess(&kadminProc);
+ prompt = LDAPManager::readFullLineFromPtyProcess(&kadminProc);
printf("(kadmin) '%s'\n\r", prompt.ascii());
} while (prompt == "");
prompt = prompt.stripWhiteSpace();
}
if (prompt != "kadmin>") {
- if (errstr) *errstr = prompt;
+ if (errstr) *errstr = LDAPManager::detailedKAdminErrorMessage(prompt);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
// Success!
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 0;
}
else if (prompt == "kadmin>") {
// Success!
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 0;
}
// Failure
- if (errstr) *errstr = prompt;
+ if (errstr) *errstr = LDAPManager::detailedKAdminErrorMessage(prompt);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
diff --git a/src/primaryrealmwizard/primaryrealmwizard.cpp b/src/primaryrealmwizard/primaryrealmwizard.cpp
index 6dbf9bc..3177afa 100644
--- a/src/primaryrealmwizard/primaryrealmwizard.cpp
+++ b/src/primaryrealmwizard/primaryrealmwizard.cpp
@@ -129,6 +129,10 @@ void PrimaryRealmWizard::next() {
if (currentPage()==intropage) {
TQWizard::next();
realmpage->validateEntries();
+
+ // Focus the first entry field on the new wizard page
+ realmpage->txtKDC->setFocus();
+ realmpage->txtKDC->selectAll();
}
else if (currentPage()==realmpage) {
// Save realm information
@@ -150,6 +154,10 @@ void PrimaryRealmWizard::next() {
TQWizard::next();
certpage->processLockouts();
certpage->validateEntries();
+
+ // Focus the first entry field on the new wizard page
+ certpage->organizationName->setFocus();
+ certpage->organizationName->selectAll();
}
else if (currentPage()==certpage) {
// Save certificate information
@@ -216,9 +224,13 @@ void PrimaryRealmWizard::next() {
TQWizard::next();
finishpage->validateEntries();
+
+ // Focus the first entry field on the new wizard page
+ finishpage->ldapAdminUsername->setFocus();
+ finishpage->ldapAdminUsername->selectAll();
}
if (currentPage()==finishpage) {
- finishButton()->setFocus();
+ //
}
}
@@ -293,6 +305,8 @@ void PrimaryRealmWizard::accept() {
nextButton()->setEnabled(false);
finishButton()->setEnabled(false);
cancelButton()->setEnabled(false);
+ finishpage->setEnabled(false);
+
if (m_controller->createNewLDAPRealm(this, m_realmconfig, finishpage->ldapAdminUsername->text(), finishpage->ldapAdminGroupname->text(), finishpage->ldapMachineAdminGroupname->text(), finishpage->ldapStandardUserGroupname->text(), finishpage->ldapAdminPassword->password(), "admin", finishpage->ldapAdminPassword->password(), finishpage->ldapAdminRealm->text(), m_certconfig, &errorString) == 0) {
done(0);
}
@@ -300,6 +314,7 @@ void PrimaryRealmWizard::accept() {
KMessageBox::error(this, i18n("<qt><b>Unable to create new realm!</b><p>Details: %1</qt>").arg(errorString), i18n("Unable to create new realm"));
}
+ finishpage->setEnabled(true);
backButton()->setEnabled(true);
finishButton()->setEnabled(true);
cancelButton()->setEnabled(true);
diff --git a/src/secondaryrealmwizard/secondaryrealmwizard.cpp b/src/secondaryrealmwizard/secondaryrealmwizard.cpp
index ec5f470..baefe8d 100644
--- a/src/secondaryrealmwizard/secondaryrealmwizard.cpp
+++ b/src/secondaryrealmwizard/secondaryrealmwizard.cpp
@@ -112,6 +112,10 @@ void SecondaryRealmWizard::next() {
if (currentPage()==intropage) {
TQWizard::next();
realmpage->validateEntries();
+
+ // Focus the first entry field on the new wizard page
+ realmpage->txtRealmName->setFocus();
+ realmpage->txtRealmName->selectAll();
}
else if (currentPage()==realmpage) {
// Save realm information
@@ -132,9 +136,13 @@ void SecondaryRealmWizard::next() {
finishpage->ldapAdminRealm->setText(realmpage->txtRealmName->text());
TQWizard::next();
finishpage->validateEntries();
+
+ // Focus the first entry field on the new wizard page
+ finishpage->ldapAdminUsername->setFocus();
+ finishpage->ldapAdminUsername->selectAll();
}
if (currentPage()==finishpage) {
- finishButton()->setFocus();
+ //
}
}
@@ -205,6 +213,8 @@ void SecondaryRealmWizard::accept() {
nextButton()->setEnabled(false);
finishButton()->setEnabled(false);
cancelButton()->setEnabled(false);
+ finishpage->setEnabled(false);
+
if (m_controller->createNewSecondaryController(this, m_realmconfig, finishpage->ldapAdminUsername->text(), finishpage->ldapAdminPassword->password(), finishpage->ldapAdminRealm->text(), &errorString) == 0) {
done(0);
}
@@ -212,6 +222,7 @@ void SecondaryRealmWizard::accept() {
KMessageBox::error(this, i18n("<qt><b>Unable to add new secondary realm controller!</b><p>Details: %1</qt>").arg(errorString), i18n("Unable to add new secondary realm controller"));
}
+ finishpage->setEnabled(true);
backButton()->setEnabled(true);
finishButton()->setEnabled(true);
cancelButton()->setEnabled(true);