RSS

(root)/users/lolando/sgeps/trunk : /pwsafe2sgeps (revision 15)

To get this branch, use:
bzr branch /loggerhead/users/lolando/sgeps/trunk
Line Revision Contents
1 12.2.13
#! /usr/bin/perl
2
#
3
# Import a pwsafe database into a sgeps store.
4
#
5
# Copyright © 2010, Ben Voui <intrigeri@boum.org>
6
#
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2 of the License, or
10
# (at your option) any later version.
11
#
12
# Usage: pwsafe2sgeps FILE [FILE ...]
13
#
14
# The file(s) passed on the command line are plaintext pwsafe exports.
15
# Use "pwsafe --exportdb" to get one.
16
17
use strict;
18
use warnings;
19
20
my $version_string = <>;
21
chomp $version_string;
22
unless ($version_string =~ m/^\# passwordsafe version 2.0 database$/ms) {
23
    die "This pwsafe database export version is not supported:\n" .
24
        "    $version_string\n" .
25
        "Only version 2.0 is supported.\n";
26
}
27
28
while (<>) {
29
    chomp;
30
31
    # skip comment lines
32
    next if ($_ =~ m/^\#/xms);
33
34
    # skip header line
35
    next if ($_ =~ m/^ uuid \s+ group \s+ name \s+ login \s+ passwd \s+ notes $/xms);
36
37
    my ($uuid, $group, $name, $login, $passwd, $notes) =
38
        ($_ =~ m/^ "([-0-9a-z]+)"
39
                   \t "(.*)"
40
                   \t "(.*)"
41
                   \t "(.*)"
42
                   \t "(.*)"
43
                   \t "(.*)"
44
                 $/xms)
45
            or next;
46
47
    chomp ($uuid, $group, $name, $login, $passwd, $notes);
48
49
    my $key;
50
    if ($group ne '') {
51
        $key = "$group/$name";
52
    }
53
    else {
54
         $key = $name;
55
    }
56
57
    open SGEPS, ( '| sgeps --add --batch ' . quotemeta($key) )
58
        or die "Failed to open pipe to sgeps";
59
    print SGEPS "$login\n" or die "Failed to print login to pipe";
60
    print SGEPS "$passwd\n" or die "Failed to print password to pipe";
61
    print SGEPS "$notes\n" or die "Failed to print notes to pipe";
62
    close SGEPS or die "Failed to close pipe to sgeps";
63
}

Loggerhead 1.17 is a web-based interface for Bazaar branches