Subversion Repositories zfs_utils

Rev

Rev 39 | Rev 41 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 39 Rev 40
Line 334... Line 334...
334
      # Derive the decrypted device name (.eli suffix on FreeBSD)
334
      # Derive the decrypted device name (.eli suffix on FreeBSD)
335
      my $decrypted = $disk . '.eli';
335
      my $decrypted = $disk . '.eli';
336
 
336
 
337
      # Decrypt using geli attach with the keyfile
337
      # Decrypt using geli attach with the keyfile
338
      logMsg("Decrypting $disk with keyfile $keyfile");
338
      logMsg("Decrypting $disk with keyfile $keyfile");
339
      if ( my $result = runCmd("geli attach -k $geliConfig->{target} $disk ") ) {
339
      runCmd("geli attach -k $geliConfig->{target} $disk");
-
 
340
      if ( $lastRunError)
340
         logMsg "Failed to decrypt $disk (exit $result)\n";
341
         logMsg "Failed to decrypt $disk (exit $lastRunError)\n";
341
         next; # ignore failed disks and continue to see if we can import the pool
342
         next; # ignore failed disks and continue to see if we can import the pool
342
      }
343
      }
343
 
344
 
344
      unless ( -e $decrypted ) {
345
      unless ( -e $decrypted ) {
345
         logMsg "Decrypted device $decrypted does not exist after geli attach\n";
346
         logMsg "Decrypted device $decrypted does not exist after geli attach\n";
Line 358... Line 359...
358
   #   push @import_cmd, '-d', $dir;
359
   #   push @import_cmd, '-d', $dir;
359
   #}
360
   #}
360
   
361
   
361
   push @import_cmd, $poolname;
362
   push @import_cmd, $poolname;
362
 
363
 
363
   my $result = system(@import_cmd);
364
   runCmd("zpool import $poolname" );
364
   unless ( $result == 0 ) {
365
   unless ( $lastRunError == 0 ) {
365
      logMsg("Failed to import zfs pool $poolname (exit $result)\n");
366
      logMsg("Failed to import zfs pool $poolname (exit $lastRunError)\n");
366
      return '';
367
      return '';
367
   }
368
   }
368
 
369
 
369
   # Mount the ZFS pool (zfs mount -a mounts all filesystems in the pool)
370
   # Mount the ZFS pool (zfs mount -a mounts all filesystems in the pool)
370
   logMsg("Mounting ZFS pool $poolname");
371
   logMsg("Mounting ZFS pool $poolname");
371
   $result = system('zfs', 'mount', '-a');
372
   runCmd('zfs mount -a');
372
   unless ( $result == 0 ) {
373
   unless ( $lastRunError == 0 ) {
373
      logMsg("Failed to mount zfs pool $poolname (exit $result)\n");
374
      logMsg("Failed to mount zfs pool $poolname (exit $lastRunError)\n");
374
      return '';
375
      return '';
375
   }
376
   }
376
 
377
 
377
   logMsg("Successfully decrypted and mounted pool $poolname");
378
   logMsg("Successfully decrypted and mounted pool $poolname");
378
   return $poolname;
379
   return $poolname;
Line 399... Line 400...
399
   }
400
   }
400
 
401
 
401
   my $remote_keyfile = "$geliConfig->{secureKey}->{path}/$geliConfig->{secureKey}->{keyfile}";
402
   my $remote_keyfile = "$geliConfig->{secureKey}->{path}/$geliConfig->{secureKey}->{keyfile}";
402
   my $localKeyHexOrPath = $geliConfig->{localKey};
403
   my $localKeyHexOrPath = $geliConfig->{localKey};
403
   my $target = $geliConfig->{target};
404
   my $target = $geliConfig->{target};
404
   
405
 
405
   if ( $geliConfig->{secureKey}->{keyfile} && $geliConfig->{localKey} ) {
406
   if ( $geliConfig->{secureKey}->{keyfile} && $geliConfig->{localKey} ) {
406
      # we have what we need to proceed
407
      # we have what we need to proceed
407
 
408
 
408
      if ( -f $remote_keyfile ) {
409
      if ( -f $remote_keyfile ) {
409
         logMsg "Creating GELI keyfile at $geliConfig->{target} using remote keyfile " . $geliConfig->{secureKey}->{keyfile} . " and local key\n";
410
         logMsg "Creating GELI keyfile at $geliConfig->{target} using remote keyfile " . $geliConfig->{secureKey}->{keyfile} . " and local key\n";