macOS getgrent returns no groups while getgrgid works

Offen
#2,009 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
47/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
java, perl

Rechercherichtung

Start by reading ExtendedNativeUtils.getgrent, FFMPosixLinux.getgrent, and FFMPosixMacOS to trace the native call and how a null result becomes an empty list. Then compare the macOS FFM binding and enumeration setup with the host libc behavior; the issue says the failure occurs on both execution backends. Done means successive getgrent calls return group records after setgrent, with regression coverage for list context and File::Finder's nogroup predicates.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

area:platform area:runtime bug

Summary

On macOS, PerlOnJava's getgrent returns no group entries, even though getgrgid can look up a group by GID. This breaks Perl code that enumerates the group database. It causes the released CPAN distribution File-Finder 1.01 to misclassify every path for its nogroup and not nogroup predicates.

Reproduction

The following probe was run with both the JVM backend and --interpreter:

my $gid = (stat ".")[5];
my @by_gid = getgrgid($gid);
print "gid=$gid getgrgid=", scalar(@by_gid), " ", join("|", @by_gid), "\n";

setgrent();
my @entry = getgrent();
print "getgrent=", scalar(@entry), " ", join("|", @entry), "\n";

PerlOnJava reports a valid getgrgid record, then getgrent=0. Repeated getgrent calls also return no entries. System Perl on the same macOS host returns group entries from getgrent (and a valid record from getgrgid).

CPAN evidence

In CPAN random tester run 20261109-091152-39587, File-Finder-1.01 failed 2 of 87 tests, both in t/05-steps.t:

  • nogroup: PerlOnJava included . although the system-Perl expected result was empty.
  • not nogroup: PerlOnJava returned an empty result although system Perl included ..

System Perl passed all 87 tests. The other File-Finder tests passed or were skipped for optional dependencies. This is a pure-Perl distribution; no XS/native distribution prioritization applies.

The affected code in File-Finder builds a GID-to-group map by iterating getgrent. Because PerlOnJava returns no entries, _gid_to_group cannot resolve the directory's GID; nogroup then treats it as unknown. The same failure was observed with both PerlOnJava backends.

Suspected implementation path

ExtendedNativeUtils.getgrent calls FFMPosix.get().getgrent() and converts a null native result into an empty Perl list. The FFM implementation in FFMPosixLinux.getgrent invokes the native getgrent handle and returns null when the pointer is null. On macOS, FFMPosixMacOS inherits this implementation. In contrast, the native getgrgid path succeeds for the current GID.

This localizes the failure to native group enumeration, shared by the two execution backends. The precise reason the native getgrent call returns null still needs investigation; likely follow-up is to validate the macOS FFM binding and enumeration setup against the platform libc behavior.

Expected behavior

After setgrent, successive getgrent calls should enumerate the same available group records as system Perl on the host. The regression should cover list-context results and the File::Finder nogroup/not nogroup behavior on both execution backends.

Vorherrschende Sprache
Perl
Sterne
67
Forks
8
Ø Merge
5 Std. 12 Min.
Gemergte PRs (30 T.)
131

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus fglock/PerlOnJava

Alle Issues in fglock/PerlOnJava

Ähnliche Issues

Weitere Issues zu Perl

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.