Skip to content

Commit b884d88

Browse files
committed
Fix compilation on Linux
Symptom with GCC 11: > gcc-11 -std=c99 -Wextra -pedantic -Wall -O2 -DUSE_PAM -DDOAS_CONF=\"/etc/doas.conf\" -D_GNU_SOURCE -include compat/compat.h -Icompat -c -o env.o env.c > env.c: In function ‘createenv’: > env.c:139:37: error: conflicting types for ‘environ’; have ‘const char **’ > 139 | extern const char **environ; > | ^~~~~~~ Symptom with Clang 17: > clang-17 -std=c99 -Wextra -pedantic -Wall -O2 -DUSE_PAM -DDOAS_CONF=\"/etc/doas.conf\" -D_GNU_SOURCE -include compat/compat.h -Icompat -c -o env.o env.c > env.c:139:23: error: redeclaration of 'environ' with a different type: 'const char **' vs 'char **' > extern const char **environ; > ^ Related: https://sourceforge.net/p/predef/wiki/OperatingSystems/#linux-kernel
1 parent d9f415c commit b884d88

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

doas.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ main(int argc, char **argv)
420420
pam_handle_t *pamh = NULL;
421421
int pam_err;
422422

423-
/* #ifndef linux */
423+
/* #ifndef __linux__ */
424424
int temp_stdin;
425425

426426
/* openpam_ttyconv checks if stdin is a terminal and
@@ -497,7 +497,7 @@ main(int argc, char **argv)
497497
}
498498
pam_end(pamh, pam_err);
499499

500-
#ifndef linux
500+
#ifndef __linux__
501501
/* Re-establish stdin */
502502
if (dup2(temp_stdin, STDIN_FILENO) == -1)
503503
err(1, "dup2");

env.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ createenv(struct rule *rule, struct passwd *original, struct passwd *target)
135135
addnode(env, "USER", target->pw_name);
136136

137137
if (rule->options & KEEPENV) {
138-
#ifndef linux
138+
#ifndef __linux__
139139
extern const char **environ;
140140
#endif
141141

0 commit comments

Comments
 (0)