Bug 102665 - perl loops in shellwords.pl with input read from stdin
perl loops in shellwords.pl with input read from stdin
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: perl (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jason Vas Dias
Depends On:
Blocks: 101028
  Show dependency treegraph
Reported: 2003-08-19 13:32 EDT by Daniel Jarboe
Modified: 2007-11-30 17:06 EST (History)
0 users

See Also:
Fixed In Version: perl-5.8.0-90.2
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-11-11 18:47:40 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
strace for wbinfo_group.pl ... killed after a few seconds of looping (23.00 KB, text/plain)
2003-08-19 13:34 EDT, Daniel Jarboe
no flags Details

  None (edit)
Description Daniel Jarboe 2003-08-19 13:32:19 EDT
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):

How reproducible:

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 13:34:17 EDT
Created attachment 93754 [details]
strace for wbinfo_group.pl ... killed after a few seconds of looping
Comment 3 Neil Martin 2004-03-16 06:05:25 EST
I get the same issue, is there any update on this one.  Thanks
Comment 4 Holger Schmieder 2004-04-08 14:15:12 EDT
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 !?

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@itraktech.com>. It is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied 
# Author:
#   Jerry Murdock <jmurdock@itraktech.com>
# changed by Holger Schmieder <schmieder@schmieder.de> 04/2004
# Version history:
#   2002-07-05 Jerry Murdock <jmurdock@itraktech.com>
#               Initial release

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

# Disable output buffering

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>) {
        &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 17:48:25 EDT
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 18:47:40 EST
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.

Note You need to log in before you can comment on or make changes to this bug.