]> git.proxmox.com Git - pve-common.git/commitdiff
add parser for "/etc/apt/auth.conf"
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 25 Jul 2013 07:58:14 +0000 (09:58 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 25 Jul 2013 07:58:14 +0000 (09:58 +0200)
bump version to 3.0-5

Makefile
data/PVE/INotify.pm
debian/changelog

index 2cff80519bf3df43fd1a110be885d771c7006811..4c7aaaf8cbf53709d49a090bb27d24e2c9098142 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 RELEASE=3.0
 
 VERSION=3.0
-PKGREL=4
+PKGREL=5
 
 PACKAGE=libpve-common-perl
 
index 850668a0d730bfc3e83a8413b76466cd0e6ced6c..f18a10bb9a3533555e0b1389e1bedf2f818a019c 100644 (file)
@@ -973,4 +973,74 @@ sub read_iscsi_initiatorname {
 register_file('initiatorname', "/etc/iscsi/initiatorname.iscsi",  
              \&read_iscsi_initiatorname);
 
+sub read_apt_auth {
+    my ($filename, $fd) = @_;
+
+    local $/;
+
+    my $raw = <$fd>;
+
+    $raw =~ s/^\s+//;
+
+    my @tokens = split(/\s+/, $raw);
+
+    my $data = {};
+
+    my $machine;
+    while (defined(my $tok = shift @tokens)) {
+
+       $machine = shift @tokens if $tok eq 'machine';
+       next if !$machine;
+       $data->{$machine} = {} if !$data->{$machine};
+
+       $data->{$machine}->{login} = shift @tokens if $tok eq 'login';
+       $data->{$machine}->{password} = shift @tokens if $tok eq 'password';
+    };
+
+    return $data;
+}
+
+my $format_apt_auth_data = sub {
+    my $data = shift;
+
+    my $raw = '';
+
+    foreach my $machine (sort keys %$data) {
+       my $d = $data->{$machine};
+       $raw .= "machine $machine\n";
+       $raw .= " login $d->{login}\n" if $d->{login};
+       $raw .= " password $d->{password}\n" if $d->{password};
+       $raw .= "\n";
+    }
+
+    return $raw;
+};
+
+sub write_apt_auth {
+    my ($filename, $fh, $data) = @_;
+
+    my $raw = &$format_apt_auth_data($data);
+
+    die "write failed: $!" unless print $fh "$raw\n";
+   
+    return $data;
+}
+
+sub update_apt_auth {
+    my ($filename, $fh, $data) = @_;
+
+    my $orig = read_apt_auth($filename, $fh);
+
+    foreach my $machine (keys %$data) {
+       $orig->{$machine} = $data->{$machine};
+    }
+
+    return &$format_apt_auth_data($orig);
+}
+
+register_file('apt-auth', "/etc/apt/auth.conf",  
+             \&read_apt_auth, \&write_apt_auth,
+             \&update_apt_auth);
+
 1;
index 4cbda1deb9aff90fc8ca7259e6e6e6ad83cb61f2..a728616f1b3d7a662b2b24b253251968abcd74dd 100644 (file)
@@ -1,3 +1,9 @@
+libpve-common-perl (3.0-5) unstable; urgency=low
+
+  * add parser for "/etc/apt/auth.conf"
+
+ -- Proxmox Support Team <support@proxmox.com>  Thu, 25 Jul 2013 09:57:55 +0200
+
 libpve-common-perl (3.0-4) unstable; urgency=low
 
   * fix bug #381: use persistent reservation file for ports