From d45a3d4812598fc056499fa4622be4af58076bd5 Mon Sep 17 00:00:00 2001 From: "Andrew G. Morgan" Date: Mon, 23 Dec 2019 22:25:46 -0800 Subject: Ensure that gcc -std=c89 build works. We're not using it, but it seems like a small price to pay for having targets I'm not building regularly continue to build. Signed-off-by: Andrew G. Morgan --- pam_cap/pam_cap.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'pam_cap/pam_cap.c') diff --git a/pam_cap/pam_cap.c b/pam_cap/pam_cap.c index 58ffe4a..d4c1e65 100644 --- a/pam_cap/pam_cap.c +++ b/pam_cap/pam_cap.c @@ -7,6 +7,8 @@ /* #define DEBUG */ +#define _DEFAULT_SOURCE + #include #include #include @@ -18,6 +20,7 @@ #include #include #include +#include #include #include @@ -55,8 +58,8 @@ static int load_groups(const char *user, char ***groups, int *groups_n) { } *groups = calloc(ngrps, sizeof(char *)); - int g_n = 0; - for (int i = 0; i < ngrps; i++) { + int g_n = 0, i; + for (i = 0; i < ngrps; i++) { const struct group *g = getgrgid(grps[i]); if (g == NULL) { continue; @@ -128,7 +131,8 @@ static char *read_capabilities_for_user(const char *user, const char *source) D(("user [%s] is not [%s] - skipping", user, line)); } - for (int i=0; i < groups_n; i++) { + int i; + for (i=0; i < groups_n; i++) { if (!strcmp(groups[i], line+1)) { D(("user group matched [%s]", line)); found_one = 1; @@ -154,7 +158,8 @@ static char *read_capabilities_for_user(const char *user, const char *source) defer: memset(buffer, 0, CAP_FILE_BUFFER_SIZE); - for (int i = 0; i < groups_n; i++) { + int i; + for (i = 0; i < groups_n; i++) { char *g = groups[i]; _pam_overwrite(g); _pam_drop(g); @@ -221,7 +226,7 @@ static int set_capabilities(struct pam_cap_s *cs) goto cleanup_caps; } if (cap_reset_ambient() == 0) { - // Ambient set fully declared by this config. + /* Ambient set fully declared by this config. */ has_ambient = 1; } @@ -241,7 +246,7 @@ static int set_capabilities(struct pam_cap_s *cs) if (has_bound) { bound = calloc(max_caps, sizeof(int)); if (has_ambient) { - // In kernel lineage, bound came first. + /* In kernel lineage, bound came first. */ ambient = calloc(max_caps, sizeof(int)); } } @@ -316,7 +321,8 @@ static int set_capabilities(struct pam_cap_s *cs) if (cap_set_proc(cap_s)) { D(("failed to set specified capabilities: %s", strerror(errno))); } else { - for (cap_value_t c = 0; c < max_caps; c++) { + cap_value_t c; + for (c = 0; c < max_caps; c++) { if (ambient != NULL && ambient[c]) { cap_set_ambient(c, CAP_SET); } -- cgit v1.2.3