Andrew Geissler | 706d5aa | 2021-02-12 15:55:30 -0600 | [diff] [blame^] | 1 | From 28c760542eecd7c5b35ea88aa2b14d62afbda961 Mon Sep 17 00:00:00 2001 |
| 2 | From: Peter Kjellerstedt <pkj@axis.com> |
| 3 | Date: Sat, 21 Nov 2020 17:22:38 +0100 |
| 4 | Subject: [PATCH] pseudo_client: Lessen indentation of |
| 5 | pseudo_client_ignore_path_chroot() |
| 6 | |
| 7 | Change-Id: I739b18efb7a95ce2d2d907d0faf7df539ab9af1c |
| 8 | --- |
| 9 | pseudo_client.c | 45 +++++++++++++++++++++++++-------------------- |
| 10 | 1 file changed, 25 insertions(+), 20 deletions(-) |
| 11 | |
| 12 | diff --git a/pseudo_client.c b/pseudo_client.c |
| 13 | index 116d926..a8bc3dc 100644 |
| 14 | --- a/pseudo_client.c |
| 15 | +++ b/pseudo_client.c |
| 16 | @@ -1527,28 +1527,33 @@ int pseudo_client_ignore_fd(int fd) { |
| 17 | |
| 18 | int pseudo_client_ignore_path_chroot(const char *path, int ignore_chroot) { |
| 19 | char *env; |
| 20 | - if (path) { |
| 21 | - if (ignore_chroot && pseudo_chroot && strncmp(path, pseudo_chroot, pseudo_chroot_len) == 0) |
| 22 | - return 0; |
| 23 | - env = pseudo_get_value("PSEUDO_IGNORE_PATHS"); |
| 24 | - if (env) { |
| 25 | - char *p = env; |
| 26 | - while (*p) { |
| 27 | - char *next = strchr(p, ','); |
| 28 | - if (!next) |
| 29 | - next = strchr(p, '\0'); |
| 30 | - if ((next - p) && !strncmp(path, p, next - p)) { |
| 31 | - pseudo_debug(PDBGF_PATH | PDBGF_VERBOSE, "ignoring path: '%s'\n", path); |
| 32 | - return 1; |
| 33 | - } |
| 34 | - if (next && *next != '\0') |
| 35 | - p = next+1; |
| 36 | - else |
| 37 | - break; |
| 38 | - } |
| 39 | - free(env); |
| 40 | + |
| 41 | + if (!path) |
| 42 | + return 0; |
| 43 | + |
| 44 | + if (ignore_chroot && pseudo_chroot && strncmp(path, pseudo_chroot, pseudo_chroot_len) == 0) |
| 45 | + return 0; |
| 46 | + |
| 47 | + env = pseudo_get_value("PSEUDO_IGNORE_PATHS"); |
| 48 | + if (!env) |
| 49 | + return 0; |
| 50 | + |
| 51 | + char *p = env; |
| 52 | + while (*p) { |
| 53 | + char *next = strchr(p, ','); |
| 54 | + if (!next) |
| 55 | + next = strchr(p, '\0'); |
| 56 | + if ((next - p) && !strncmp(path, p, next - p)) { |
| 57 | + pseudo_debug(PDBGF_PATH | PDBGF_VERBOSE, "ignoring path: '%s'\n", path); |
| 58 | + return 1; |
| 59 | } |
| 60 | + if (next && *next != '\0') |
| 61 | + p = next+1; |
| 62 | + else |
| 63 | + break; |
| 64 | } |
| 65 | + free(env); |
| 66 | + |
| 67 | return 0; |
| 68 | } |
| 69 | |