diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-02-13 22:49:39 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-02-13 22:49:39 -0600 |
commit | ebe5fa27bf7265c0580ae3bf93ff28258ecfcb27 (patch) | |
tree | a53a8230b82b6a5eac21ac49cd56131cd4c4cbf9 /src | |
parent | bdb1c6b002c350e1354e9d34fa304fd83152502a (diff) | |
download | libtdeldap-ebe5fa27bf7265c0580ae3bf93ff28258ecfcb27.tar.gz libtdeldap-ebe5fa27bf7265c0580ae3bf93ff28258ecfcb27.zip |
Do not use GUI dialog to prompt for password when operating in CLI mode
Diffstat (limited to 'src')
-rw-r--r-- | src/libtdeldap.cpp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/libtdeldap.cpp b/src/libtdeldap.cpp index 1f35469..3220f7c 100644 --- a/src/libtdeldap.cpp +++ b/src/libtdeldap.cpp @@ -978,10 +978,18 @@ int LDAPManager::setPasswordForUser(LDAPUserInfo user, TQString *errstr) { } if (prompt.endsWith(" Password:")) { if (admincreds.password == "") { - TQCString password; - int result = KPasswordDialog::getPassword(password, prompt); - if (result == KPasswordDialog::Accepted) { - admincreds.password = password; + if (tqApp->type() != TQApplication::Tty) { + TQCString password; + int result = KPasswordDialog::getPassword(password, prompt); + if (result == KPasswordDialog::Accepted) { + admincreds.password = password; + } + } + else { + TQFile file; + file.open(IO_ReadOnly, stdin); + TQTextStream qtin(&file); + admincreds.password = qtin.readLine(); } } if (admincreds.password != "") { @@ -1633,10 +1641,18 @@ int LDAPManager::addServiceInfo(LDAPServiceInfo service, TQString *errstr) { while (prompt != "kadmin>") { if (prompt.endsWith(" Password:")) { if (admincreds.password == "") { - TQCString password; - int result = KPasswordDialog::getPassword(password, prompt); - if (result == KPasswordDialog::Accepted) { - admincreds.password = password; + if (tqApp->type() != TQApplication::Tty) { + TQCString password; + int result = KPasswordDialog::getPassword(password, prompt); + if (result == KPasswordDialog::Accepted) { + admincreds.password = password; + } + } + else { + TQFile file; + file.open(IO_ReadOnly, stdin); + TQTextStream qtin(&file); + admincreds.password = qtin.readLine(); } } if (admincreds.password != "") { |