From 92574b8bfd91381169b75fe49a09024662cd10f2 Mon Sep 17 00:00:00 2001 From: Nicolas R Date: Tue, 8 Oct 2019 12:08:21 -0600 Subject: [PATCH 1/2] Add a unit test to check if we can change EFFECTIVE_GROUP_ID --- MANIFEST | 1 + t/op/groups-setegid.t | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 t/op/groups-setegid.t diff --git a/MANIFEST b/MANIFEST index 7bf62d847985..5d3a19c4968e 100644 --- a/MANIFEST +++ b/MANIFEST @@ -5765,6 +5765,7 @@ t/op/goto_xs.t See if "goto &sub" works on XSUBs t/op/grent.t See if getgr*() functions work t/op/grep.t See if grep() and map() work t/op/groups.t See if $( works +t/op/groups-setegid.t See if $( works t/op/gv.t See if typeglobs work t/op/hash.t See if the complexity attackers are repelled t/op/hash-rt85026.t See if hash iteration/deletion works diff --git a/t/op/groups-setegid.t b/t/op/groups-setegid.t new file mode 100644 index 000000000000..5bafcd79d5a8 --- /dev/null +++ b/t/op/groups-setegid.t @@ -0,0 +1,41 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + require './test.pl'; + set_up_inc( '../lib' ); + skip_all_if_miniperl("no dynamic loading on miniperl, no POSIX"); +} + +use 5.010; +use strict; +use Config (); +use POSIX (); + +skip_all('getgrgid() not implemented') + unless eval { my($foo) = getgrgid(0); 1 }; + +skip_all("No 'id' or 'groups'") if + $^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'VMS' || $^O =~ /lynxos/i; + +skip_all('need to be root') if $> != 0; + +Test(); +exit; + + + +sub Test { + + plan 2; + + $) = "123"; + is $), "123", "can change egid to '123'"; + + $) = "123 123"; + is $), "123 123", "can change egid to '123 123'"; + + return; +} + +# ex: set ts=8 sts=4 sw=4 et: From 15dbe1afb2073e311b185cf095649621e6a4bfbf Mon Sep 17 00:00:00 2001 From: Nicolas R Date: Tue, 8 Oct 2019 12:26:14 -0600 Subject: [PATCH 2/2] Fix setting EFFECTIVE_GROUP_ID to a list RT 134486 This is a regression introduced in 5.29.0 by 5d4a52b5 grok_atoUV: allow non-C strings and document Making sure we backup the end pointer and restore it before calling multiple times grok_atoUV should fix it. URL: https://rt.perl.org/Ticket/Display.html?id=134486 --- mg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mg.c b/mg.c index f235f0ee5a55..d04e08ef0759 100644 --- a/mg.c +++ b/mg.c @@ -3180,6 +3180,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) Groups_t *gary = NULL; const char* p_end = p + len; const char* endptr = p_end; + const char* backup_endptr = endptr; UV uv; #ifdef _SC_NGROUPS_MAX int maxgrp = sysconf(_SC_NGROUPS_MAX); @@ -3211,6 +3212,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) Newx(gary, i + 1, Groups_t); else Renew(gary, i + 1, Groups_t); + endptr = backup_endptr; /* we know where the end is */ if (grok_atoUV(p, &uv, &endptr)) gary[i] = (Groups_t)uv; else {