13
0

Clarify that ca_info files must exist as files

From file_test documentation:
  Returns TRUE if any of the tests in the bitfield test are TRUE.

A Glib::file_test parameter like
  Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR
will thus also return true if the path exist as a directory.

Make the code work as intended by simply using
Glib::FILE_TEST_IS_REGULAR
This commit is contained in:
Mads Kiilerich 2022-10-22 01:43:44 +02:00 committed by Robin Gareus
parent d069aa7a56
commit 47b7b98652
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -83,15 +83,15 @@ HttpGet::setup_certificate_paths ()
*/ */
assert (!ca_path && !ca_info); // call once assert (!ca_path && !ca_info); // call once
if (Glib::file_test ("/etc/pki/tls/certs/ca-bundle.crt", Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) { if (Glib::file_test ("/etc/pki/tls/certs/ca-bundle.crt", Glib::FILE_TEST_IS_REGULAR)) {
// Fedora / RHEL, Arch // Fedora / RHEL, Arch
ca_info = "/etc/pki/tls/certs/ca-bundle.crt"; ca_info = "/etc/pki/tls/certs/ca-bundle.crt";
} }
else if (Glib::file_test ("/etc/ssl/certs/ca-certificates.crt", Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) { else if (Glib::file_test ("/etc/ssl/certs/ca-certificates.crt", Glib::FILE_TEST_IS_REGULAR)) {
// Debian and derivatives // Debian and derivatives
ca_info = "/etc/ssl/certs/ca-certificates.crt"; ca_info = "/etc/ssl/certs/ca-certificates.crt";
} }
else if (Glib::file_test ("/etc/pki/tls/cert.pem", Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) { else if (Glib::file_test ("/etc/pki/tls/cert.pem", Glib::FILE_TEST_IS_REGULAR)) {
// GNU/TLS can keep extra stuff here // GNU/TLS can keep extra stuff here
ca_info = "/etc/pki/tls/cert.pem"; ca_info = "/etc/pki/tls/cert.pem";
} }