diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-10-06 02:04:49 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-10-09 01:20:01 +0200 |
| commit | e4b2ebd80779a44d24fe87af26ef278c1e2d97d2 (patch) | |
| tree | 3bc940c5eb49c96c3c18a896c8ccd8039e6db839 /src/certificate_chain.cc | |
| parent | 3be26a66645de04c7b220abeebfd2f024990a696 (diff) | |
Add wrappers around boost::filesystem methods that handle the
required mangling of long filenames on Windows.
Also wrap lots of missing places (e.g. calls to asdcplib, libxml++,
libcxml etc.) in dcp::filesystem::fix_long_path().
The idea is to keep paths un-mangled until they we call some
filesystem-related API and mangle them at that point. Otherwise
we end up serialising mangled names, which seems like it will
not end well.
Should fix DoM #2623.
Diffstat (limited to 'src/certificate_chain.cc')
| -rw-r--r-- | src/certificate_chain.cc | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/certificate_chain.cc b/src/certificate_chain.cc index 449dba89..6748d73c 100644 --- a/src/certificate_chain.cc +++ b/src/certificate_chain.cc @@ -41,6 +41,7 @@ #include "compose.hpp" #include "dcp_assert.h" #include "exceptions.h" +#include "filesystem.h" #include "util.h" #include "warnings.h" #include <asdcp/KM_util.h> @@ -57,7 +58,6 @@ LIBDCP_ENABLE_WARNINGS #include <openssl/evp.h> #include <openssl/pem.h> #include <openssl/rsa.h> -#include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> #include <fstream> #include <iostream> @@ -114,7 +114,7 @@ command (string cmd) int const code = WEXITSTATUS (r); #endif if (code) { - throw dcp::MiscError (String::compose ("error %1 in %2 within %3", code, cmd, boost::filesystem::current_path().string())); + throw dcp::MiscError(String::compose("error %1 in %2 within %3", code, cmd, filesystem::current_path().string())); } } @@ -196,10 +196,14 @@ CertificateChain::CertificateChain ( ) { auto directory = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path (); - boost::filesystem::create_directories (directory); + filesystem::create_directories(directory); - auto const cwd = boost::filesystem::current_path (); - boost::filesystem::current_path (directory); + auto const cwd = boost::filesystem::current_path(); + /* On Windows we will use cmd.exe here, and that doesn't work with UNC paths, so make sure + * we don't use our own filesystem::current_path() as it will make the current working + * directory a UNC path. + */ + boost::filesystem::current_path(directory); string quoted_openssl = "\"" + openssl.string() + "\""; @@ -319,7 +323,10 @@ CertificateChain::CertificateChain ( ) ); - boost::filesystem::current_path (cwd); + /* Use boost:: rather than dcp:: here so we don't force UNC into the current path if it + * wasn't there before. + */ + boost::filesystem::current_path(cwd); _certificates.push_back (dcp::Certificate(dcp::file_to_string(directory / "ca.self-signed.pem"))); _certificates.push_back (dcp::Certificate(dcp::file_to_string(directory / "intermediate.signed.pem"))); @@ -327,7 +334,7 @@ CertificateChain::CertificateChain ( _key = dcp::file_to_string (directory / "leaf.key"); - boost::filesystem::remove_all (directory); + filesystem::remove_all(directory); } |
