Skip to content

Commit

Permalink
Add custom mount options
Browse files Browse the repository at this point in the history
Co-authored-by: moson-mo <[email protected]>
  • Loading branch information
phpony and moson-mo committed Jan 24, 2024
1 parent 59402e0 commit 6a486aa
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
22 changes: 22 additions & 0 deletions resources/ui/VaultWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,28 @@
<property name="top-attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Custom mount options</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry_custom_options">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
<placeholder/>
</child>
Expand Down
5 changes: 4 additions & 1 deletion src/Gocrypt.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Cryptor {
}
}

public static void mount_vault (string path, string mountpoint, string password, bool ro, bool reverse) throws Error {
public static void mount_vault (string path, string mountpoint, string password, bool ro, bool reverse, string custom_options) throws Error {
string standard_error;
int status;

Expand All @@ -39,6 +39,9 @@ namespace Cryptor {
if (reverse) {
cmd += "-reverse ";
}
if (custom_options != "") {
cmd += custom_options + " ";
}
cmd += " -passfile " + pfile.get_path () + " -- " + path + " " + mountpoint;
try {
Process.spawn_command_line_sync (cmd, null, out standard_error, out status);
Expand Down
1 change: 1 addition & 0 deletions src/data/Vault.vala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Cryptor.Data {
public string mount_point { get; set; }
public string mode { get; set; }
public bool reverse { get; set; }
public string custom_options { get; set; default = ""; }
public bool is_mounted;
}
}
4 changes: 2 additions & 2 deletions src/ui/CryptorWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,15 @@ namespace Cryptor.UI {
return;
}
try {
Gocrypt.mount_vault (vault.path, vault.mount_point, password, (vault.mode == "r"), vault.reverse);
Gocrypt.mount_vault (vault.path, vault.mount_point, password, (vault.mode == "r"), vault.reverse, vault.custom_options);
vault.is_mounted = true;
sync_treeview_from_conf ();
} catch (Error e) {
if (e.message.contains ("fusermount exited with code 256")) {
if (Utils.show_question (this, "%s\n\n%s\n%s".printf (e.message, _("Vault might be mounted already."), _("Shall I retry unmounting it first?"))) == ResponseType.YES) {
try {
Gocrypt.unmount_vault (vault.mount_point);
Gocrypt.mount_vault (vault.path, vault.mount_point, password, (vault.mode == "r"), vault.reverse);
Gocrypt.mount_vault (vault.path, vault.mount_point, password, (vault.mode == "r"), vault.reverse, vault.custom_options);
vault.is_mounted = true;
sync_treeview_from_conf ();
} catch (Error e) {
Expand Down
5 changes: 5 additions & 0 deletions src/ui/VaultWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ namespace Cryptor.UI {
[GtkChild]
private unowned CheckButton check_reverse;

[GtkChild]
private unowned Entry entry_custom_options;

public VaultWindow (Window parent, int row, Config config) {
Object (
transient_for: parent
Expand All @@ -38,6 +41,7 @@ namespace Cryptor.UI {
entry_vault.text = v.path;
entry_mountpoint.text = v.mount_point;
combo_mode.active_id = v.mode;
entry_custom_options.text = v.custom_options;
}
if (row == -1) {
this.title = _("New vault");
Expand Down Expand Up @@ -157,6 +161,7 @@ namespace Cryptor.UI {
v.mount_point = entry_mountpoint.text;
v.mode = combo_mode.active_id;
v.reverse = check_reverse.active;
v.custom_options = entry_custom_options.text;

config.changes_made = true;

Expand Down

0 comments on commit 6a486aa

Please sign in to comment.