~teejee2008/timeshift/trunk

« back to all changes in this revision

Viewing changes to src/Core/SnapshotRepo.vala

  • Committer: Tony George
  • Date: 2016-10-03 16:31:49 UTC
  • Revision ID: tony.george.kol@gmail.com-20161003163149-aj8pf94auoazlho0
Device: Moved the code for unlocking luks devices to Device class; Removed redundant code for unlocking devices;

Show diffs side-by-side

added added

removed removed

Lines of Context:
221
221
                        }
222
222
                }
223
223
                        
224
 
                if (parent_window == null){
225
 
 
226
 
                        var counter = new TimeoutCounter();
227
 
                        counter.kill_process_on_timeout("cryptsetup", 20, true);
228
 
 
229
 
                        // prompt user to unlock
230
 
                        string cmd = "cryptsetup luksOpen '%s' '%s'".printf(luks_device.device, mapped_name);
231
 
                        Posix.system(cmd);
232
 
                        counter.stop();
233
 
                        log_msg("");
234
 
 
235
 
                        partitions = Device.get_block_devices_using_lsblk();
236
 
 
237
 
                        // check if unlocked
238
 
                        foreach(var part in partitions){
239
 
                                if (part.pkname == luks_device.kname){
240
 
                                        log_msg(_("Unlocked device is mapped to '%s'").printf(part.name));
241
 
                                        log_msg("");
242
 
                                        return part;
243
 
                                }
244
 
                        }
245
 
                }
246
 
                else{
247
 
                        // prompt user for password
248
 
                        string? passphrase = gtk_inputbox(
249
 
                                _("Encrypted Device"),
250
 
                                _("Enter passphrase to unlock '%s'").printf(luks_device.name),
251
 
                                parent_window, true);
252
 
 
253
 
                        if (passphrase == null){
254
 
                                // cancelled by user
255
 
                                log_debug("User cancelled the input prompt");
256
 
                                return null;
257
 
                        }
258
 
 
259
 
                        gtk_set_busy(true, parent_window);
260
 
 
261
 
                        string message, details;
262
 
                        luks_unlocked = Device.luks_unlock(luks_device, mapped_name, passphrase,
263
 
                                out message, out details);
264
 
 
265
 
                        bool is_error = (luks_unlocked == null);
266
 
 
267
 
                        gtk_set_busy(false, parent_window);
268
 
 
269
 
                        gtk_messagebox(message, details, null, is_error);
270
 
                }
 
224
                string msg_out, msg_err;
 
225
                luks_unlocked = Device.luks_unlock(
 
226
                        luks_device, mapped_name, "", parent_window, out msg_out, out msg_err);
271
227
 
272
228
                return luks_unlocked;
273
229
        }