|
|
|
@ -1058,14 +1058,14 @@ int LDAPManager::setPasswordForUser(LDAPUserInfo user, TQString *errstr) {
|
|
|
|
|
TQCString command = "kadmin";
|
|
|
|
|
QCStringList args;
|
|
|
|
|
if (m_host.startsWith("ldapi://")) {
|
|
|
|
|
args << TQCString("-l") << TQCString("-r") << TQCString(admincreds.realm.upper());
|
|
|
|
|
args << TQCString("-l") << TQCString("-r") << admincreds.realm.upper().local8Bit();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (admincreds.username == "") {
|
|
|
|
|
args << TQCString("-r") << TQCString(admincreds.realm.upper());
|
|
|
|
|
args << TQCString("-r") << admincreds.realm.upper().local8Bit();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
args << TQCString("-p") << TQCString(admincreds.username.lower()+"@"+(admincreds.realm.upper())) << TQCString("-r") << TQCString(admincreds.realm.upper());
|
|
|
|
|
args << TQCString("-p") << TQString("%1@%2").arg(admincreds.username.lower()).arg(admincreds.realm.upper()).local8Bit() << TQCString("-r") << admincreds.realm.upper().local8Bit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1075,7 +1075,7 @@ int LDAPManager::setPasswordForUser(LDAPUserInfo user, TQString *errstr) {
|
|
|
|
|
prompt = readFullLineFromPtyProcess(&kadminProc);
|
|
|
|
|
prompt = prompt.stripWhiteSpace();
|
|
|
|
|
if (prompt == "kadmin>") {
|
|
|
|
|
command = TQCString("passwd "+user.name);
|
|
|
|
|
command = TQCString("passwd ")+user.name.local8Bit();
|
|
|
|
|
kadminProc.enableLocalEcho(false);
|
|
|
|
|
kadminProc.writeLine(command, true);
|
|
|
|
|
do { // Discard our own input
|
|
|
|
@ -1113,7 +1113,7 @@ int LDAPManager::setPasswordForUser(LDAPUserInfo user, TQString *errstr) {
|
|
|
|
|
TQFile file;
|
|
|
|
|
file.open(IO_ReadOnly, stdin);
|
|
|
|
|
TQTextStream qtin(&file);
|
|
|
|
|
admincreds.password = qtin.readLine();
|
|
|
|
|
admincreds.password = qtin.readLine().local8Bit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (admincreds.password != "") {
|
|
|
|
@ -1160,8 +1160,8 @@ TQString klistDateTimeToRFCDateTime(TQString datetime) {
|
|
|
|
|
// HACK HACK HACK
|
|
|
|
|
// FIXME
|
|
|
|
|
TQString ret;
|
|
|
|
|
TQString command = TQString("date -R -d \"%1\"").arg(datetime);
|
|
|
|
|
FILE *output = popen(command.ascii(), "r");
|
|
|
|
|
TQCString command = TQString("date -R -d \"%1\"").arg(datetime).local8Bit();
|
|
|
|
|
FILE *output = popen(command, "r");
|
|
|
|
|
TQFile f;
|
|
|
|
|
f.open(IO_ReadOnly, output);
|
|
|
|
|
TQTextStream stream(&f);
|
|
|
|
@ -1426,10 +1426,10 @@ int LDAPManager::obtainKerberosTicket(LDAPCredentials creds, TQString principal,
|
|
|
|
|
TQCString command = "kinit";
|
|
|
|
|
QCStringList args;
|
|
|
|
|
if (principal == "") {
|
|
|
|
|
args << TQCString(creds.username + "@" + creds.realm.upper());
|
|
|
|
|
args << TQString("%1@%2").arg(creds.username).arg(creds.realm.upper()).local8Bit();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
args << TQCString("-S") << TQCString(principal) << TQCString(creds.username + "@" + creds.realm.upper());
|
|
|
|
|
args << TQCString("-S") << principal.local8Bit() << TQString("%1@%2").arg(creds.username).arg(creds.realm.upper()).local8Bit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQString prompt;
|
|
|
|
@ -1457,8 +1457,8 @@ int LDAPManager::obtainKerberosTicket(LDAPCredentials creds, TQString principal,
|
|
|
|
|
|
|
|
|
|
int LDAPManager::obtainKerberosServiceTicket(TQString principal, TQString *errstr) {
|
|
|
|
|
TQString ret;
|
|
|
|
|
TQString command = TQString("kgetcred \"%1\"").arg(principal);
|
|
|
|
|
FILE *output = popen(command.ascii(), "r");
|
|
|
|
|
TQCString command = TQString("kgetcred \"%1\"").arg(principal).local8Bit();
|
|
|
|
|
FILE *output = popen(command, "r");
|
|
|
|
|
TQFile f;
|
|
|
|
|
f.open(IO_ReadOnly, output);
|
|
|
|
|
TQTextStream stream(&f);
|
|
|
|
@ -1475,8 +1475,8 @@ int LDAPManager::obtainKerberosServiceTicket(TQString principal, TQString *errst
|
|
|
|
|
|
|
|
|
|
int LDAPManager::destroyKerberosTicket(TQString principal, TQString *errstr) {
|
|
|
|
|
TQString ret;
|
|
|
|
|
TQString command = TQString("kdestroy --credential=\"%1\"").arg(principal);
|
|
|
|
|
FILE *output = popen(command.ascii(), "r");
|
|
|
|
|
TQCString command = TQString("kdestroy --credential=\"%1\"").arg(principal).local8Bit();
|
|
|
|
|
FILE *output = popen(command, "r");
|
|
|
|
|
TQFile f;
|
|
|
|
|
f.open(IO_ReadOnly, output);
|
|
|
|
|
TQTextStream stream(&f);
|
|
|
|
@ -1687,14 +1687,14 @@ int LDAPManager::addMachineInfo(LDAPMachineInfo machine, TQString *errstr) {
|
|
|
|
|
TQCString command = "kadmin";
|
|
|
|
|
QCStringList args;
|
|
|
|
|
if (m_host.startsWith("ldapi://")) {
|
|
|
|
|
args << TQCString("-l") << TQCString("-r") << TQCString(admincreds.realm.upper());
|
|
|
|
|
args << TQCString("-l") << TQCString("-r") << admincreds.realm.upper().local8Bit();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (admincreds.username == "") {
|
|
|
|
|
args << TQCString("-r") << TQCString(admincreds.realm.upper());
|
|
|
|
|
args << TQCString("-r") << admincreds.realm.upper().local8Bit();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
args << TQCString("-p") << TQCString(admincreds.username.lower()+"@"+(admincreds.realm.upper())) << TQCString("-r") << TQCString(admincreds.realm.upper());
|
|
|
|
|
args << TQCString("-p") << TQString("%1@%2").arg(admincreds.username.lower()).arg(admincreds.realm.upper()).local8Bit() << TQCString("-r") << admincreds.realm.upper().local8Bit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1707,10 +1707,10 @@ int LDAPManager::addMachineInfo(LDAPMachineInfo machine, TQString *errstr) {
|
|
|
|
|
prompt = prompt.stripWhiteSpace();
|
|
|
|
|
if (prompt == "kadmin>") {
|
|
|
|
|
if (machine.newPassword == "") {
|
|
|
|
|
command = TQCString("ank --random-key "+hoststring);
|
|
|
|
|
command = TQCString("ank --random-key ")+hoststring.local8Bit();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
command = TQCString("ank --password=\""+machine.newPassword+"\" "+hoststring);
|
|
|
|
|
command = TQCString("ank --password=\"")+machine.newPassword.local8Bit()+TQCString("\" ")+hoststring.local8Bit();
|
|
|
|
|
}
|
|
|
|
|
kadminProc.enableLocalEcho(false);
|
|
|
|
|
kadminProc.writeLine(command, true);
|
|
|
|
@ -1734,7 +1734,7 @@ int LDAPManager::addMachineInfo(LDAPMachineInfo machine, TQString *errstr) {
|
|
|
|
|
TQFile file;
|
|
|
|
|
file.open(IO_ReadOnly, stdin);
|
|
|
|
|
TQTextStream qtin(&file);
|
|
|
|
|
admincreds.password = qtin.readLine();
|
|
|
|
|
admincreds.password = qtin.readLine().local8Bit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (admincreds.password != "") {
|
|
|
|
@ -1762,7 +1762,7 @@ int LDAPManager::addMachineInfo(LDAPMachineInfo machine, TQString *errstr) {
|
|
|
|
|
leftbracket++;
|
|
|
|
|
defaultParam = prompt.mid(leftbracket, rightbracket-leftbracket);
|
|
|
|
|
}
|
|
|
|
|
command = TQCString(defaultParam);
|
|
|
|
|
command = defaultParam.local8Bit();
|
|
|
|
|
kadminProc.enableLocalEcho(false);
|
|
|
|
|
kadminProc.writeLine(command, true);
|
|
|
|
|
do { // Discard our own input
|
|
|
|
@ -1812,14 +1812,14 @@ int LDAPManager::addServiceInfo(LDAPServiceInfo service, TQString *errstr) {
|
|
|
|
|
TQCString command = "kadmin";
|
|
|
|
|
QCStringList args;
|
|
|
|
|
if (m_host.startsWith("ldapi://")) {
|
|
|
|
|
args << TQCString("-l") << TQCString("-r") << TQCString(admincreds.realm.upper());
|
|
|
|
|
args << TQCString("-l") << TQCString("-r") << admincreds.realm.upper().local8Bit();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (admincreds.username == "") {
|
|
|
|
|
args << TQCString("-r") << TQCString(admincreds.realm.upper());
|
|
|
|
|
args << TQCString("-r") << admincreds.realm.upper().local8Bit();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
args << TQCString("-p") << TQCString(admincreds.username.lower()+"@"+(admincreds.realm.upper())) << TQCString("-r") << TQCString(admincreds.realm.upper());
|
|
|
|
|
args << TQCString("-p") << TQString("%1@%2").arg(admincreds.username.lower()).arg(admincreds.realm.upper()).local8Bit() << TQCString("-r") << admincreds.realm.upper().local8Bit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1831,7 +1831,7 @@ int LDAPManager::addServiceInfo(LDAPServiceInfo service, TQString *errstr) {
|
|
|
|
|
prompt = readFullLineFromPtyProcess(&kadminProc);
|
|
|
|
|
prompt = prompt.stripWhiteSpace();
|
|
|
|
|
if (prompt == "kadmin>") {
|
|
|
|
|
command = TQCString("ank --random-key "+hoststring);
|
|
|
|
|
command = TQCString("ank --random-key ")+hoststring.local8Bit();
|
|
|
|
|
kadminProc.enableLocalEcho(false);
|
|
|
|
|
kadminProc.writeLine(command, true);
|
|
|
|
|
do { // Discard our own input
|
|
|
|
@ -1854,7 +1854,7 @@ int LDAPManager::addServiceInfo(LDAPServiceInfo service, TQString *errstr) {
|
|
|
|
|
TQFile file;
|
|
|
|
|
file.open(IO_ReadOnly, stdin);
|
|
|
|
|
TQTextStream qtin(&file);
|
|
|
|
|
admincreds.password = qtin.readLine();
|
|
|
|
|
admincreds.password = qtin.readLine().local8Bit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (admincreds.password != "") {
|
|
|
|
@ -1882,7 +1882,7 @@ int LDAPManager::addServiceInfo(LDAPServiceInfo service, TQString *errstr) {
|
|
|
|
|
leftbracket++;
|
|
|
|
|
defaultParam = prompt.mid(leftbracket, rightbracket-leftbracket);
|
|
|
|
|
}
|
|
|
|
|
command = TQCString(defaultParam);
|
|
|
|
|
command = defaultParam.local8Bit();
|
|
|
|
|
kadminProc.enableLocalEcho(false);
|
|
|
|
|
kadminProc.writeLine(command, true);
|
|
|
|
|
do { // Discard our own input
|
|
|
|
@ -2519,14 +2519,14 @@ int LDAPManager::exportKeytabForPrincipal(TQString principal, TQString fileName,
|
|
|
|
|
TQCString command = "kadmin";
|
|
|
|
|
QCStringList args;
|
|
|
|
|
if (m_host.startsWith("ldapi://")) {
|
|
|
|
|
args << TQCString("-l") << TQCString("-r") << TQCString(admincreds.realm.upper());
|
|
|
|
|
args << TQCString("-l") << TQCString("-r") << admincreds.realm.upper().local8Bit();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (admincreds.username == "") {
|
|
|
|
|
args << TQCString("-r") << TQCString(admincreds.realm.upper());
|
|
|
|
|
args << TQCString("-r") << admincreds.realm.upper().local8Bit();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
args << TQCString("-p") << TQCString(admincreds.username.lower()+"@"+(admincreds.realm.upper())) << TQCString("-r") << TQCString(admincreds.realm.upper());
|
|
|
|
|
args << TQCString("-p") << TQString("%1@%2").arg(admincreds.username.lower()).arg(admincreds.realm.upper()).local8Bit() << TQCString("-r") << admincreds.realm.upper().local8Bit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2537,10 +2537,10 @@ int LDAPManager::exportKeytabForPrincipal(TQString principal, TQString fileName,
|
|
|
|
|
prompt = prompt.stripWhiteSpace();
|
|
|
|
|
if (prompt == "kadmin>") {
|
|
|
|
|
if (fileName == "") {
|
|
|
|
|
command = TQCString("ext_keytab "+principal);
|
|
|
|
|
command = TQCString("ext_keytab ")+principal.local8Bit();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
command = TQCString("ext_keytab --keytab=\""+fileName+"\" "+principal);
|
|
|
|
|
command = TQCString("ext_keytab --keytab=\"")+fileName.local8Bit()+TQCString("\" ")+principal.local8Bit();
|
|
|
|
|
}
|
|
|
|
|
kadminProc.enableLocalEcho(false);
|
|
|
|
|
kadminProc.writeLine(command, true);
|
|
|
|
@ -2564,7 +2564,7 @@ int LDAPManager::exportKeytabForPrincipal(TQString principal, TQString fileName,
|
|
|
|
|
TQFile file;
|
|
|
|
|
file.open(IO_ReadOnly, stdin);
|
|
|
|
|
TQTextStream qtin(&file);
|
|
|
|
|
admincreds.password = qtin.readLine();
|
|
|
|
|
admincreds.password = qtin.readLine().local8Bit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (admincreds.password != "") {
|
|
|
|
@ -2592,7 +2592,7 @@ int LDAPManager::exportKeytabForPrincipal(TQString principal, TQString fileName,
|
|
|
|
|
leftbracket++;
|
|
|
|
|
defaultParam = prompt.mid(leftbracket, rightbracket-leftbracket);
|
|
|
|
|
}
|
|
|
|
|
command = TQCString(defaultParam);
|
|
|
|
|
command = defaultParam.local8Bit();
|
|
|
|
|
kadminProc.enableLocalEcho(false);
|
|
|
|
|
kadminProc.writeLine(command, true);
|
|
|
|
|
do { // Discard our own input
|
|
|
|
@ -2759,7 +2759,7 @@ int LDAPManager::moveKerberosEntries(TQString newSuffix, TQString* errstr) {
|
|
|
|
|
if((dn = ldap_get_dn(m_ldap, entry)) != NULL) {
|
|
|
|
|
TQStringList dnParts = TQStringList::split(",", dn);
|
|
|
|
|
TQString id = dnParts[0];
|
|
|
|
|
retcode = ldap_rename_s(m_ldap, dn, id, newSuffix, 0, NULL, NULL);
|
|
|
|
|
retcode = ldap_rename_s(m_ldap, dn, id.utf8(), newSuffix.utf8(), 0, NULL, NULL);
|
|
|
|
|
if (retcode != LDAP_SUCCESS) {
|
|
|
|
|
if (errstr) *errstr = i18n("LDAP rename failure<p>Reason: [%3] %4").arg(retcode).arg(ldap_err2string(retcode));
|
|
|
|
|
return -1;
|
|
|
|
@ -2785,7 +2785,7 @@ int LDAPManager::writeLDAPConfFile(LDAPRealmConfig realmcfg, LDAPMachineRole mac
|
|
|
|
|
int m_ldapBindTimeout;
|
|
|
|
|
TQString m_passwordHash;
|
|
|
|
|
TQString m_ignoredUsers;
|
|
|
|
|
TQString command;
|
|
|
|
|
TQCString command;
|
|
|
|
|
|
|
|
|
|
systemconfig = new KSimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/ldap/ldapconfigrc" ));
|
|
|
|
|
systemconfig->setGroup(NULL);
|
|
|
|
@ -2839,9 +2839,9 @@ int LDAPManager::writeLDAPConfFile(LDAPRealmConfig realmcfg, LDAPMachineRole mac
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
command = TQString("ln -s %1 %2").arg(LDAP_FILE).arg(LDAP_SECONDARY_FILE);
|
|
|
|
|
command = TQString("ln -s %1 %2").arg(LDAP_FILE).arg(LDAP_SECONDARY_FILE).local8Bit();
|
|
|
|
|
if (system(command) < 0) {
|
|
|
|
|
if (errstr) *errstr = TQString("Execution of \"%s\" failed").arg(command.ascii());
|
|
|
|
|
if (errstr) *errstr = TQString("Execution of \"%s\" failed").arg(command);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2852,9 +2852,9 @@ int LDAPManager::writeLDAPConfFile(LDAPRealmConfig realmcfg, LDAPMachineRole mac
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
command = TQString("ln -s %1 %2").arg(LDAP_FILE).arg(LDAP_TERTIARY_FILE);
|
|
|
|
|
command = TQString("ln -s %1 %2").arg(LDAP_FILE).arg(LDAP_TERTIARY_FILE).local8Bit();
|
|
|
|
|
if (system(command) < 0) {
|
|
|
|
|
if (errstr) *errstr = TQString("Execution of \"%s\" failed").arg(command.ascii());
|
|
|
|
|
if (errstr) *errstr = TQString("Execution of \"%s\" failed").arg(command);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -3807,11 +3807,11 @@ TQDateTime LDAPManager::getCertificateExpiration(TQString certfile) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int LDAPManager::generatePublicKerberosCACertificate(LDAPCertConfig certinfo) {
|
|
|
|
|
TQString command;
|
|
|
|
|
TQCString command;
|
|
|
|
|
|
|
|
|
|
command = TQString("openssl req -key %1 -new -x509 -out %2 -subj \"/C=%3/ST=%4/L=%5/O=%6/OU=%7/CN=%8/emailAddress=%9\"").arg(KERBEROS_PKI_PEMKEY_FILE).arg(KERBEROS_PKI_PEM_FILE).arg(certinfo.countryName).arg(certinfo.stateOrProvinceName).arg(certinfo.localityName).arg(certinfo.organizationName).arg(certinfo.orgUnitName).arg(certinfo.commonName).arg(certinfo.emailAddress);
|
|
|
|
|
command = TQString("openssl req -key %1 -new -x509 -out %2 -subj \"/C=%3/ST=%4/L=%5/O=%6/OU=%7/CN=%8/emailAddress=%9\"").arg(KERBEROS_PKI_PEMKEY_FILE).arg(KERBEROS_PKI_PEM_FILE).arg(certinfo.countryName).arg(certinfo.stateOrProvinceName).arg(certinfo.localityName).arg(certinfo.organizationName).arg(certinfo.orgUnitName).arg(certinfo.commonName).arg(certinfo.emailAddress).local8Bit();
|
|
|
|
|
if (system(command) < 0) {
|
|
|
|
|
printf("ERROR: Execution of \"%s\" failed!\n", command.ascii());
|
|
|
|
|
printf("ERROR: Execution of \"%s\" failed!\n", command.data());
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (chmod(KERBEROS_PKI_PEM_FILE, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) {
|
|
|
|
@ -3827,7 +3827,7 @@ int LDAPManager::generatePublicKerberosCACertificate(LDAPCertConfig certinfo) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int LDAPManager::generatePublicKerberosCertificate(LDAPCertConfig certinfo, LDAPRealmConfig realmcfg) {
|
|
|
|
|
TQString command;
|
|
|
|
|
TQCString command;
|
|
|
|
|
|
|
|
|
|
TQString kdc_certfile = KERBEROS_PKI_KDC_FILE;
|
|
|
|
|
TQString kdc_keyfile = KERBEROS_PKI_KDCKEY_FILE;
|
|
|
|
@ -3836,14 +3836,14 @@ int LDAPManager::generatePublicKerberosCertificate(LDAPCertConfig certinfo, LDAP
|
|
|
|
|
kdc_keyfile.replace("@@@KDCSERVER@@@", realmcfg.name.lower());
|
|
|
|
|
kdc_reqfile.replace("@@@KDCSERVER@@@", realmcfg.name.lower());
|
|
|
|
|
|
|
|
|
|
command = TQString("openssl req -new -out %1 -key %2 -subj \"/C=%3/ST=%4/L=%5/O=%6/OU=%7/CN=%8/emailAddress=%9\"").arg(kdc_reqfile).arg(kdc_keyfile).arg(certinfo.countryName).arg(certinfo.stateOrProvinceName).arg(certinfo.localityName).arg(certinfo.organizationName).arg(certinfo.orgUnitName).arg(certinfo.commonName).arg(certinfo.emailAddress);
|
|
|
|
|
command = TQString("openssl req -new -out %1 -key %2 -subj \"/C=%3/ST=%4/L=%5/O=%6/OU=%7/CN=%8/emailAddress=%9\"").arg(kdc_reqfile).arg(kdc_keyfile).arg(certinfo.countryName).arg(certinfo.stateOrProvinceName).arg(certinfo.localityName).arg(certinfo.organizationName).arg(certinfo.orgUnitName).arg(certinfo.commonName).arg(certinfo.emailAddress).local8Bit();
|
|
|
|
|
if (system(command) < 0) {
|
|
|
|
|
printf("ERROR: Execution of \"%s\" failed!\n", command.ascii());
|
|
|
|
|
printf("ERROR: Execution of \"%s\" failed!\n", command.data());
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
command = TQString("openssl x509 -req -in %1 -CAkey %2 -CA %3 -out %4 -extfile %5 -extensions kdc_cert -CAcreateserial").arg(kdc_reqfile).arg(KERBEROS_PKI_PEMKEY_FILE).arg(KERBEROS_PKI_PEM_FILE).arg(kdc_certfile).arg(OPENSSL_EXTENSIONS_FILE);
|
|
|
|
|
command = TQString("openssl x509 -req -in %1 -CAkey %2 -CA %3 -out %4 -extfile %5 -extensions kdc_cert -CAcreateserial").arg(kdc_reqfile).arg(KERBEROS_PKI_PEMKEY_FILE).arg(KERBEROS_PKI_PEM_FILE).arg(kdc_certfile).arg(OPENSSL_EXTENSIONS_FILE).local8Bit();
|
|
|
|
|
if (system(command) < 0) {
|
|
|
|
|
printf("ERROR: Execution of \"%s\" failed!\n", command.ascii());
|
|
|
|
|
printf("ERROR: Execution of \"%s\" failed!\n", command.data());
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (chmod(kdc_certfile.ascii(), S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) {
|
|
|
|
@ -3865,7 +3865,7 @@ int LDAPManager::generatePublicKerberosCertificate(LDAPCertConfig certinfo, LDAP
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int LDAPManager::generatePublicLDAPCertificate(LDAPCertConfig certinfo, LDAPRealmConfig realmcfg, uid_t ldap_uid, gid_t ldap_gid) {
|
|
|
|
|
TQString command;
|
|
|
|
|
TQCString command;
|
|
|
|
|
|
|
|
|
|
TQString ldap_certfile = LDAP_CERT_FILE;
|
|
|
|
|
TQString ldap_keyfile = LDAP_CERTKEY_FILE;
|
|
|
|
@ -3874,14 +3874,14 @@ int LDAPManager::generatePublicLDAPCertificate(LDAPCertConfig certinfo, LDAPReal
|
|
|
|
|
ldap_keyfile.replace("@@@ADMINSERVER@@@", realmcfg.name.lower());
|
|
|
|
|
ldap_reqfile.replace("@@@ADMINSERVER@@@", realmcfg.name.lower());
|
|
|
|
|
|
|
|
|
|
command = TQString("openssl req -new -out %1 -key %2 -subj \"/C=%3/ST=%4/L=%5/O=%6/OU=%7/CN=%8/emailAddress=%9\"").arg(ldap_reqfile).arg(ldap_keyfile).arg(certinfo.countryName).arg(certinfo.stateOrProvinceName).arg(certinfo.localityName).arg(certinfo.organizationName).arg(certinfo.orgUnitName).arg(realmcfg.admin_server).arg(certinfo.emailAddress);
|
|
|
|
|
command = TQString("openssl req -new -out %1 -key %2 -subj \"/C=%3/ST=%4/L=%5/O=%6/OU=%7/CN=%8/emailAddress=%9\"").arg(ldap_reqfile).arg(ldap_keyfile).arg(certinfo.countryName).arg(certinfo.stateOrProvinceName).arg(certinfo.localityName).arg(certinfo.organizationName).arg(certinfo.orgUnitName).arg(realmcfg.admin_server).arg(certinfo.emailAddress).local8Bit();
|
|
|
|
|
if (system(command) < 0) {
|
|
|
|
|
printf("ERROR: Execution of \"%s\" failed!\n", command.ascii());
|
|
|
|
|
printf("ERROR: Execution of \"%s\" failed!\n", command.data());
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
command = TQString("openssl x509 -req -in %1 -CAkey %2 -CA %3 -out %4 -CAcreateserial").arg(ldap_reqfile).arg(KERBEROS_PKI_PEMKEY_FILE).arg(KERBEROS_PKI_PEM_FILE).arg(ldap_certfile);
|
|
|
|
|
command = TQString("openssl x509 -req -in %1 -CAkey %2 -CA %3 -out %4 -CAcreateserial").arg(ldap_reqfile).arg(KERBEROS_PKI_PEMKEY_FILE).arg(KERBEROS_PKI_PEM_FILE).arg(ldap_certfile).local8Bit();
|
|
|
|
|
if (system(command) < 0) {
|
|
|
|
|
printf("ERROR: Execution of \"%s\" failed!\n", command.ascii());
|
|
|
|
|
printf("ERROR: Execution of \"%s\" failed!\n", command.data());
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (chmod(ldap_certfile.ascii(), S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) {
|
|
|
|
@ -4136,7 +4136,7 @@ int LDAPManager::writePAMFiles(LDAPPamConfig pamConfig, TQString *errstr) {
|
|
|
|
|
int LDAPManager::bondRealm(TQString adminUserName, const char * adminPassword, TQString adminRealm, TQString *errstr) {
|
|
|
|
|
TQCString command = "kadmin";
|
|
|
|
|
QCStringList args;
|
|
|
|
|
args << TQCString("-p") << TQCString(adminUserName+"@"+(adminRealm.upper())) << TQCString("-r") << TQCString(adminRealm.upper());
|
|
|
|
|
args << TQCString("-p") << TQString("%1@%2").arg(adminUserName).arg(adminRealm.upper()).local8Bit() << TQCString("-r") << adminRealm.upper().local8Bit();
|
|
|
|
|
|
|
|
|
|
TQString hoststring = "host/"+getMachineFQDN();
|
|
|
|
|
|
|
|
|
@ -4146,7 +4146,7 @@ int LDAPManager::bondRealm(TQString adminUserName, const char * adminPassword, T
|
|
|
|
|
prompt = readFullLineFromPtyProcess(&kadminProc);
|
|
|
|
|
prompt = prompt.stripWhiteSpace();
|
|
|
|
|
if (prompt == "kadmin>") {
|
|
|
|
|
command = TQCString("ext "+hoststring);
|
|
|
|
|
command = TQCString("ext ")+hoststring.local8Bit();
|
|
|
|
|
kadminProc.enableLocalEcho(false);
|
|
|
|
|
kadminProc.writeLine(command, true);
|
|
|
|
|
do { // Discard our own input
|
|
|
|
@ -4178,7 +4178,7 @@ int LDAPManager::bondRealm(TQString adminUserName, const char * adminPassword, T
|
|
|
|
|
prompt = readFullLineFromPtyProcess(&kadminProc);
|
|
|
|
|
printf("(kadmin) '%s'\n", prompt.ascii());
|
|
|
|
|
} while (prompt == "");
|
|
|
|
|
command = TQCString("ank --random-key "+hoststring);
|
|
|
|
|
command = TQCString("ank --random-key ")+hoststring.local8Bit();
|
|
|
|
|
kadminProc.enableLocalEcho(false);
|
|
|
|
|
kadminProc.writeLine(command, true);
|
|
|
|
|
do { // Discard our own input
|
|
|
|
@ -4216,7 +4216,7 @@ int LDAPManager::bondRealm(TQString adminUserName, const char * adminPassword, T
|
|
|
|
|
leftbracket++;
|
|
|
|
|
defaultParam = prompt.mid(leftbracket, rightbracket-leftbracket);
|
|
|
|
|
}
|
|
|
|
|
command = TQCString(defaultParam);
|
|
|
|
|
command = defaultParam.local8Bit();
|
|
|
|
|
kadminProc.enableLocalEcho(false);
|
|
|
|
|
kadminProc.writeLine(command, true);
|
|
|
|
|
do { // Discard our own input
|
|
|
|
@ -4226,7 +4226,7 @@ int LDAPManager::bondRealm(TQString adminUserName, const char * adminPassword, T
|
|
|
|
|
prompt = prompt.stripWhiteSpace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
command = TQCString("ext "+hoststring);
|
|
|
|
|
command = TQCString("ext ")+hoststring.local8Bit();
|
|
|
|
|
kadminProc.enableLocalEcho(false);
|
|
|
|
|
kadminProc.writeLine(command, true);
|
|
|
|
|
do { // Discard our own input
|
|
|
|
@ -4279,7 +4279,7 @@ int LDAPManager::unbondRealm(LDAPRealmConfig realmcfg, TQString adminUserName, c
|
|
|
|
|
|
|
|
|
|
TQCString command = "kadmin";
|
|
|
|
|
QCStringList args;
|
|
|
|
|
args << TQCString("-p") << TQCString(adminUserName+"@"+(adminRealm.upper()));
|
|
|
|
|
args << TQCString("-p") << TQString("%1@%2").arg(adminUserName).arg(adminRealm.upper()).local8Bit();
|
|
|
|
|
|
|
|
|
|
TQString hoststring = "host/"+getMachineFQDN();
|
|
|
|
|
|
|
|
|
@ -4292,7 +4292,7 @@ int LDAPManager::unbondRealm(LDAPRealmConfig realmcfg, TQString adminUserName, c
|
|
|
|
|
prompt = readFullLineFromPtyProcess(&kadminProc);
|
|
|
|
|
prompt = prompt.stripWhiteSpace();
|
|
|
|
|
if (prompt == "kadmin>") {
|
|
|
|
|
command = TQCString("delete "+hoststring);
|
|
|
|
|
command = TQCString("delete ")+hoststring.local8Bit();
|
|
|
|
|
kadminProc.enableLocalEcho(false);
|
|
|
|
|
kadminProc.writeLine(command, true);
|
|
|
|
|
do { // Discard our own input
|
|
|
|
@ -4325,7 +4325,7 @@ int LDAPManager::unbondRealm(LDAPRealmConfig realmcfg, TQString adminUserName, c
|
|
|
|
|
kadminProc.writeLine("quit", true);
|
|
|
|
|
|
|
|
|
|
// Delete keys from keytab
|
|
|
|
|
command = TQString("ktutil remove -p %1").arg(hoststring+"@"+adminRealm.upper());
|
|
|
|
|
command = TQString("ktutil remove -p %1").arg(hoststring+"@"+adminRealm.upper()).local8Bit();
|
|
|
|
|
if (system(command) < 0) {
|
|
|
|
|
printf("ERROR: Execution of \"%s\" failed!\n", command.data());
|
|
|
|
|
return 1; // Failure
|
|
|
|
|