deprecated has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Questions with sysopen (code)
by Zaxo (Archbishop) on Sep 19, 2002 at 19:32 UTC | |
|
Re: Questions with sysopen (code)
by VSarkiss (Monsignor) on Sep 19, 2002 at 19:32 UTC | |
|
Re: Questions with sysopen (code)
by Thelonius (Priest) on Sep 19, 2002 at 19:35 UTC | |
by RMGir (Prior) on Sep 19, 2002 at 19:38 UTC | |
|
Re: Questions with sysopen (code)
by Aristotle (Chancellor) on Sep 19, 2002 at 20:34 UTC | |
|
Re: passwd + command line options
by fglock (Vicar) on Sep 19, 2002 at 19:53 UTC |