netblue30 / firejail

Linux namespaces and seccomp-bpf sandbox
https://firejail.wordpress.com
GNU General Public License v2.0
5.81k stars 567 forks source link

PATH_MAX is undeclared on musl libc #4578

Closed dm9pZCAq closed 3 years ago

dm9pZCAq commented 3 years ago

Description

build failed due to PATH_MAX missed on musl libc

Steps to Reproduce

build on musl libc (voidlinux, alpinelinux, kisslinux)

Environment

Log

main.c:1003:26: error: use of undeclared identifier 'PATH_MAX'
                if (strlen(argv[i]) >= MAX_ARG_LEN) {
                                       ^
./firejail.h:364:22: note: expanded from macro 'MAX_ARG_LEN'
#define MAX_ARG_LEN (PATH_MAX + 32) // --foobar=PATH
                     ^
main.c:1015:23: error: use of undeclared identifier 'PATH_MAX'
                if (strlen(*ptr) >= MAX_ENV_LEN) {
                                    ^
./firejail.h:658:22: note: expanded from macro 'MAX_ENV_LEN'
#define MAX_ENV_LEN (PATH_MAX + 32)     // FOOBAR=SOME_PATH
                     ^

How to fix

here is patch from voidlinux https://github.com/void-linux/void-packages/blob/master/srcpkgs/firejail/patches/musl.patch

with this patch everything builds fine for me

kmk3 commented 3 years ago

@dm9pZCAq commented on Sep 27:

Description

build failed due to PATH_MAX missed on musl libc

Steps to Reproduce

build on musl libc (voidlinux, alpinelinux, kisslinux)

Environment

  • Gentoo linux with musl profile
  • trying to build firejail-0.9.64.4

Log

main.c:1003:26: error: use of undeclared identifier 'PATH_MAX'
                if (strlen(argv[i]) >= MAX_ARG_LEN) {
                                       ^
./firejail.h:364:22: note: expanded from macro 'MAX_ARG_LEN'
#define MAX_ARG_LEN (PATH_MAX + 32) // --foobar=PATH
                     ^
main.c:1015:23: error: use of undeclared identifier 'PATH_MAX'
                if (strlen(*ptr) >= MAX_ENV_LEN) {
                                    ^
./firejail.h:658:22: note: expanded from macro 'MAX_ENV_LEN'
#define MAX_ENV_LEN (PATH_MAX + 32)     // FOOBAR=SOME_PATH
                     ^

Thanks for the report.

How to fix

here is patch from voidlinux https://github.com/void-linux/void-packages/blob/master/srcpkgs/firejail/patches/musl.patch

with this patch everything builds fine for me

The patch looks good to me; could you open a PR for it?

Cc: @Duncaen (who appears to be the patch author)