Closed rickeyski closed 1 year ago
Additionally, I wrote a C
program to test getgrent
directly and it succeeds, providing the same output on rhel 7 as rhel 8.
#include <stdio.h>
#include <grp.h>
int main(int argc, char** argv){
struct group *tmpGrp;
while((tmpGrp = getgrent()) != NULL) {
printf("group : %s\n", tmpGrp->gr_name);
}
printf("\n");
return 0;
}
Tried on rocky8 (docker container), which should be similar to rhel8.
I could not reproduce with cabal and the following GHCs:
These are the fedora27 bindists.
I also tried with ghc-9.4.6-x86_64-centos7-linux.tar.xz just in case. It still succeeds. I don't have a proper rhel8 machine, but rocky8 should be binary compatible/equivalent.
@juhp
So far the only difference I have found between the rocky linux version and rhel8 is the build number of glibc
glibc-2.28-164.el8.x86_64 -- rhel8
glibc-2.28-225.el8.x86_64 -- rocky 8
(Sorry but next time please remove unnecessary deps like pretty-simple from your reproducer - it is not needed right?) (Would be nice if the reproducer used the current user too:-)
I don't have a fresh rhel8 release vm right now. I tried on a current Centos Stream 8 container (with stack):
$ podman run -it --rm quay.io/centos/centos:stream8
:
[root@9648a641a1ab test-unix]# stack install
[root@9648a641a1ab test-unix]# ~/.local/bin/test-unix-exe
[]
[root@9648a641a1ab test-unix]# rpm -q glibc
glibc-2.28-236.el8.x86_64
[root@9648a641a1ab test-unix]# ./a.out | wc -l
36
Can you reproduce with cabal and ghcup?
Actually not seeing any errors at all, so I can't reproduce
I guess runghc test.sh
would be sufficient with
-- test.hs
import System.Posix.Types
import System.Posix.User
main = do
user <- getLoginName
getAllGroupEntries >>= print . userGIDList user
where
userGIDList :: String -> [GroupEntry] -> [GroupID]
userGIDList user groups = map groupID $ filter (elem user . groupMembers) groups
Wondering if something wrong with your system, @rickeyski
It sounds like getAllGroupEntries
is erroring for you.
If so all you need to do to reproduce is
$ ghci
> import System.Posix.User
> getAllGroupEntries
Or even simpler than the runghc above:
$ ghci
> import System.Posix.User
> import Control.Monad
> printMembers g = let mems = groupMembers g in unless (null mems) $ putStrLn $ groupName g ++ ": " ++ unwords mems
> getAllGroupEntries >>= mapM_ printMembers
wheel: user1
kvm: qemu
tss: clevis
Anyway to conclude: I can neither reproduce your error in a Centos Stream 8 container nor a RHEL8 VM. Since noone else is reporting this (AFAIK?) it seems unlikely to be a general problem.
Interesting. Thanks for the quick response. I will dig further into my system since it seems to be that build on ec2. To be clear, the simple reproducer was correct.
$ ghci
> import System.Posix.User
>g <- getAllGroupEntries
*** Exception: getAllGroupEntries: invalid argument (Invalid argument)
Next time I will trim more away. Thanks again for your help.
You don't need to close though, it could well be a genuine issue with AWS likely then.
Could you also try with the ghc in EPEL 8?
The definition is here I think.
You could also try (this is only in 9.6)
(But you could try unix-2.8 to compare perhaps if it builds with older ghc.)System.Posix.User.ByteString.getAllGroupEntries
perhaps just to compare.
Could you also try with the ghc in EPEL 8?
What do you mean? The system ghc?
Yes exactly (from Fedora EPEL) it is much older though: ghc 8.2.
Same issue with epel install packages
$ ghci
GHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help
Prelude> import System.Posix.User
Prelude System.Posix.User> g <- getAllGroupEntries
*** Exception: getAllGroupEntries: invalid argument (Invalid argument)
You could also try ghc-9.6.2 and/or latest unix-2.8.1.1, although probably unlikely it helps, but nevertheless a good idea before reporting this to upstream ghc at least.
I commented https://github.com/rickeyski/test-unix/issues/1#issuecomment-1699305176
(Also curious what the actual problem is you are trying to solve with this (maybe there is a workaround/alternative?), but we should get to the bottom of this issue and understand it properly.)
Also you could try with RHEL 9 for good measure if you wish. Just trying to understanding the affected system space until we can dig deeper in the core issue.
Tried with RHEL 9.2 glibc-2.34-60 ghc 9.4, 9.2, and 8.10 all succeeded as expected...
I am working on a app that uses the group lookup as part of a saml auth flow. We just started moving from RHEL 7 to RHEL 8 and discovered this issue. I am thinking of pivoting to just creating a static build linked against musl to avoid this problem.
Not sure why I didn't think to try this earlier, but the host had a pending glibc update. Updating to glibc-2.28-225.el8.x86_64
has fixed the issue. I need to dive into what happened with 2.28-164
.
Okay that is indeed surprising, thanks for testing. I guess we can close this unless you still see an issue. ((also just my 2c but at this point I feel it is worth considering using RHEL 9 instead but anyway - also EPEL 9 has all recent ghc versions in ghcX.Y btw))
Sounds good. I wish we could go right to RHEL9 given how much of a mess it has been to move to RHEL8, but that is above my paygrade. Thanks again for your help.
Thanks for your attention. Please let me know if I can provide any further information.
Rickey
Your environment
Which OS do you use:
Describe your project (alternative: link to the project): I made a reproducing sample project here It fails with both stackage snapshots in the project lts-20.24 and lts-21.9
Steps to reproduce
Run the reproducer project
Expected behaviour
List all groupIds for user On Rhel 7.9, Amzn Linux 2, and Ubuntu 22.04 it works correctly
Actual behaviour
(unix-test-exe: getAllGroupEntries: invalid argument (Invalid argument))
Include debug information