Bug 102665

Summary: perl loops in shellwords.pl with input read from stdin
Product: Red Hat Enterprise Linux 3 Reporter: Daniel Jarboe <backwardthinker>
Component: perlAssignee: Jason Vas Dias <jvdias>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: perl-5.8.0-90.2 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-11-11 23:47:40 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 101028    
Attachments:
Description Flags
strace for wbinfo_group.pl ... killed after a few seconds of looping none

Description Daniel Jarboe 2003-08-19 17:32:19 UTC
Description of problem:
wbinfo_group.pl provided by squid-2.5.STABLE3-2.3E enters a loop in perl with 
doubling mmaps.  Loop is initiated by shellwords 
(/usr/lib/perl5/5.8.0/shellwords.pl) when using STDIN.

For example:

#!/usr/bin/perl -w
require 'shellwords.pl';
($user, $group) = &shellwords(<STDIN>);
print "'$user' and '$group'\n";

is enough to cause the loop.  Not sure if this is important, but a $line = 
<STDIN> and &shellwords($line) loops similarly, but specifying $line = "blah 
blah\n" and then doing the shellwords works fine (no loop).


Version-Release number of selected component (if applicable):
perl-5.8.0-88.1

How reproducible:
Always

Steps to Reproduce:
1. Use shellwords.pl with args from STDIN
    

Actual Results:  Loops, with memory size growing.

Expected Results:  Returned with a value.

Additional info:

May be for non-s390 platforms too, don't have one handy to try.  
wbinfo_group.pl is a standard winbindd group external acl for squid, which 
doesn't work because of this bug.

Comment 1 Daniel Jarboe 2003-08-19 17:34:17 UTC
Created attachment 93754 [details]
strace for wbinfo_group.pl ... killed after a few seconds of looping

Comment 3 Neil Martin 2004-03-16 11:05:25 UTC
I get the same issue, is there any update on this one.  Thanks

Comment 4 Holger Schmieder 2004-04-08 18:15:12 UTC
Hallo all,
with the new winbind Version 3.0.2a there ar another problem: winbind 
returns togehter with the groupSID the Domain Group number.
So i changed two things in the script to become it working.
Because i am not verry family with perl the systaxes are not pretty 
good but the script works for my solution.
Hope that helps you to.
Btw: In my opinion there is a problem with perl to read special 
characters from STDIN !?

Regards
Holger Schmieder


#!/usr/bin/perl -w
# external_acl helper to Squid to verify NT Domain group
# membership using wbinfo
# This program is put in the public domain by Jerry Murdock
# <jmurdock>. It is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied 
warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Author:
#   Jerry Murdock <jmurdock>
#
# changed by Holger Schmieder <schmieder> 04/2004
#
# Version history:
#   2002-07-05 Jerry Murdock <jmurdock>
#               Initial release
#

# external_acl uses shell style lines in it's protocol
require 'shellwords.pl';

# Disable output buffering
$|=1;

sub debug {
        # Uncomment this to enable debugging
        #print STDERR "@_\n";
}

#
# Check if a user belongs to a group
#
sub check {
        local($user, $group) = @_;
        $groupSID = `wbinfo -n "$group"` . " ";
        #because the new wbinfo -n returns also the group number
        #we do the following
        $groupSID = substr($groupSID,0,index($groupSID," ",0));
        $groupGID = `wbinfo -Y $groupSID`;
        chop $groupGID;
        &debug( "User:  -$user-\nGroup: -$group-\nSID:   -$groupSID-
\nGID:   -$groupGID-");
        return 'OK' if(`wbinfo -r \Q$user\E` =~ /^$groupGID$/m);
        return 'ERR';
}

#
# Main loop
#
while (<STDIN>) {
        chop;
        &debug ("Got $_ from squid");
        #H1 was added by holger
        @H1=split(/\s+/, $_);
        #printf ("User:%s\n",$H1[0]);
        #printf ("Group:%s\n",$H1[1]);
        $user = $H1[0];
        $group = $H1[1];
#        ($user, $group) = &shellwords;
        $ans = &check($user, $group);
        &debug ("Sending $ans to squid");
        print "$ans\n";
}


Comment 5 Josh Burley 2004-10-04 21:48:25 UTC
I have a similar problem with shellwords.pl on a Redhat ES3 server.
The while() loop in shellwords.pl loops infinitely when a single line
is passed in.

This is with the Nagiostat package for Nagios. This same package
worked great on an AIX box... but upon migrating to this Redhat ES3
server, because entirely unusable.

Comment 6 Jason Vas Dias 2005-11-11 23:47:40 UTC
Very sorry for the long delay in processing this bug report.
This is not a problem with the current release of perl in RHEL-3.