summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2014-01-07 14:10:11 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2014-01-07 14:10:11 -0600
commit5bfd539b84218ffc0742dad0bc3eac747d1394cd (patch)
treee64bb38f94e8e00a29abae654dfb4383fec37937 /src
parent571e1739fb4f6cf77c1e7297670801114b6de717 (diff)
downloadlibtdeldap-5bfd539b84218ffc0742dad0bc3eac747d1394cd.tar.gz
libtdeldap-5bfd539b84218ffc0742dad0bc3eac747d1394cd.zip
Make bonding and unbonding methods slightly more robust
Diffstat (limited to 'src')
-rw-r--r--src/libtdeldap.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/libtdeldap.cpp b/src/libtdeldap.cpp
index 8cf4bdd..5309ecb 100644
--- a/src/libtdeldap.cpp
+++ b/src/libtdeldap.cpp
@@ -1086,7 +1086,7 @@ int LDAPManager::setPasswordForUser(LDAPUserInfo user, TQString *errstr) {
prompt = readFullLineFromPtyProcess(&kadminProc);
printf("(kadmin) '%s'\n", prompt.ascii());
} while (prompt == "");
- prompt = prompt.stripWhiteSpace();
+ prompt = prompt.stripWhiteSpace();
if ((prompt.endsWith(" Password:")) && (prompt.startsWith("Verify"))) {
kadminProc.enableLocalEcho(false);
kadminProc.writeLine(user.new_password, true);
@@ -4143,6 +4143,7 @@ int LDAPManager::bondRealm(TQString adminUserName, const char * adminPassword, T
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);
@@ -4150,6 +4151,7 @@ int LDAPManager::bondRealm(TQString adminUserName, const char * adminPassword, T
} while ((prompt == TQString(command)) || (prompt == ""));
prompt = prompt.stripWhiteSpace();
if (prompt.endsWith(" Password:")) {
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(adminPassword, true);
do { // Discard our own input
prompt = readFullLineFromPtyProcess(&kadminProc);
@@ -4159,6 +4161,11 @@ int LDAPManager::bondRealm(TQString adminUserName, const char * adminPassword, T
}
if (prompt.contains("authentication failed")) {
if (errstr) *errstr = prompt;
+ do { // Wait for command prompt
+ prompt = readFullLineFromPtyProcess(&kadminProc);
+ printf("(kadmin) '%s'\n", prompt.ascii());
+ } while (prompt == "");
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
@@ -4168,6 +4175,7 @@ int LDAPManager::bondRealm(TQString adminUserName, const char * adminPassword, T
printf("(kadmin) '%s'\n", prompt.ascii());
} while (prompt == "");
command = TQCString("ank --random-key "+hoststring);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(command, true);
do { // Discard our own input
prompt = readFullLineFromPtyProcess(&kadminProc);
@@ -4177,6 +4185,7 @@ int LDAPManager::bondRealm(TQString adminUserName, const char * adminPassword, T
// Use all defaults
while (prompt != "kadmin>") {
if (prompt.endsWith(" Password:")) {
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(adminPassword, true);
do { // Discard our own input
prompt = readFullLineFromPtyProcess(&kadminProc);
@@ -4186,6 +4195,11 @@ int LDAPManager::bondRealm(TQString adminUserName, const char * adminPassword, T
}
if (prompt.contains("authentication failed")) {
if (errstr) *errstr = prompt;
+ do { // Wait for command prompt
+ prompt = readFullLineFromPtyProcess(&kadminProc);
+ printf("(kadmin) '%s'\n", prompt.ascii());
+ } while (prompt == "");
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
@@ -4199,6 +4213,7 @@ int LDAPManager::bondRealm(TQString adminUserName, const char * adminPassword, 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);
@@ -4208,6 +4223,7 @@ int LDAPManager::bondRealm(TQString adminUserName, const char * adminPassword, T
}
}
command = TQCString("ext "+hoststring);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(command, true);
do { // Discard our own input
prompt = readFullLineFromPtyProcess(&kadminProc);
@@ -4216,17 +4232,24 @@ int LDAPManager::bondRealm(TQString adminUserName, const char * adminPassword, T
prompt = prompt.stripWhiteSpace();
if (prompt != "kadmin>") {
if (errstr) *errstr = prompt;
+ do { // Wait for command prompt
+ prompt = readFullLineFromPtyProcess(&kadminProc);
+ printf("(kadmin) '%s'\n", prompt.ascii());
+ } while (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;
@@ -4234,6 +4257,11 @@ int LDAPManager::bondRealm(TQString adminUserName, const char * adminPassword, T
// Failure
if (errstr) *errstr = prompt;
+ while (prompt == "") { // Wait for command prompt
+ prompt = readFullLineFromPtyProcess(&kadminProc);
+ printf("(kadmin) '%s'\n", prompt.ascii());
+ }
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
@@ -4261,6 +4289,7 @@ int LDAPManager::unbondRealm(LDAPRealmConfig realmcfg, TQString adminUserName, c
prompt = prompt.stripWhiteSpace();
if (prompt == "kadmin>") {
command = TQCString("delete "+hoststring);
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(command, true);
do { // Discard our own input
prompt = readFullLineFromPtyProcess(&kadminProc);
@@ -4268,6 +4297,7 @@ int LDAPManager::unbondRealm(LDAPRealmConfig realmcfg, TQString adminUserName, c
} while ((prompt == TQString(command)) || (prompt == ""));
prompt = prompt.stripWhiteSpace();
if (prompt.endsWith(" Password:")) {
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine(adminPassword, true);
do { // Discard our own input
prompt = readFullLineFromPtyProcess(&kadminProc);
@@ -4277,11 +4307,17 @@ int LDAPManager::unbondRealm(LDAPRealmConfig realmcfg, TQString adminUserName, c
}
if (prompt != "kadmin>") {
if (errstr) *errstr = prompt;
+ do { // Wait for command prompt
+ prompt = readFullLineFromPtyProcess(&kadminProc);
+ printf("(kadmin) '%s'\n", prompt.ascii());
+ } while (prompt == "");
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
return 1;
}
// Success!
+ kadminProc.enableLocalEcho(false);
kadminProc.writeLine("quit", true);
// Delete keys from keytab