diff options
Diffstat (limited to 'perl-install/fs/dmcrypt.pm')
| -rw-r--r-- | perl-install/fs/dmcrypt.pm | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/perl-install/fs/dmcrypt.pm b/perl-install/fs/dmcrypt.pm index 0e5c3c19e..a78a495d1 100644 --- a/perl-install/fs/dmcrypt.pm +++ b/perl-install/fs/dmcrypt.pm @@ -1,4 +1,4 @@ -package fs::dmcrypt; # $Id: $ +package fs::dmcrypt; use diagnostics; use strict; @@ -11,8 +11,24 @@ use fs::type; use fs::get; use run_program; +=head1 SYNOPSYS + +Manage encrypted file systems using cryptsetup + +=head1 Functions + +=over + +=cut + sub _crypttab() { "$::prefix/etc/crypttab" } +=item init() + +Load kernel modules and init device mapper. + +=cut + sub init() { whereis_binary('cryptsetup') or die "cryptsetup not installed"; @@ -33,6 +49,7 @@ sub read_crypttab_ { my @raw_parts = grep { fs::type::isRawLUKS($_) } fs::get::really_all_fstab($all_hds); foreach (cat_($crypttab)) { + next if /^#/; my ($dm_name, $dev) = split; my $raw_part = fs::get::device2part($dev, \@raw_parts) @@ -43,6 +60,12 @@ sub read_crypttab_ { } } +=item read_crypttab($all_hds) + +Read /etc/crypttab + +=cut + sub read_crypttab { my ($all_hds) = @_; read_crypttab_($all_hds, _crypttab()); @@ -66,6 +89,12 @@ sub save_crypttab_ { } $crypttab; } +=item save_crypttab($all_hds) + +Save /etc/crypttab + +=cut + sub save_crypttab { my ($all_hds) = @_; save_crypttab_($all_hds, _crypttab()); @@ -107,7 +136,12 @@ sub close_part { my $dm_part = fs::get::device2part("mapper/$part->{dm_name}", $dmcrypts); _run_or_die('luksClose', devices::make($dm_part->{device})); $part->{dm_active} = 0; - @$dmcrypts = grep { $_ != $dm_part } @$dmcrypts; + @$dmcrypts = grep { $_ != $dm_part } @$dmcrypts; + # remove partition from /etc/crypttab when deleted (mga#25891) + substInFile { + my ($name, $_dev) = split; + undef $_ if $name eq $part->{dm_name}; + } _crypttab(); } sub _run_or_die { @@ -175,4 +209,8 @@ sub active_dm() { } run_program::get_stdout('dmsetup', 'table'); } +=back + +=cut + 1; |
