summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2011-04-18 12:31:37 +0200
committerHans de Goede <hdegoede@redhat.com>2011-04-20 10:47:18 +0200
commite733aee0f2726e68736bf3d0dfb4545c6c786dd0 (patch)
tree612f726e72284fad1e118a8d9f46e38fc7ff88a4
parent1d61c0211e1c72c5d80c631f0543f2ad88ef4f3d (diff)
downloadspice-e733aee0f2726e68736bf3d0dfb4545c6c786dd0.tar.gz
spice-e733aee0f2726e68736bf3d0dfb4545c6c786dd0.tar.xz
spice-e733aee0f2726e68736bf3d0dfb4545c6c786dd0.zip
client: skip spaces in --host-subject
This fixes fdo bug #32896: "Subject in certificates is stored in following format (values separated by comma and space): grep Subject: server-cert.pem | awk -F": " '{print $2}' O=REDHAT, CN=10.34.58.2 While spicec expects that values in host subject are separated only by comma: spicec --host-subject "O=REDHAT,CN=10.34.58.2" " In this case, ignoring spaces make it much easier to directly copy and paste the subject line from certificates.
-rw-r--r--client/application.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/client/application.cpp b/client/application.cpp
index e7e24929..60c7dde8 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -2001,7 +2001,14 @@ bool Application::set_host_cert_subject(const char* subject, const char* arg0)
_exit_code = SPICEC_ERROR_CODE_INVALID_ARG;
return false;
}
- entry_pair.first = entry.substr(0, value_pos);
+ size_t start_pos = entry.find_first_not_of(' ');
+ if ((start_pos == std::string::npos) || (start_pos == value_pos)) {
+ Platform::term_printf("%s: host_subject bad format: first part of assignment must be non empty in %s\n",
+ arg0, entry.c_str());
+ _exit_code = SPICEC_ERROR_CODE_INVALID_ARG;
+ return false;
+ }
+ entry_pair.first = entry.substr(start_pos, value_pos - start_pos);
entry_pair.second = entry.substr(value_pos + 1);
_host_auth_opt.host_subject.push_back(entry_pair);
DBG(0, "subject entry: %s=%s", entry_pair.first.c_str(), entry_pair.second.c_str());