1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/usr/bin/env perl
use strict;
use warnings;
# run as pwsafe --exportdb | pwsafe2pass
# requires an already initialized pass database
# headers
readline;
readline;
while (my $line = <>) {
chomp $line;
my ($uuid, $group, $name, $login, $passwd, $notes) = map {
s/^"(.*)"$/$1/;
# sigh
s/\\\\/\\/g;
s/>/>/g; # not a typo, they really forgot the ;
s/</</g;
s/&/\&/g;
$_
} split /\t/, $line;
# XXX pass doesn't handle filenames with spaces properly
s/\s/-/g for $group, $name;
die "pass can't handle files with spaces" if $login =~ /\s/;
my $entry = join '/', $group, $name, length($login) ? ($login) : ();
open my $fh, '|-', 'pass', 'insert', ($notes ? ('-m') : ('-e')), $entry
or die "Couldn't insert!";
$fh->print("$passwd\n");
$fh->print("$notes\n") if $notes;
$fh->close;
# XXX pass doesn't propagate git failure exit codes to the overall process,
# so failures in 'git add' or whatever will fail silently
die "Failed to insert $entry: $?" if $?;
}
|