He says that what it eventually does is obliterate the file and replace it with the text#!/usr/local/bin/perl use strict; use warnings; use Fcntl qw(:DEFAULT :flock); # sysopen(PASSWD, "./passwd", O_RDWR) open (PASSWD, "+>>./passwd") or die "can't open passwd file ($!)"; flock(PASSWD, LOCK_EX); # or die "can't get lock on passwd file ($!)"; my @temp; foreach my $readLine (PASSWD) { chomp $readline; my ( $name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell ) = split /:/, $readLine; if ($name eq "www") { $shell =~ s[/bin/bash][/dev/null]; } my $line = join ':', ($name,$passwd,$uid,$gid,$quota,$comment,$gcos, +$dir,$shell); push @temp, $line; } truncate (PASSWD, 0); foreach my $user (@temp) { print PASSWD "$user\n"; } close (PASSWD);
This strikes me as rather bizarre. Now, this is on linux on x86, and perl 5.5. I suggested he use File::Slurp (/me bows down and worships File::Slurp). However, this script needs to be deployed to > 4000 machines, and installing modules is simply not an option (I have entertained the possibility of just taking the code from the module and putting it in the script, that seems reasonable).PASSWD::::::::
I'm concerned because I can't think of any reason why it would be doing this. Any ideas, Monks?
el dep mas fina
--
Laziness, Impatience, Hubris, and Generosity.
In reply to Questions with sysopen (code) by deprecated
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |