Files
telephony/net/asterisk/patches/180-res_crypto.c-Avoid-using-the-non-portable-ALLPERMS-m.patch
Sebastian Kemper 945b7ea1f0 asterisk: bump to 20.3.0
- bump to 20.3.0
- new modules: app-broadcast, app-if, app-signal, func-export,
  res-pjsip-aoc and res-pjsip-rfc3329
- remove "--without-vpb", not available anymore
- add configuration file for res-http-media-cache
- drop libsrtp2 from res-pjproject dependencies, see changes in
  pjproject package
- refresh patches
- add upstream patch
  180-res_crypto.c-Avoid-using-the-non-portable-ALLPERMS-m.patch to fix
  build [1]

[1] https://github.com/asterisk/asterisk/issues/149

Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
2023-06-07 23:56:27 +02:00

34 lines
1.2 KiB
Diff

From 94c884d5b8afca96164852cfb29fc496bc5b9e0a Mon Sep 17 00:00:00 2001
From: Sean Bright <sean@seanbright.com>
Date: Mon, 5 Jun 2023 18:17:47 -0400
Subject: [PATCH] res_crypto.c: Avoid using the non-portable ALLPERMS macro.
ALLPERMS is not POSIX and it's trivial enough to not jump through
autoconf hoops to check for it.
Fixes #149.
---
res/res_crypto.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
--- a/res/res_crypto.c
+++ b/res/res_crypto.c
@@ -217,10 +217,15 @@ static struct ast_key *try_load_key(cons
return NULL;
}
+ /* PERM_MASK is a bitwise OR of all possible file mode bits encoded in the
+ * `st_mode` member of `struct stat`. For POSIX compatible systems this
+ * will be 07777. */
+#define PERM_MASK (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
+
/* only user read or read/write modes allowed */
if (ktype == AST_KEY_PRIVATE &&
- ((st.st_mode & ALLPERMS) & ~(S_IRUSR | S_IWUSR)) != 0) {
- ast_log(LOG_ERROR, "Private key file has bad permissions: %s: %#4o\n", ffname, st.st_mode & ALLPERMS);
+ ((st.st_mode & PERM_MASK) & ~(S_IRUSR | S_IWUSR)) != 0) {
+ ast_log(LOG_ERROR, "Private key file has bad permissions: %s: %#4o\n", ffname, st.st_mode & PERM_MASK);
fclose(f);
return NULL;
}