1 |
#!/usr/bin/perl |
2 |
# MPD |
3 |
# |
4 |
# Douglas Thrift |
5 |
# |
6 |
# $Id$ |
7 |
|
8 |
use strict; |
9 |
use warnings; |
10 |
|
11 |
use File::Basename; |
12 |
use IO::Prompt; |
13 |
|
14 |
if ($#ARGV != 1) |
15 |
{ |
16 |
print 'Usage: ' . basename($0) . " [input] [output]\n"; |
17 |
|
18 |
exit 1; |
19 |
} |
20 |
|
21 |
my $input = shift; |
22 |
my $output = shift; |
23 |
|
24 |
umask 0077; |
25 |
|
26 |
open INPUT, "<$input" or die basename($0) . ": $!\n"; |
27 |
open OUTPUT, ">$output" or die basename($0) . ": $!\n"; |
28 |
|
29 |
while (<INPUT>) |
30 |
{ |
31 |
if (/^\tset user (\w+) password(?: (?:admin|operator|user))?$/) |
32 |
{ |
33 |
my $user = $1; |
34 |
my $password = prompt("$user\'s password: ", -e => '*'); |
35 |
|
36 |
s/$user password/$user $password/; |
37 |
} |
38 |
|
39 |
print OUTPUT; |
40 |
} |
41 |
|
42 |
close INPUT; |
43 |
close OUTPUT; |