1
Fork 0
mirror of https://https.git.savannah.gnu.org/git/guix.git/ synced 2025-07-13 10:30:43 +02:00
guix/gnu/packages/patches/pounce-readable-checks.patch
Maxim Cournoyer 57768a7566
gnu: pounce: Add patch improving diagnostics.
* gnu/packages/patches/pounce-readable-checks.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/messaging.scm (pounce): Use it.

Change-Id: Ibfe10d4a6c99f86a0c925ad1bed2bcc14fb4c95c
2025-04-14 10:34:51 +09:00

48 lines
1.2 KiB
Diff

Print a warning when a configuration file cannot not be opened due to read
access.
Upstream-status: Forwarded to the author of Pounce via email.
diff --git a/local.c b/local.c
index fcd670a..d4603c4 100644
--- a/local.c
+++ b/local.c
@@ -43,6 +43,15 @@
static struct tls *server;
+void checkReadable(const char* file) {
+ FILE* f = fopen(file, "r");
+ if (f == NULL) {
+ if (errno == EACCES) warnx("failed to read file '%s'", file);
+ } else {
+ fclose(f);
+ }
+}
+
int localConfig(
const char *cert, const char *priv, const char *ca, bool require
) {
@@ -55,12 +64,14 @@ int localConfig(
int error;
char buf[PATH_MAX];
for (int i = 0; configPath(buf, sizeof(buf), cert, i); ++i) {
+ checkReadable(buf);
error = tls_config_set_cert_file(config, buf);
if (!error) break;
}
if (error) goto fail;
for (int i = 0; configPath(buf, sizeof(buf), priv, i); ++i) {
+ checkReadable(buf);
error = tls_config_set_key_file(config, buf);
if (!error) break;
}
@@ -68,6 +79,7 @@ int localConfig(
if (ca) {
for (int i = 0; configPath(buf, sizeof(buf), ca, i); ++i) {
+ checkReadable(buf);
error = tls_config_set_ca_file(config, buf);
if (!error) break;
}