PERL script bug - need HELP please! 
Author Message
 PERL script bug - need HELP please!

Hello,

I've found a bug in the perl script for Majordomo.  I've tried the
majordomo-users mailing list with no luck.  I've identified the portion of
code that causes the bug (see below).

Here's what it's supposed to do:

When a subscriber sends the command to UNSUBSCRIBE from the mailing list, the
script checks that that subscriber is on the list, if so it creates a
temporary list file, removes that one entry in that temporary file, then
regenerates the original list file from the temporary (with that entry
removed).

Unfortunately, here's what's happening:  The UNSUBSCRIBE goes okay until the
system tries to remove the ONE entry from the temporary file.  Instead, it
removes ALL entries leaving a filesize of 0 bytes, then generates the working
file from the temporary - leaving NOBODY SUBSCRIBED...!

Here's the suspect code.  Any suggestions would be appreciated...

# Check to see if this request is approved, or if the subscriber is
# the person making the request...
if ($approved
        || ($config_opts{$clean_list,"subscribe_policy"} eq "auto" )
        || &addr_match($reply_to, $subscriber,
                (&cf_ck_bool($clean_list, "mungedomain") ? 2 : undef))) {
# either the request is approved or the subscriber is the requestor
# so drop them from the list
        &lopen(LIST, "", "$listdir/$clen_list") ||
                &abort("Can't open $listdir/$clean_list: $!");
        open(NEW, ">$listdir/$clean_list.new") ||
                &abort("Can't open $listdir/$clean_list.new: $!");
        chmod(0664, "$listdir/$clean_list.new") ||
                &abort("chmod(0664, \"$listdir/$clean_list.new\"): $!);
        while (<LIST>) {
                if (! &addr_match($subscriber, $_,
                        (&cf_ck_bool($clean_list, "mungedomain") ? 2 : undef))) {
                        print NEW $_;
                } else {
                        $match_count++;
                        if ($match_count ~= 1) {
        &squawk("unsubscribe: '$subscriber' matches multiple list members.");
                        last;
                }
        }

Quote:
}

close(NEW);

-------------------------------------------
Yea I know, there's a lot of functions and variables, here's a synopsis:

$config_opts{}  =       Array holding options from the configuration file
&addr_match =       Function to compare address with those in the list file
$listdir                =       Macro/variable with the directory of the listfile
$clean_list     =       Macro/variable with the filename of the listfile
$clean_list.new =       Marco/variable with the filename of temporary file
NEW             =       file-handle of the temporary file (from open())
$_              =       *** I haven't a clue on this one! ***

Any help would be appreciated.

Thanks in advance..

Leland

---------------------------
http://www.*-*-*.com/
http://www.*-*-*.com/ ~lelandv/
---------------------------



Sun, 23 Nov 1997 03:00:00 GMT  
 PERL script bug - need HELP please!
[ posted and mailed ]

Quote:
>I've found a bug in the perl script for Majordomo.  I've tried the
>majordomo-users mailing list with no luck.  I've identified the portion of
>code that causes the bug (see below).
>Here's what it's supposed to do:
>When a subscriber sends the command to UNSUBSCRIBE from the mailing list, the
>script checks that that subscriber is on the list, if so it creates a
>temporary list file, removes that one entry in that temporary file, then
>regenerates the original list file from the temporary (with that entry
>removed).
>Unfortunately, here's what's happening:  The UNSUBSCRIBE goes okay until the
>system tries to remove the ONE entry from the temporary file.  Instead, it
>removes ALL entries leaving a filesize of 0 bytes, then generates the working
>file from the temporary - leaving NOBODY SUBSCRIBED...!
>Here's the suspect code.  Any suggestions would be appreciated...

[ most of code deleted ]

Quote:
>close(NEW);

Try checking the return status of the close, e.g.:

    close(NEW) || &abort("close $listdir/$clean_list: $!");

--
 Dave Wolfe    *Not a spokesman for Motorola*  (512) 891-3246
 Motorola MMTG  6501 Wm. Cannon Dr. W. OE112  Austin  TX  78735-8598



Wed, 26 Nov 1997 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Need Perl Script/regexp/grep help, please...

2. Need Some Perl Script Help Please...

3. HELP: bug reporting script needed

4. Need a Simple but Unique CGI script - please help

5. Need help with the script, please

6. Please help I need a script

7. I need a script writen, can someone help me please

8. Script error need help please....

9. Please help with a script, knoledge needed!

10. Please - need help with for loop on hostname script

11. password script help needed please

12. Need simple perl script, Please.

 

 
Powered by phpBB® Forum Software