Skip to content

Commit

Permalink
Fix opam unable to find executables on systems where users belong to …
Browse files Browse the repository at this point in the history
…more than 32 groups when opam is built using musl libc

Details of the issue in musl described in https://www.openwall.com/lists/musl/2021/07/03/1
  • Loading branch information
kit-ty-kate committed Dec 6, 2022
1 parent 23664f3 commit 8ef4544
Show file tree
Hide file tree
Showing 13 changed files with 5 additions and 266 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ src/client/no-git-version
src/core/developer
src/manifest/dune
src/manifest/install.inc
src/stubs/libacl/dune
src/stubs/libacl/c-libraries.sexp
src/stubs/win32/cc64
src/stubs/win32/dune
src/stubs/c-flags.sexp
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ clean:
distclean: clean clean-ext
rm -rf autom4te.cache bootstrap
rm -f Makefile.config config.log config.status aclocal.m4
rm -f src/*.META src/*/.merlin src/manifest/dune src/manifest/install.inc src/stubs/libacl/dune src/stubs/win32/dune src/stubs/win32/cc64 src/ocaml-flags-configure.sexp src/stubs/libacl/c-libraries.sexp
rm -f src/*.META src/*/.merlin src/manifest/dune src/manifest/install.inc src/stubs/win32/dune src/stubs/win32/cc64 src/ocaml-flags-configure.sexp
rm -f src/client/linking.sexp src/stubs/c-flags.sexp src/core/developer src/core/version

OPAMINSTALLER_FLAGS = --prefix "$(call CYGPATH,$(DESTDIR)$(prefix))"
Expand Down
28 changes: 0 additions & 28 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ AS_IF([test "x$with_0install_solver" = xno],
)


AC_ARG_WITH([libacl],
AC_HELP_STRING([--with-libacl],
[Compile opam with libacl support]),,[with_libacl=auto])

AC_ARG_WITH([private_runtime],
AC_HELP_STRING([--with-private-runtime],
[For a mingw-w64 build, manifest the runtime DLLs locally in Opam.Runtime.arch]),,[with_private_runtime=no]
Expand Down Expand Up @@ -164,23 +160,6 @@ AS_IF([test "x${enable_developer_mode}" = "xyes"],[

AS_IF([test "x${with_mccs}" = "xno"], [AC_SUBST(MCCS_ENABLED,false)], [AC_SUBST(MCCS_ENABLED,true)])

AS_IF([test "x${with_libacl}" != "xno"],[
have_libacl=yes
AC_CHECK_HEADER([acl/libacl.h],,[have_libacl=no])
AC_SEARCH_LIBS([acl_get_perm],[acl],,[have_libacl=no])
AS_IF([test "x${SYSTEM}" = "xcygwin"],[
AS_IF([test "x${have_libacl}" = "xno"],[AC_MSG_ERROR([opam on Cygwin requires libacl])],[with_libacl=yes])
])
AS_IF([test "x${with_libacl}${have_libacl}" = "xyesno"],[AC_MSG_ERROR([libacl not found])])
])
AS_IF([test "x${with_libacl}" = "xyes"],[
AS_IF([test "x${ac_cv_search_acl_get_perm}" = "xnone required"],[
AC_SUBST(CONF_LIBACL_LINK,[])
],[
AC_SUBST(CONF_LIBACL_LINK,[${ac_cv_search_acl_get_perm}])
])
])

CONF_OCAMLFLAGS=''

AS_IF([test "x${CI}" != "x" -o "x${enable_developer_mode}" = "xyes"],[
Expand Down Expand Up @@ -427,7 +406,6 @@ AC_CONFIG_FILES(
Makefile.config
src/ocaml-flags-configure.sexp
src/stubs/c-flags.sexp
src/stubs/libacl/c-libraries.sexp
)
AC_OUTPUT

Expand All @@ -449,12 +427,6 @@ AS_IF([ test ${WIN32} -eq 1],[
${LN_S} -f dune-win32 dune
cd ../../..
])
rm -f src/stubs/libacl/dune
AS_IF([ test "x${with_libacl}" = "xyes" ],[
cd src/stubs/libacl
${LN_S} -f dune-libacl dune
cd ../../..
])

echo

Expand Down
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -584,3 +584,4 @@ users)
* `OpamStd.Map`: add `filter_map` [#5337 @rjbou]
* `OpamStd.Set`: Add `to_list_map` [#5308 @kit-ty-kate]
* `OpamConsole.header_msg`: remove trailing space when there is no left padding [#5363 @rjbou]
* Fix opam unable to find executables on systems where users belong to more than 32 groups when opam is built using musl libc [#5381 @kit-ty-kate - fix #5373]
3 changes: 0 additions & 3 deletions src/core/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
(public_name opam-core)
(synopsis "OCaml Package Manager core internal stdlib")
(libraries re ocamlgraph unix bigarray sha jsonm
(select opamACL.ml from
(opam-core.libacl -> opamACL.libacl.ml)
( -> opamACL.dummy.ml))
(select opamStubs.ml from
(opam-core.stubs -> opamStubs.win32.ml)
( -> opamStubs.dummy.ml)))
Expand Down
11 changes: 0 additions & 11 deletions src/core/opamACL.dummy.ml

This file was deleted.

11 changes: 0 additions & 11 deletions src/core/opamACL.libacl.ml

This file was deleted.

22 changes: 0 additions & 22 deletions src/core/opamACL.mli

This file was deleted.

29 changes: 3 additions & 26 deletions src/core/opamSystem.ml
Original file line number Diff line number Diff line change
Expand Up @@ -388,32 +388,9 @@ let t_resolve_command =
let name = forward_to_back name in
OpamStd.String.contains_char name Filename.dir_sep.[0]
in
let check_perms =
if Sys.win32 then fun f ->
try (Unix.stat f).Unix.st_kind = Unix.S_REG
with e -> OpamStd.Exn.fatal e; false
else fun f ->
try
let open Unix in
let uid = geteuid () in
let groups = OpamStd.IntSet.of_list (getegid () :: Array.to_list (getgroups ())) in
let {st_uid; st_gid; st_perm; _} = stat f in
let mask =
if uid = st_uid then
0o100
else if OpamStd.IntSet.mem st_gid groups then
0o010
else
0o001
in
if (st_perm land mask) <> 0 then
true
else
match OpamACL.get_acl_executable_info f st_uid with
| None -> false
| Some [] -> true
| Some gids -> OpamStd.IntSet.(not (is_empty (inter (of_list gids) groups)))
with e -> OpamStd.Exn.fatal e; false
let check_perms f =
try Unix.access f [if Sys.win32 then Unix.R_OK else Unix.X_OK]; true
with Unix.Unix_error _ -> false
in
let resolve ?dir env name =
if not (Filename.is_relative name) then begin
Expand Down
1 change: 0 additions & 1 deletion src/stubs/libacl/c-libraries.sexp.in

This file was deleted.

22 changes: 0 additions & 22 deletions src/stubs/libacl/dune-libacl

This file was deleted.

128 changes: 0 additions & 128 deletions src/stubs/libacl/opamACL.c

This file was deleted.

11 changes: 0 additions & 11 deletions src/stubs/libacl/opamlibACL.ml

This file was deleted.

0 comments on commit 8ef4544

Please sign in to comment.