diff --git a/src/include/users/dialogs.rb b/src/include/users/dialogs.rb index 03e2f388c..31c083f3d 100644 --- a/src/include/users/dialogs.rb +++ b/src/include/users/dialogs.rb @@ -27,6 +27,7 @@ # # $Id$ +require "pathname" require "shellwords" require "users/ssh_public_key" @@ -64,6 +65,21 @@ def initialize_users_dialogs(include_target) @default_pw = "******" end + def btrfs_path?(path) + dirname = Pathname.new(path).dirname + fstype = Yast::Execute.locally!.stdout("/usr/bin/stat", "-f", "--format", "%T", dirname).chomp + + fstype == "btrfs" + end + + def redraw_btrfs_subvolume_option + home_dir = UI.QueryWidget(Id(:home), :Value) + valid_btrfs_path = btrfs_path?(home_dir) + + UI.ChangeWidget(Id(:btrfs_subvolume), :Enabled, valid_btrfs_path) + UI.ChangeWidget(Id(:btrfs_subvolume), :Value, false) unless valid_btrfs_path + end + # Uppercase letters were used in username! (see bug #26409) # In these popups, ask user what to do. def AskForUppercasePopup(username) @@ -389,6 +405,7 @@ def EditUserDialog(what) create_home = Ops.get_boolean(user, "create_home", true) chown_home = Ops.get_boolean(user, "chown_home", true) no_skel = Ops.get_boolean(user, "no_skeleton", false) + btrfs_subvolume = Ops.get_boolean(user, "btrfs_subvolume", false) do_not_edit = user_type == "nis" complex_layout = installation && Users.StartDialog("user_add") @@ -462,6 +479,7 @@ def EditUserDialog(what) chown_home = Ops.get_boolean(user, "chown_home", chown_home) no_skel = Ops.get_boolean(user, "no_skeleton", no_skel) + btrfs_subvolume = Ops.get_boolean(user, "btrfs_subvolume", btrfs_subvolume) groups = Ops.get_map(user, "grouplist", {}) do_not_edit = user_type == "nis" @@ -724,7 +742,7 @@ def EditUserDialog(what) home_w = VBox( # textentry label - InputField(Id(:home), Opt(:hstretch), _("&Home Directory"), home), + InputField(Id(:home), Opt(:hstretch, :notify), _("&Home Directory"), home), action != "edited" ? Empty() : HBox( @@ -753,6 +771,10 @@ def EditUserDialog(what) HBox( HSpacing(), Left(CheckBox(Id(:skel), _("E&mpty Home"), no_skel)) + ), + HBox( + HSpacing(), + Left(CheckBox(Id(:btrfs_subvolume), _("Btrfs subvolume"), btrfs_subvolume)) ) ) @@ -1011,6 +1033,12 @@ def EditUserDialog(what) error = "" ret = Convert.to_symbol(UI.UserInput) if current != nil + + if ret == :home + redraw_btrfs_subvolume_option + next + end + if (ret == :abort || ret == :cancel) && ReallyAbort() != :abort ret = :notnext next @@ -1342,6 +1370,7 @@ def EditUserDialog(what) ) end UI.ChangeWidget(Id(:home), :Value, dir) + redraw_btrfs_subvolume_option end end @@ -1355,6 +1384,7 @@ def EditUserDialog(what) new_home = Convert.to_string(UI.QueryWidget(Id(:home), :Value)) if what == "add_user" + btrfs_subvolume = UI.QueryWidget(Id(:btrfs_subvolume), :Enabled) && UI.QueryWidget(Id(:btrfs_subvolume), :Value) no_skel = Convert.to_boolean(UI.QueryWidget(Id(:skel), :Value)) mode = Convert.to_string(UI.QueryWidget(Id(:mode), :Value)) end @@ -1539,6 +1569,7 @@ def EditUserDialog(what) Ops.set(user, "addit_data", addit_data) Ops.set(user, "no_skeleton", no_skel) Ops.set(user, "home_mode", mode) + Ops.set(user, "btrfs_subvolume", btrfs_subvolume) end if current == :passwordsettings && (ret == :next || tab)