diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..89bc8dd --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/udisks-2.7.3.tar.bz2 diff --git a/.udisks2.metadata b/.udisks2.metadata new file mode 100644 index 0000000..c81af9b --- /dev/null +++ b/.udisks2.metadata @@ -0,0 +1 @@ +dd8daa649796a6737ef3f0fd3fe3f536714b9fba SOURCES/udisks-2.7.3.tar.bz2 diff --git a/README.md b/README.md deleted file mode 100644 index 0e7897f..0000000 --- a/README.md +++ /dev/null @@ -1,5 +0,0 @@ -The master branch has no content - -Look at the c7 branch if you are working with CentOS-7, or the c4/c5/c6 branch for CentOS-4, 5 or 6 - -If you find this file in a distro specific branch, it means that no content has been checked in yet diff --git a/SOURCES/fix_mpoin_cleanup_1384796.patch b/SOURCES/fix_mpoin_cleanup_1384796.patch new file mode 100644 index 0000000..2c6499e --- /dev/null +++ b/SOURCES/fix_mpoin_cleanup_1384796.patch @@ -0,0 +1,93 @@ +From aad98b87513f9e277258c8bc9c3bc7db7a8442ba Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Thu, 18 Jan 2018 13:59:11 +0100 +Subject: [PATCH] Fix escaping mountpoint for the cleanup service + +We need to use the 'systemd-escape' command -- it escapes more +symbols and manually escaping only slashes isn't enough. + +Resolves: rhbz#1384796 +(cherry picked from commit 4d982bb6b81afcd17b0a42b6c1256c22ff444ee5) +--- + src/udiskslinuxfilesystem.c | 38 +++++++++++++++++++++++++++----------- + 1 file changed, 27 insertions(+), 11 deletions(-) + +diff --git a/src/udiskslinuxfilesystem.c b/src/udiskslinuxfilesystem.c +index 2910181..e2b7e18 100644 +--- a/src/udiskslinuxfilesystem.c ++++ b/src/udiskslinuxfilesystem.c +@@ -1144,10 +1144,11 @@ is_system_managed (UDisksBlock *block, + + static void trigger_mpoint_cleanup (const gchar *mount_point) + { +- const gchar *argv[] = {"systemctl", "start", NULL, NULL}; ++ const gchar *service_argv[] = {"systemctl", "start", NULL, NULL}; ++ const gchar *escape_argv[] = {"systemd-escape", NULL, NULL}; + GError *error = NULL; + gchar *escaped_mpoint = NULL; +- gsize len = 0; ++ size_t len = 0; + + if (g_str_has_prefix (mount_point, "/")) + mount_point++; +@@ -1155,14 +1156,27 @@ static void trigger_mpoint_cleanup (const gchar *mount_point) + udisks_warning ("Invalid mount point given to trigger_mpoint_cleanup(): %s", + mount_point); + +- /* start with the mount point without the leading '/' */ +- escaped_mpoint = g_strdup (mount_point); ++ /* use 'systemd-escape' to escape the mountpoint */ ++ escape_argv[1] = g_strdup (mount_point); + +- /* and replace all '/'s with '-'s */ +- for (gchar *letter = escaped_mpoint; *letter != '\0'; letter++, len++) ++ if (!bd_utils_exec_and_capture_output (escape_argv, NULL, &escaped_mpoint, &error) && (error != NULL)) + { +- if (*letter == '/') +- *letter = '-'; ++ /* this is a best-effort mechanism, if it fails, just log warning and move ++ on */ ++ udisks_warning ("Failed to setup systemd-based mount point cleanup: %s", ++ error->message); ++ g_clear_error (&error); ++ goto out; ++ } ++ ++ /* remove leading/trailing whitespace */ ++ g_strstrip (escaped_mpoint); ++ ++ len = strlen (escaped_mpoint); ++ if (len <= 0) ++ { ++ udisks_warning ("Failed to setup systemd-based mount point cleanup"); ++ goto out; + } + + /* remove the potential trailing '-' (would happen if the given mount_point +@@ -1170,9 +1184,9 @@ static void trigger_mpoint_cleanup (const gchar *mount_point) + if (escaped_mpoint[len - 1] == '-') + escaped_mpoint[len - 1] = '\0'; + +- argv[2] = g_strdup_printf ("clean-mount-point@%s", escaped_mpoint); ++ service_argv[2] = g_strdup_printf ("clean-mount-point@%s", escaped_mpoint); + +- if (!bd_utils_exec_and_report_error (argv, NULL, &error) && (error != NULL)) ++ if (!bd_utils_exec_and_report_error (service_argv, NULL, &error) && (error != NULL)) + { + /* this is a best-effort mechanism, if it fails, just log warning and move + on */ +@@ -1181,8 +1195,10 @@ static void trigger_mpoint_cleanup (const gchar *mount_point) + g_clear_error (&error); + } + ++out: + g_free (escaped_mpoint); +- g_free ((gchar *) argv[2]); ++ g_free ((gchar *) service_argv[2]); ++ g_free ((gchar *) escape_argv[1]); + } + + /* ---------------------------------------------------------------------------------------------------- */ +-- +1.8.3.1 + diff --git a/SOURCES/fix_thinpool_size_1534904.patch b/SOURCES/fix_thinpool_size_1534904.patch new file mode 100644 index 0000000..c78320d --- /dev/null +++ b/SOURCES/fix_thinpool_size_1534904.patch @@ -0,0 +1,34 @@ +From 34bf5d61e5ea1bd9450db6197fc9791a8e7aa8da Mon Sep 17 00:00:00 2001 +From: Marius Vollmer +Date: Wed, 13 Dec 2017 15:28:23 +0200 +Subject: [PATCH] lvm2: Don't match prefixes in cmp_int_lv_name + +Once the whole internal name has matched, the other name must also be +at the end. Otherwise we might find "lvol0" when looking for +"lvol0_meta", for example. + +The symptom is that the size of a pool is reported as twice its data +size, instead of data plus metadata size, which funnily is exactly the +same symptom fixed by 043edcb. Deja vu... + +(cherry picked from commit 821bc20911e9a446b943cf40abe0e8a8132bf418) +--- + modules/lvm2/udiskslinuxvolumegroupobject.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/modules/lvm2/udiskslinuxvolumegroupobject.c b/modules/lvm2/udiskslinuxvolumegroupobject.c +index 617af04..3f622a6 100644 +--- a/modules/lvm2/udiskslinuxvolumegroupobject.c ++++ b/modules/lvm2/udiskslinuxvolumegroupobject.c +@@ -530,7 +530,7 @@ cmp_int_lv_name (const gchar *int_lv_name, const gchar *lv_name) + + if (*c == ']') + c++; +- if (*c == '\0') ++ if (*c == '\0' && lv_name[c - int_lv_name] == '\0') + return TRUE; + + return FALSE; +-- +1.8.3.1 + diff --git a/SOURCES/no_discard_1516697.patch b/SOURCES/no_discard_1516697.patch new file mode 100644 index 0000000..65eda10 --- /dev/null +++ b/SOURCES/no_discard_1516697.patch @@ -0,0 +1,317 @@ +From 50b7a2125f77f23901eff12c76efb80881236513 Mon Sep 17 00:00:00 2001 +From: Marius Vollmer +Date: Thu, 23 Nov 2017 11:40:50 +0200 +Subject: [PATCH] Add 'no-discard' option to formatting methods + +It unfortunately seems to be necessary to use this option in certain +situations. See https://bugzilla.redhat.com/show_bug.cgi?id=1516041 +for example. + +(cherry picked from commit 26ac7429b5ef9b5024e54e6eca25b685c0666eb5) + +Conflicts: + src/udiskslinuxblock.c + +Signed-off-by: Vratislav Podzimek +--- + data/org.freedesktop.UDisks2.xml | 4 ++++ + src/tests/integration-test | 14 +++++++----- + src/udiskslinuxblock.c | 48 ++++++++++++++++++++++++++++------------ + src/udiskslinuxfsinfo.c | 31 ++++++++++++++++++-------- + src/udiskslinuxfsinfo.h | 1 + + 5 files changed, 70 insertions(+), 28 deletions(-) + +diff --git a/data/org.freedesktop.UDisks2.xml b/data/org.freedesktop.UDisks2.xml +index fa53a72..1f71ca1 100644 +--- a/data/org.freedesktop.UDisks2.xml ++++ b/data/org.freedesktop.UDisks2.xml +@@ -1404,6 +1404,10 @@ + this allows a deeper check of the parameters even when + no-block is %TRUE. + ++ If the option no-discard is set to ++ %TRUE then Udisks tells the formatting utility not to issue ++ BLKDISCARD ioctls. ++ + If the option config-items is set, it + should be an array of configuration items suitable for + org.freedesktop.UDisks2.Block.AddConfigurationItem. They will +diff --git a/src/tests/integration-test b/src/tests/integration-test +index f863578..0edbb6a 100755 +--- a/src/tests/integration-test ++++ b/src/tests/integration-test +@@ -825,6 +825,8 @@ class FS(UDisksTestCase): + self._do_udisks_check(fs_type, 'test%stst' % fs_type) + # also test fs_create with an empty label + self._do_udisks_check(fs_type, '') ++ # also test fs_create with the no-discard option ++ self._do_udisks_check(fs_type, '', True) + + def _do_cli_check(self, fs_type, label=None): + """udisks correctly picks up file system changes from command line tools""" +@@ -890,15 +892,17 @@ class FS(UDisksTestCase): + subprocess.call(['umount', mount_a]) + self.assertProperty(fs, 'mount-points', []) + +- def _do_udisks_check(self, fs_type, label=None): ++ def _do_udisks_check(self, fs_type, label=None, no_discard=None): + """udisks API correctly changes file system""" + ++ + # create fs ++ options = { } + if label is not None: +- options = GLib.Variant('a{sv}', {'label': GLib.Variant('s', label)}) +- else: +- options = no_options +- self.fs_create(None, fs_type, options) ++ options['label'] = GLib.Variant('s', label); ++ if no_discard is not None: ++ options['no-discard'] = GLib.Variant('b', no_discard); ++ self.fs_create(None, fs_type, GLib.Variant('a{sv}', options)) + + # properties + b_id = self.blkid() +diff --git a/src/udiskslinuxblock.c b/src/udiskslinuxblock.c +index 3d56577..0de5422 100644 +--- a/src/udiskslinuxblock.c ++++ b/src/udiskslinuxblock.c +@@ -2656,6 +2656,27 @@ add_blocksize (gchar **command, + return TRUE; + } + ++static gchar * ++build_command (const gchar *template, ++ const gchar *device, ++ const gchar *label, ++ const gchar *options, ++ GError **error) ++{ ++ gchar *tmp, *tmp2, *command; ++ tmp = udisks_daemon_util_subst_str_and_escape (template, "$DEVICE", device); ++ tmp2 = udisks_daemon_util_subst_str_and_escape (tmp, "$LABEL", label != NULL ? label : ""); ++ command = udisks_daemon_util_subst_str (tmp2, "$OPTIONS", options != NULL ? options : ""); ++ g_free (tmp); ++ g_free (tmp2); ++ if (strstr (command, "$BLOCKSIZE") && ! add_blocksize (&command, device, error)) ++ { ++ g_free (command); ++ return NULL; ++ } ++ ++ return command; ++} + + void + udisks_linux_block_handle_format (UDisksBlock *block, +@@ -2679,8 +2700,8 @@ udisks_linux_block_handle_format (UDisksBlock *block, + const gchar *action_id; + const gchar *message; + const FSInfo *fs_info; ++ const gchar *command_options = NULL; + gchar *command = NULL; +- gchar *tmp; + gchar *error_message; + GError *error; + int status; +@@ -2700,6 +2721,7 @@ udisks_linux_block_handle_format (UDisksBlock *block, + const gchar *partition_type = NULL; + GVariant *config_items = NULL; + gboolean teardown_flag = FALSE; ++ gboolean no_discard_flag = FALSE; + BDPartTableType part_table_type = BD_PART_TABLE_UNDEF; + + error = NULL; +@@ -2723,6 +2745,7 @@ udisks_linux_block_handle_format (UDisksBlock *block, + g_variant_lookup (options, "dry-run-first", "b", &dry_run_first); + g_variant_lookup (options, "config-items", "@a(sa{sv})", &config_items); + g_variant_lookup (options, "tear-down", "b", &teardown_flag); ++ g_variant_lookup (options, "no-discard", "b", &no_discard_flag); + + partition = udisks_object_get_partition (object); + if (partition != NULL) +@@ -2886,21 +2909,20 @@ udisks_linux_block_handle_format (UDisksBlock *block, + goto out; + } + ++ if (no_discard_flag && fs_info->option_no_discard) ++ command_options = fs_info->option_no_discard; ++ + /* If requested, check whether the ultimate filesystem creation + will succeed before actually getting to work. + */ + if (dry_run_first && fs_info->command_validate_create_fs) + { + const gchar *device = udisks_block_get_device (block); +- tmp = udisks_daemon_util_subst_str_and_escape (fs_info->command_validate_create_fs, "$DEVICE", +- device); +- command = udisks_daemon_util_subst_str_and_escape (tmp, "$LABEL", label != NULL ? label : ""); +- g_free (tmp); +- if (strstr (command, "$BLOCKSIZE") && ! add_blocksize (&command, device, &error)) +- { +- handle_format_failure (invocation, error); +- goto out; +- } ++ command = build_command (fs_info->command_validate_create_fs, device, label, command_options, &error); ++ if (command == NULL) { ++ handle_format_failure (invocation, error); ++ goto out; ++ } + + if (!udisks_daemon_launch_spawned_job_sync (daemon, + object, +@@ -3081,10 +3103,8 @@ udisks_linux_block_handle_format (UDisksBlock *block, + { + /* Build and run mkfs shell command */ + const gchar *device = udisks_block_get_device (block_to_mkfs); +- tmp = udisks_daemon_util_subst_str_and_escape (fs_info->command_create_fs, "$DEVICE", device); +- command = udisks_daemon_util_subst_str_and_escape (tmp, "$LABEL", label != NULL ? label : ""); +- g_free (tmp); +- if (strstr (command, "$BLOCKSIZE") && ! add_blocksize (&command, device, &error)) ++ command = build_command (fs_info->command_create_fs, device, label, command_options, &error); ++ if (command == NULL) + { + handle_format_failure (invocation, error); + goto out; +diff --git a/src/udiskslinuxfsinfo.c b/src/udiskslinuxfsinfo.c +index b7834c0..1556af3 100644 +--- a/src/udiskslinuxfsinfo.c ++++ b/src/udiskslinuxfsinfo.c +@@ -70,8 +70,9 @@ const FSInfo _fs_info[] = + NULL, + TRUE, /* supports_online_label_rename */ + TRUE, /* supports_owners */ +- "mkfs.ext2 -F -L $LABEL $DEVICE", +- "mkfs.ext2 -n -F -L $LABEL $DEVICE", ++ "mkfs.ext2 -F -L $LABEL $OPTIONS $DEVICE", ++ "mkfs.ext2 -n -F -L $LABEL $OPTIONS $DEVICE", ++ "-E nodiscard", /* option_no_discard */ + }, + { + FS_EXT3, +@@ -79,8 +80,9 @@ const FSInfo _fs_info[] = + NULL, + TRUE, /* supports_online_label_rename */ + TRUE, /* supports_owners */ +- "mkfs.ext3 -F -L $LABEL $DEVICE", +- "mkfs.ext3 -n -F -L $LABEL $DEVICE", ++ "mkfs.ext3 -F -L $LABEL $OPTIONS $DEVICE", ++ "mkfs.ext3 -n -F -L $LABEL $OPTIONS $DEVICE", ++ "-E nodiscard", /* option_no_discard */ + }, + { + FS_EXT4, +@@ -88,8 +90,9 @@ const FSInfo _fs_info[] = + NULL, + TRUE, /* supports_online_label_rename */ + TRUE, /* supports_owners */ +- "mkfs.ext4 -F -L $LABEL $DEVICE", +- "mkfs.ext4 -n -F -L $LABEL $DEVICE", ++ "mkfs.ext4 -F -L $LABEL $OPTIONS $DEVICE", ++ "mkfs.ext4 -n -F -L $LABEL $OPTIONS $DEVICE", ++ "-E nodiscard", /* option_no_discard */ + }, + { + FS_VFAT, +@@ -99,6 +102,7 @@ const FSInfo _fs_info[] = + FALSE, /* supports_owners */ + "mkfs.vfat -I -n $LABEL $DEVICE", + NULL, ++ NULL, /* option_no_discard */ + }, + { + FS_NTFS, +@@ -108,6 +112,7 @@ const FSInfo _fs_info[] = + FALSE, /* supports_owners */ + "mkntfs -f -F -L $LABEL $DEVICE", + "mkntfs -n -f -F -L $LABEL $DEVICE", ++ NULL, /* option_no_discard */ + }, + { + FS_EXFAT, +@@ -117,6 +122,7 @@ const FSInfo _fs_info[] = + FALSE, /* supports_owners */ + "mkexfatfs -n $LABEL $DEVICE", + NULL, ++ NULL, /* option_no_discard */ + }, + { + FS_XFS, +@@ -124,8 +130,9 @@ const FSInfo _fs_info[] = + "xfs_admin -L -- $DEVICE", + FALSE, /* supports_online_label_rename */ + TRUE, /* supports_owners */ +- "mkfs.xfs -f -L $LABEL $DEVICE", +- "mkfs.xfs -N -f -L $LABEL $DEVICE" ++ "mkfs.xfs -f -L $LABEL $OPTIONS $DEVICE", ++ "mkfs.xfs -N -f -L $LABEL $OPTIONS $DEVICE", ++ "-K" /* option_no_discard */ + }, + { + FS_REISERFS, +@@ -135,6 +142,7 @@ const FSInfo _fs_info[] = + TRUE, /* supports_owners */ + "mkfs.reiserfs -q -l $LABEL $DEVICE", + NULL, ++ NULL, /* option_no_discard */ + }, + { + FS_NILFS2, +@@ -144,6 +152,7 @@ const FSInfo _fs_info[] = + TRUE, /* supports_owners */ + "mkfs.nilfs2 -L $LABEL $DEVICE", + NULL, ++ NULL, /* option_no_discard */ + }, + { + FS_BTRFS, +@@ -151,8 +160,9 @@ const FSInfo _fs_info[] = + NULL, + FALSE, /* supports_online_label_rename */ + TRUE, /* supports_owners */ +- "mkfs.btrfs -L $LABEL $DEVICE", ++ "mkfs.btrfs -L $LABEL $OPTIONS $DEVICE", + NULL, ++ "-K", /* option_no_discard */ + }, + { + FS_MINIX, +@@ -162,6 +172,7 @@ const FSInfo _fs_info[] = + FALSE, /* supports_owners */ + "mkfs.minix $DEVICE", + NULL, ++ NULL, + }, + { + FS_UDF, +@@ -171,6 +182,7 @@ const FSInfo _fs_info[] = + TRUE, /* supports_owners */ + "mkudffs --utf8 --media-type=hd --udfrev=0x201 --blocksize=$BLOCKSIZE --vid $LABEL --lvid $LABEL $DEVICE", + NULL, ++ NULL, + }, + { + FS_F2FS, +@@ -180,6 +192,7 @@ const FSInfo _fs_info[] = + TRUE, /* supports_owners */ + "mkfs.f2fs -l $LABEL $DEVICE", + NULL, ++ NULL, + }, + /* swap space */ + { +diff --git a/src/udiskslinuxfsinfo.h b/src/udiskslinuxfsinfo.h +index 2daec10..6a7a541 100644 +--- a/src/udiskslinuxfsinfo.h ++++ b/src/udiskslinuxfsinfo.h +@@ -35,6 +35,7 @@ typedef struct + gboolean supports_owners; + const gchar *command_create_fs; /* should have $DEVICE and $LABEL */ + const gchar *command_validate_create_fs; /* should have $DEVICE and $LABEL */ ++ const gchar *option_no_discard; + } FSInfo; + + const FSInfo *get_fs_info (const gchar *fstype); +-- +2.9.5 + diff --git a/SOURCES/raid_watchers_1400056.patch b/SOURCES/raid_watchers_1400056.patch new file mode 100644 index 0000000..544fdcd --- /dev/null +++ b/SOURCES/raid_watchers_1400056.patch @@ -0,0 +1,514 @@ +From 5bcb348b17935328a2344d811ddba9847ab3c846 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Mon, 16 Oct 2017 12:33:14 +0200 +Subject: [PATCH 1/5] Move some useful mdraid functions to a helper file + +Related: rhbz#1400056 +Signed-off-by: Vratislav Podzimek +--- + src/Makefile.am | 1 + + src/udiskslinuxmdraid.c | 83 ++------------------------------ + src/udiskslinuxmdraidhelpers.c | 104 +++++++++++++++++++++++++++++++++++++++++ + src/udiskslinuxmdraidhelpers.h | 41 ++++++++++++++++ + 4 files changed, 149 insertions(+), 80 deletions(-) + create mode 100644 src/udiskslinuxmdraidhelpers.c + create mode 100644 src/udiskslinuxmdraidhelpers.h + +diff --git a/src/Makefile.am b/src/Makefile.am +index 396ab4e..9cca8cd 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -66,6 +66,7 @@ libudisks_daemon_la_SOURCES = \ + udiskslinuxdrive.h udiskslinuxdrive.c \ + udiskslinuxdriveata.h udiskslinuxdriveata.c \ + udiskslinuxmdraidobject.h udiskslinuxmdraidobject.c \ ++ udiskslinuxmdraidhelpers.h udiskslinuxmdraidhelpers.c \ + udiskslinuxmdraid.h udiskslinuxmdraid.c \ + udiskslinuxmanager.h udiskslinuxmanager.c \ + udiskslinuxfsinfo.h udiskslinuxfsinfo.c \ +diff --git a/src/udiskslinuxmdraid.c b/src/udiskslinuxmdraid.c +index 9bf6ae9..2dcf0ff 100644 +--- a/src/udiskslinuxmdraid.c ++++ b/src/udiskslinuxmdraid.c +@@ -38,6 +38,7 @@ + #include "udiskslinuxprovider.h" + #include "udiskslinuxmdraidobject.h" + #include "udiskslinuxmdraid.h" ++#include "udiskslinuxmdraidhelpers.h" + #include "udiskslinuxblockobject.h" + #include "udisksdaemon.h" + #include "udisksstate.h" +@@ -128,68 +129,6 @@ udisks_linux_mdraid_new (void) + + /* ---------------------------------------------------------------------------------------------------- */ + +-static gchar * +-read_sysfs_attr (GUdevDevice *device, +- const gchar *attr) +-{ +- gchar *ret = NULL; +- gchar *path = NULL; +- GError *error = NULL; +- +- g_return_val_if_fail (G_UDEV_IS_DEVICE (device), NULL); +- +- path = g_strdup_printf ("%s/%s", g_udev_device_get_sysfs_path (device), attr); +- if (!g_file_get_contents (path, &ret, NULL /* size */, &error)) +- { +- udisks_warning ("Error reading sysfs attr `%s': %s (%s, %d)", +- path, error->message, g_quark_to_string (error->domain), error->code); +- g_clear_error (&error); +- goto out; +- } +- +- out: +- g_free (path); +- return ret; +-} +- +-static gint +-read_sysfs_attr_as_int (GUdevDevice *device, +- const gchar *attr) +-{ +- gint ret = 0; +- gchar *str = NULL; +- +- str = read_sysfs_attr (device, attr); +- if (str == NULL) +- goto out; +- +- ret = atoi (str); +- g_free (str); +- +- out: +- return ret; +-} +- +-static guint64 +-read_sysfs_attr_as_uint64 (GUdevDevice *device, +- const gchar *attr) +-{ +- guint64 ret = 0; +- gchar *str = NULL; +- +- str = read_sysfs_attr (device, attr); +- if (str == NULL) +- goto out; +- +- ret = atoll (str); +- g_free (str); +- +- out: +- return ret; +-} +- +-/* ---------------------------------------------------------------------------------------------------- */ +- + static gboolean + on_polling_timout (gpointer user_data) + { +@@ -306,8 +245,6 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid *mdraid, + guint64 sync_remaining_time = 0; + GVariantBuilder builder; + UDisksDaemon *daemon = NULL; +- gboolean has_redundancy = FALSE; +- gboolean has_stripes = FALSE; + UDisksBaseJob *job = NULL; + + daemon = udisks_linux_mdraid_object_get_daemon (object); +@@ -377,23 +314,9 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid *mdraid, + + udisks_mdraid_set_running (iface, raid_device != NULL); + +- if (g_strcmp0 (level, "raid1") == 0 || +- g_strcmp0 (level, "raid4") == 0 || +- g_strcmp0 (level, "raid5") == 0 || +- g_strcmp0 (level, "raid6") == 0 || +- g_strcmp0 (level, "raid10") == 0) +- has_redundancy = TRUE; +- +- if (g_strcmp0 (level, "raid0") == 0 || +- g_strcmp0 (level, "raid4") == 0 || +- g_strcmp0 (level, "raid5") == 0 || +- g_strcmp0 (level, "raid6") == 0 || +- g_strcmp0 (level, "raid10") == 0) +- has_stripes = TRUE; +- + if (raid_device != NULL) + { +- if (has_redundancy) ++ if (mdraid_has_redundancy (level)) + { + /* Can't use GUdevDevice methods as they cache the result and these variables vary */ + degraded = read_sysfs_attr_as_int (raid_device->udev_device, "md/degraded"); +@@ -408,7 +331,7 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid *mdraid, + g_strstrip (bitmap_location); + } + +- if (has_stripes) ++ if (mdraid_has_stripes (level)) + { + chunk_size = read_sysfs_attr_as_uint64 (raid_device->udev_device, "md/chunk_size"); + } +diff --git a/src/udiskslinuxmdraidhelpers.c b/src/udiskslinuxmdraidhelpers.c +new file mode 100644 +index 0000000..dafdddf +--- /dev/null ++++ b/src/udiskslinuxmdraidhelpers.c +@@ -0,0 +1,104 @@ ++/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- ++ * ++ * Copyright (C) 2017 Red Hat, Inc. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ++ * ++ * Author: Vojtech Trefny ++ * ++ */ ++ ++#include ++#include ++#include ++ ++#include "udiskslinuxmdraidhelpers.h" ++#include "udiskslogging.h" ++ ++gboolean ++mdraid_has_redundancy (const gchar *raid_level) ++{ ++ return raid_level != NULL && ++ g_str_has_prefix (raid_level, "raid") && ++ g_strcmp0 (raid_level, "raid0") != 0; ++} ++ ++gboolean ++mdraid_has_stripes (const gchar *raid_level) ++{ ++ return raid_level != NULL && ++ g_str_has_prefix (raid_level, "raid") && ++ g_strcmp0 (raid_level, "raid1") != 0; ++} ++ ++gchar * ++read_sysfs_attr (GUdevDevice *device, ++ const gchar *attr) ++{ ++ gchar *ret = NULL; ++ gchar *path = NULL; ++ GError *error = NULL; ++ ++ g_return_val_if_fail (G_UDEV_IS_DEVICE (device), NULL); ++ ++ path = g_strdup_printf ("%s/%s", g_udev_device_get_sysfs_path (device), attr); ++ if (!g_file_get_contents (path, &ret, NULL /* size */, &error)) ++ { ++ udisks_warning ("Error reading sysfs attr `%s': %s (%s, %d)", ++ path, error->message, g_quark_to_string (error->domain), error->code); ++ g_clear_error (&error); ++ goto out; ++ } ++ ++ out: ++ g_free (path); ++ return ret; ++} ++ ++gint ++read_sysfs_attr_as_int (GUdevDevice *device, ++ const gchar *attr) ++{ ++ gint ret = 0; ++ gchar *str = NULL; ++ ++ str = read_sysfs_attr (device, attr); ++ if (str == NULL) ++ goto out; ++ ++ ret = atoi (str); ++ g_free (str); ++ ++ out: ++ return ret; ++} ++ ++guint64 ++read_sysfs_attr_as_uint64 (GUdevDevice *device, ++ const gchar *attr) ++{ ++ guint64 ret = 0; ++ gchar *str = NULL; ++ ++ str = read_sysfs_attr (device, attr); ++ if (str == NULL) ++ goto out; ++ ++ ret = atoll (str); ++ g_free (str); ++ ++ out: ++ return ret; ++} +diff --git a/src/udiskslinuxmdraidhelpers.h b/src/udiskslinuxmdraidhelpers.h +new file mode 100644 +index 0000000..6d2b714 +--- /dev/null ++++ b/src/udiskslinuxmdraidhelpers.h +@@ -0,0 +1,41 @@ ++/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- ++ * ++ * Copyright (C) 2017 Red Hat, Inc. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ++ * ++ * Author: Vojtech Trefny ++ * ++ */ ++ ++#ifndef __UDISKS_LINUX_MDRAID_HELPERS_H__ ++#define __UDISKS_LINUX_MDRAID_HEPLERS_H__ ++ ++#include ++#include ++ ++ ++G_BEGIN_DECLS ++ ++gboolean mdraid_has_redundancy (const gchar *raid_level); ++gboolean mdraid_has_stripes (const gchar *raid_level); ++gchar *read_sysfs_attr (GUdevDevice *device, const gchar *attr); ++gint read_sysfs_attr_as_int (GUdevDevice *device, const gchar *attr); ++guint64 read_sysfs_attr_as_uint64 (GUdevDevice *device, const gchar *attr); ++ ++G_END_DECLS ++ ++ ++#endif /* __UDISKS_LINUX_MDRAID_HEPLERS_H__ */ +-- +2.9.5 + +From 61ff342139f21663958bcc2972a3efa37cf7bc83 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Mon, 16 Oct 2017 12:41:22 +0200 +Subject: [PATCH 2/5] Remove leading/trailing white space in 'read_sysfs_attr' + +So we don't have to call 'g_strstrip' after using it. + +Related: rhbz#1400056 +Signed-off-by: Vratislav Podzimek +--- + src/udiskslinuxmdraid.c | 8 -------- + src/udiskslinuxmdraidhelpers.c | 4 ++++ + 2 files changed, 4 insertions(+), 8 deletions(-) + +diff --git a/src/udiskslinuxmdraid.c b/src/udiskslinuxmdraid.c +index 2dcf0ff..22b4ee4 100644 +--- a/src/udiskslinuxmdraid.c ++++ b/src/udiskslinuxmdraid.c +@@ -321,14 +321,8 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid *mdraid, + /* Can't use GUdevDevice methods as they cache the result and these variables vary */ + degraded = read_sysfs_attr_as_int (raid_device->udev_device, "md/degraded"); + sync_action = read_sysfs_attr (raid_device->udev_device, "md/sync_action"); +- if (sync_action != NULL) +- g_strstrip (sync_action); + sync_completed = read_sysfs_attr (raid_device->udev_device, "md/sync_completed"); +- if (sync_completed != NULL) +- g_strstrip (sync_completed); + bitmap_location = read_sysfs_attr (raid_device->udev_device, "md/bitmap/location"); +- if (bitmap_location != NULL) +- g_strstrip (bitmap_location); + } + + if (mdraid_has_stripes (level)) +@@ -472,7 +466,6 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid *mdraid, + member_state = read_sysfs_attr (raid_device->udev_device, buf); + if (member_state != NULL) + { +- g_strstrip (member_state); + member_state_elements = g_strsplit (member_state, ",", 0); + } + else +@@ -486,7 +479,6 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid *mdraid, + member_slot = read_sysfs_attr (raid_device->udev_device, buf); + if (member_slot != NULL) + { +- g_strstrip (member_slot); + if (g_strcmp0 (member_slot, "none") != 0) + member_slot_as_int = atoi (member_slot); + } +diff --git a/src/udiskslinuxmdraidhelpers.c b/src/udiskslinuxmdraidhelpers.c +index dafdddf..297b1fa 100644 +--- a/src/udiskslinuxmdraidhelpers.c ++++ b/src/udiskslinuxmdraidhelpers.c +@@ -62,6 +62,10 @@ read_sysfs_attr (GUdevDevice *device, + goto out; + } + ++ /* remove newline from the attribute */ ++ if (ret != NULL) ++ g_strstrip (ret); ++ + out: + g_free (path); + return ret; +-- +2.9.5 + +From 756571efc1b0d602bca2dd4ff761dca686dc08bd Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Mon, 16 Oct 2017 12:42:42 +0200 +Subject: [PATCH 3/5] Do not try to create file watchers for RAIDs without + redundancy + +We are trying to watch 'md/degraded' and 'md/sync_action' sysfs +files for all RAIDs but these files exist only for RAIDs with +redundancy -- we shouldn't do this for raid0, containers and linear +RAIDs. + +Resolves: rhbz#1400056 +Signed-off-by: Vratislav Podzimek +--- + src/udiskslinuxmdraidobject.c | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/src/udiskslinuxmdraidobject.c b/src/udiskslinuxmdraidobject.c +index 493145e..1d2f07a 100644 +--- a/src/udiskslinuxmdraidobject.c ++++ b/src/udiskslinuxmdraidobject.c +@@ -30,6 +30,7 @@ + #include "udisksdaemonutil.h" + #include "udiskslinuxprovider.h" + #include "udiskslinuxmdraidobject.h" ++#include "udiskslinuxmdraidhelpers.h" + #include "udiskslinuxmdraid.h" + #include "udiskslinuxblockobject.h" + #include "udiskslinuxdevice.h" +@@ -552,9 +553,18 @@ static void + raid_device_added (UDisksLinuxMDRaidObject *object, + UDisksLinuxDevice *device) + { ++ gchar *level = NULL; ++ + g_assert (object->sync_action_source == NULL); + g_assert (object->degraded_source == NULL); + ++ if (!UDISKS_IS_LINUX_DEVICE (device)) ++ goto out; ++ ++ level = read_sysfs_attr (device->udev_device, "md/level"); ++ if (level == NULL || !mdraid_has_redundancy (level)) ++ goto out; ++ + /* udisks_debug ("start watching %s", g_udev_device_get_sysfs_path (device->udev_device)); */ + object->sync_action_source = watch_attr (device, + "md/sync_action", +@@ -564,6 +574,9 @@ raid_device_added (UDisksLinuxMDRaidObject *object, + "md/degraded", + (GSourceFunc) attr_changed, + object); ++ ++ out: ++ g_free (level); + } + + static void +@@ -684,6 +697,12 @@ udisks_linux_mdraid_object_uevent (UDisksLinuxMDRaidObject *object, + object->raid_device = g_object_ref (device); + raid_device_added (object, object->raid_device); + } ++ else if (object->sync_action_source == NULL && object->degraded_source == NULL) ++ { ++ /* we don't have file watchers, adding them may failed because ++ we were unable to get raid level, let's try again */ ++ raid_device_added (object, object->raid_device); ++ } + } + } + } +-- +2.9.5 + +From ab6ee79abac6a75eddd0ecfba7fc5111663bc50f Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Mon, 16 Oct 2017 15:26:16 +0200 +Subject: [PATCH 5/5] Try to use libblockdev to get RAID array size + +If reading size from sysfs fails, try to use libblockdev to read +it from mdadm --examine data. + +Signed-off-by: Vratislav Podzimek +--- + src/udiskslinuxmdraid.c | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +diff --git a/src/udiskslinuxmdraid.c b/src/udiskslinuxmdraid.c +index 22b4ee4..6c94a2b 100644 +--- a/src/udiskslinuxmdraid.c ++++ b/src/udiskslinuxmdraid.c +@@ -246,6 +246,8 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid *mdraid, + GVariantBuilder builder; + UDisksDaemon *daemon = NULL; + UDisksBaseJob *job = NULL; ++ GError *error = NULL; ++ BDMDExamineData *raid_data = NULL; + + daemon = udisks_linux_mdraid_object_get_daemon (object); + +@@ -303,7 +305,15 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid *mdraid, + } + else + { +- /* TODO: need MD_ARRAY_SIZE, see https://bugs.freedesktop.org/show_bug.cgi?id=53239#c5 */ ++ raid_data = bd_md_examine (g_udev_device_get_device_file (device->udev_device), ++ &error); ++ if (raid_data == NULL) ++ { ++ udisks_debug ("Failed to read array size: %s", error->message); ++ g_clear_error (&error); ++ } ++ else ++ size = raid_data->size; + } + + udisks_mdraid_set_uuid (iface, uuid); +@@ -523,11 +533,14 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid *mdraid, + uuid)); + + out: ++ if (raid_data) ++ bd_md_examine_data_free (raid_data); + g_free (sync_completed); + g_free (sync_action); + g_free (bitmap_location); + g_list_free_full (member_devices, g_object_unref); + g_clear_object (&raid_device); ++ g_clear_error (&error); + return ret; + } + +-- +2.9.5 + diff --git a/SOURCES/reboot_mpoint_cleanup_1384796.patch b/SOURCES/reboot_mpoint_cleanup_1384796.patch new file mode 100644 index 0000000..2b68e95 --- /dev/null +++ b/SOURCES/reboot_mpoint_cleanup_1384796.patch @@ -0,0 +1,212 @@ +From 6121d5437d7800876567fd08b6020ca1d72eeaac Mon Sep 17 00:00:00 2001 +From: Vratislav Podzimek +Date: Fri, 20 Oct 2017 13:24:20 +0200 +Subject: [PATCH] Add and use a service for cleaning up mount point directories + +When udisks2 is used for mounting devices, it may need to create +the mount point directory. If unmount happens later, udisks2 +cleans after itself and removes the mount point +directory. However, if the unmount happens during reboot, the +udisks2 daemon may already be terminated not having a chance to +do the cleanup. We need a different mechanism to do the job in +such cases. + +systemd provides us with such a mechanism so let's make use of +it. + +Resolves: rhbz#1384796 +Signed-off-by: Vratislav Podzimek +--- + data/Makefile.am | 6 ++-- + data/clean-mount-point@.service | 10 +++++++ + packaging/udisks2.spec | 1 + + src/Makefile.am | 3 +- + src/udiskslinuxfilesystem.c | 61 +++++++++++++++++++++++++++++++++++++++-- + 5 files changed, 74 insertions(+), 7 deletions(-) + create mode 100644 data/clean-mount-point@.service + +diff --git a/data/Makefile.am b/data/Makefile.am +index 83af330..9b8073a 100644 +--- a/data/Makefile.am ++++ b/data/Makefile.am +@@ -15,14 +15,14 @@ dbusconf_DATA = $(dbusconf_in_files:.conf.in=.conf) + $(dbusconf_DATA): $(dbusconf_in_files) Makefile + cp $< $@ + +-systemdservice_in_files = udisks2.service.in ++systemdservice_in_files = udisks2.service.in clean-mount-point@.service + + if HAVE_SYSTEMD + systemdservicedir = $(systemdsystemunitdir) + systemdservice_DATA = $(systemdservice_in_files:.service.in=.service) + +-$(systemdservice_DATA): $(systemdservice_in_files) Makefile +- @sed -e "s|\@udisksdprivdir\@|$(libexecdir)/udisks2|" $< > $@ ++$(systemdservice_DATA): udisks2.service.in Makefile ++ @sed -e "s|\@udisksdprivdir\@|$(libexecdir)/udisks2|" udisks2.service.in > udisks2.service + endif + + udevrulesdir = $(udevdir)/rules.d +diff --git a/data/clean-mount-point@.service b/data/clean-mount-point@.service +new file mode 100644 +index 0000000..83edceb +--- /dev/null ++++ b/data/clean-mount-point@.service +@@ -0,0 +1,10 @@ ++[Unit] ++Description=Clean the %f mount point ++Before=%i.mount ++BindsTo=%i.mount ++DefaultDependencies=no ++ ++[Service] ++Type=oneshot ++RemainAfterExit=true ++ExecStop=/bin/rm -fd %f +diff --git a/src/Makefile.am b/src/Makefile.am +index 396ab4e..3b22cca 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -113,7 +113,8 @@ libudisks_daemon_la_LIBADD = \ + $(GIO_LIBS) \ + $(GMODULE_LIBS) \ + $(GUDEV_LIBS) \ +- $(BLOCKDEV_LIBS) \ ++ $(BLOCKDEV_LIBS) \ ++ -lbd_utils \ + $(LIBATASMART_LIBS) \ + $(POLKIT_GOBJECT_1_LIBS) \ + $(ACL_LIBS) \ +diff --git a/src/udiskslinuxfilesystem.c b/src/udiskslinuxfilesystem.c +index 4cd2784..2910181 100644 +--- a/src/udiskslinuxfilesystem.c ++++ b/src/udiskslinuxfilesystem.c +@@ -86,9 +86,11 @@ G_DEFINE_TYPE_WITH_CODE (UDisksLinuxFilesystem, udisks_linux_filesystem, UDISKS_ + G_IMPLEMENT_INTERFACE (UDISKS_TYPE_FILESYSTEM, filesystem_iface_init)); + + #ifdef HAVE_FHS_MEDIA +-# define MOUNT_BASE "/media" ++#define MOUNT_BASE "/media" ++#define MOUNT_BASE_PERSISTENT TRUE + #else +-# define MOUNT_BASE "/run/media" ++#define MOUNT_BASE "/run/media" ++#define MOUNT_BASE_PERSISTENT FALSE + #endif + + /* ---------------------------------------------------------------------------------------------------- */ +@@ -833,6 +835,7 @@ add_acl (const gchar *path, + * @gid: group id of the calling user + * @user_name: user name of the calling user + * @fs_type: The file system type to mount with ++ * @persistent: if the mount point is persistent (survives reboot) or not + * @error: Return location for error or %NULL. + * + * Calculates the mount point to use. +@@ -846,6 +849,7 @@ calculate_mount_point (UDisksDaemon *daemon, + gid_t gid, + const gchar *user_name, + const gchar *fs_type, ++ gboolean *persistent, + GError **error) + { + UDisksLinuxBlockObject *object = NULL; +@@ -889,6 +893,7 @@ calculate_mount_point (UDisksDaemon *daemon, + if (!fs_shared && (user_name != NULL && strstr (user_name, "/") == NULL)) + { + mount_dir = g_strdup_printf (MOUNT_BASE "/%s", user_name); ++ *persistent = MOUNT_BASE_PERSISTENT; + if (!g_file_test (mount_dir, G_FILE_TEST_EXISTS)) + { + /* First ensure that MOUNT_BASE exists */ +@@ -933,8 +938,10 @@ calculate_mount_point (UDisksDaemon *daemon, + } + } + /* otherwise fall back to mounting in /media */ +- if (mount_dir == NULL) ++ if (mount_dir == NULL) { + mount_dir = g_strdup ("/media"); ++ *persistent = TRUE; ++ } + + /* NOTE: UTF-8 has the nice property that valid UTF-8 strings only contains + * the byte 0x2F if it's for the '/' character (U+002F SOLIDUS). +@@ -1135,6 +1142,49 @@ is_system_managed (UDisksBlock *block, + return ret; + } + ++static void trigger_mpoint_cleanup (const gchar *mount_point) ++{ ++ const gchar *argv[] = {"systemctl", "start", NULL, NULL}; ++ GError *error = NULL; ++ gchar *escaped_mpoint = NULL; ++ gsize len = 0; ++ ++ if (g_str_has_prefix (mount_point, "/")) ++ mount_point++; ++ else ++ udisks_warning ("Invalid mount point given to trigger_mpoint_cleanup(): %s", ++ mount_point); ++ ++ /* start with the mount point without the leading '/' */ ++ escaped_mpoint = g_strdup (mount_point); ++ ++ /* and replace all '/'s with '-'s */ ++ for (gchar *letter = escaped_mpoint; *letter != '\0'; letter++, len++) ++ { ++ if (*letter == '/') ++ *letter = '-'; ++ } ++ ++ /* remove the potential trailing '-' (would happen if the given mount_point ++ has a trailing '/') */ ++ if (escaped_mpoint[len - 1] == '-') ++ escaped_mpoint[len - 1] = '\0'; ++ ++ argv[2] = g_strdup_printf ("clean-mount-point@%s", escaped_mpoint); ++ ++ if (!bd_utils_exec_and_report_error (argv, NULL, &error) && (error != NULL)) ++ { ++ /* this is a best-effort mechanism, if it fails, just log warning and move ++ on */ ++ udisks_warning ("Failed to setup systemd-based mount point cleanup: %s", ++ error->message); ++ g_clear_error (&error); ++ } ++ ++ g_free (escaped_mpoint); ++ g_free ((gchar *) argv[2]); ++} ++ + /* ---------------------------------------------------------------------------------------------------- */ + + /* runs in thread dedicated to handling @invocation */ +@@ -1154,6 +1204,7 @@ handle_mount (UDisksFilesystem *filesystem, + gchar *fs_type_to_use = NULL; + gchar *mount_options_to_use = NULL; + gchar *mount_point_to_use = NULL; ++ gboolean mpoint_persistent = TRUE; + gchar *fstab_mount_options = NULL; + gchar *caller_user_name = NULL; + GError *error = NULL; +@@ -1443,6 +1494,7 @@ handle_mount (UDisksFilesystem *filesystem, + caller_gid, + caller_user_name, + fs_type_to_use, ++ &mpoint_persistent, + &error); + if (mount_point_to_use == NULL) + { +@@ -1487,6 +1539,9 @@ handle_mount (UDisksFilesystem *filesystem, + else + udisks_simple_job_complete (UDISKS_SIMPLE_JOB (job), TRUE, NULL); + ++ if (mpoint_persistent) ++ trigger_mpoint_cleanup (mount_point_to_use); ++ + /* update the mounted-fs file */ + udisks_state_add_mounted_fs (state, + mount_point_to_use, +-- +2.9.5 + diff --git a/SPECS/udisks2.spec b/SPECS/udisks2.spec new file mode 100644 index 0000000..ee106fb --- /dev/null +++ b/SPECS/udisks2.spec @@ -0,0 +1,414 @@ +%global glib2_version 2.36 +%global gobject_introspection_version 1.30.0 +%global polkit_version 0.102 +%global systemd_version 208 +%global libatasmart_version 0.17 +%global dbus_version 1.4.0 +%global with_gtk_doc 1 +%global libblockdev_version 2.10 + +%define is_git %(git show > /dev/null 2>&1 && echo 1 || echo 0) +%define git_hash %(git log -1 --pretty=format:"%h" || true) +%define build_date %(date '+%Y%m%d') + +Name: udisks2 +Summary: Disk Manager +Version: 2.7.3 +Release: 6%{?dist} +License: GPLv2+ +Group: System Environment/Libraries +URL: https://github.com/storaged-project/udisks +Source0: https://github.com/storaged-project/udisks/releases/download/udisks-%{version}/udisks-%{version}.tar.bz2 + +Patch0: reboot_mpoint_cleanup_1384796.patch +Patch1: raid_watchers_1400056.patch +Patch2: no_discard_1516697.patch +Patch3: fix_thinpool_size_1534904.patch +Patch4: fix_mpoin_cleanup_1384796.patch + +BuildRequires: glib2-devel >= %{glib2_version} +BuildRequires: gobject-introspection-devel >= %{gobject_introspection_version} +BuildRequires: libgudev1-devel >= %{systemd_version} +BuildRequires: libatasmart-devel >= %{libatasmart_version} +BuildRequires: polkit-devel >= %{polkit_version} +BuildRequires: systemd-devel >= %{systemd_version} +BuildRequires: gnome-common +BuildRequires: libacl-devel +BuildRequires: chrpath +BuildRequires: gtk-doc +BuildRequires: intltool +BuildRequires: redhat-rpm-config +BuildRequires: libblockdev-devel >= %{libblockdev_version} +BuildRequires: libblockdev-part-devel >= %{libblockdev_version} +BuildRequires: libblockdev-loop-devel >= %{libblockdev_version} +BuildRequires: libblockdev-swap-devel >= %{libblockdev_version} +BuildRequires: libblockdev-mdraid-devel >= %{libblockdev_version} +BuildRequires: libblockdev-fs-devel >= %{libblockdev_version} +BuildRequires: libblockdev-crypto-devel >= %{libblockdev_version} + +Requires: libblockdev >= %{libblockdev_version} +Requires: libblockdev-part >= %{libblockdev_version} +Requires: libblockdev-loop >= %{libblockdev_version} +Requires: libblockdev-swap >= %{libblockdev_version} +Requires: libblockdev-mdraid >= %{libblockdev_version} +Requires: libblockdev-fs >= %{libblockdev_version} +Requires: libblockdev-crypto >= %{libblockdev_version} + +# Needed for the systemd-related macros used in this file +%{?systemd_requires} +BuildRequires: systemd + +# Needed to pull in the system bus daemon +Requires: dbus >= %{dbus_version} +# Needed to pull in the udev daemon +Requires: udev >= %{systemd_version} +# We need at least this version for bugfixes/features etc. +Requires: libatasmart >= %{libatasmart_version} +# For mount, umount, mkswap +Requires: util-linux +# For mkfs.ext3, mkfs.ext3, e2label +Requires: e2fsprogs +# For mkfs.xfs, xfs_admin +Requires: xfsprogs +# For mkfs.vfat +Requires: dosfstools +Requires: gdisk +# For ejecting removable disks +Requires: eject + +Requires: lib%{name}%{?_isa} = %{version}-%{release} + +# For mkntfs (not available on rhel or on ppc/ppc64) +%if ! 0%{?rhel} +%ifnarch ppc ppc64 +Requires: ntfsprogs +%endif +%endif + +Obsoletes: storaged + +%description +The Udisks project provides a daemon, tools and libraries to access and +manipulate disks, storage devices and technologies. + +%package -n lib%{name} +Summary: Dynamic library to access the udisksd daemon +Group: System Environment/Libraries +License: LGPLv2+ +Obsoletes: libstoraged + +%description -n lib%{name} +This package contains the dynamic library, which provides +access to the udisksd daemon. + +%package -n %{name}-iscsi +Summary: Module for iSCSI +Group: System Environment/Libraries +Requires: %{name}%{?_isa} = %{version}-%{release} +License: LGPLv2+ +Requires: iscsi-initiator-utils +BuildRequires: iscsi-initiator-utils-devel +Obsoletes: storaged-iscsi + +%description -n %{name}-iscsi +This package contains module for iSCSI configuration. + +%package -n %{name}-lvm2 +Summary: Module for LVM2 +Group: System Environment/Libraries +Requires: %{name}%{?_isa} = %{version}-%{release} +License: LGPLv2+ +Requires: lvm2 +Requires: libblockdev-lvm >= %{libblockdev_version} +BuildRequires: lvm2-devel +BuildRequires: libblockdev-lvm-devel >= %{libblockdev_version} +Obsoletes: storaged-lvm2 + +%description -n %{name}-lvm2 +This package contains module for LVM2 configuration. + +%package -n lib%{name}-devel +Summary: Development files for lib%{name} +Group: Development/Libraries +Requires: lib%{name}%{?_isa} = %{version}-%{release} +License: LGPLv2+ +Obsoletes: libstoraged-devel + +%description -n lib%{name}-devel +This package contains the development files for the library lib%{name}, a +dynamic library, which provides access to the udisksd daemon. + +%prep +%setup -q -n udisks-%{version} +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 + +%build +autoreconf -ivf +# we can't use _hardened_build here, see +# https://bugzilla.redhat.com/show_bug.cgi?id=892837 +export CFLAGS='-fPIC %optflags' +export LDFLAGS='-pie -Wl,-z,now -Wl,-z,relro' +%configure \ + --sysconfdir=/etc \ + --enable-iscsi \ + --enable-lvm2 \ +%if %{with_gtk_doc} + --enable-gtk-doc +%else + --disable-gtk-doc +%endif +make %{?_smp_mflags} + +%install +make install DESTDIR=%{buildroot} +%if %{with_gtk_doc} == 0 +rm -fr %{buildroot}/%{_datadir}/gtk-doc/html/udisks2 +%endif + +find %{buildroot} -name \*.la -o -name \*.a | xargs rm + +chrpath --delete %{buildroot}/%{_sbindir}/umount.udisks2 +chrpath --delete %{buildroot}/%{_bindir}/udisksctl +chrpath --delete %{buildroot}/%{_libexecdir}/udisks2/udisksd + +%find_lang udisks2 + +%post -n %{name} +%systemd_post udisks2.service +%systemd_post clean-mount-point@.service +udevadm control --reload +udevadm trigger + +%preun -n %{name} +%systemd_preun udisks2.service +%systemd_preun clean-mount-point@.service + +%postun -n %{name} +%systemd_postun_with_restart udisks2.service +%systemd_postun_with_restart clean-mount-point@.service + +%post -n lib%{name} -p /sbin/ldconfig + +%postun -n lib%{name} -p /sbin/ldconfig + +%files -f udisks2.lang +%doc README.md AUTHORS NEWS HACKING +%license COPYING + +%dir %{_sysconfdir}/udisks2 +%{_sysconfdir}/udisks2/udisks2.conf + +%{_sysconfdir}/dbus-1/system.d/org.freedesktop.UDisks2.conf +%{_datadir}/bash-completion/completions/udisksctl +%{_unitdir}/udisks2.service +%{_unitdir}/clean-mount-point@.service +%{_udevrulesdir}/80-udisks2.rules +%{_sbindir}/umount.udisks2 + + +%dir %{_libdir}/udisks2 +%dir %{_libdir}/udisks2/modules +%dir %{_libexecdir}/udisks2 +%{_libexecdir}/udisks2/udisksd + +%{_bindir}/udisksctl + +%{_mandir}/man1/udisksctl.1* +%{_mandir}/man5/udisks2.conf.5* +%{_mandir}/man8/udisksd.8* +%{_mandir}/man8/udisks.8* +%{_mandir}/man8/umount.udisks2.8* + +%{_datadir}/polkit-1/actions/org.freedesktop.UDisks2.policy +%{_datadir}/dbus-1/system-services/org.freedesktop.UDisks2.service + +# Permissions for local state data are 0700 to avoid leaking information +# about e.g. mounts to unprivileged users +%attr(0700,root,root) %dir %{_localstatedir}/lib/udisks2 + +%files -n lib%{name} +%{_libdir}/libudisks2.so.* +%{_libdir}/girepository-1.0/UDisks-2.0.typelib + +%files -n %{name}-lvm2 +%{_libdir}/udisks2/modules/libudisks2_lvm2.so +%{_datadir}/polkit-1/actions/org.freedesktop.UDisks2.lvm2.policy + +%files -n %{name}-iscsi +%{_libdir}/udisks2/modules/libudisks2_iscsi.so +%{_datadir}/polkit-1/actions/org.freedesktop.UDisks2.iscsi.policy + +%files -n lib%{name}-devel +%{_libdir}/libudisks2.so +%dir %{_includedir}/udisks2 +%dir %{_includedir}/udisks2/udisks +%{_includedir}/udisks2/udisks/*.h +%{_datadir}/gir-1.0/UDisks-2.0.gir +%if %{with_gtk_doc} +%dir %{_datadir}/gtk-doc/html/udisks2 +%{_datadir}/gtk-doc/html/udisks2/* +%endif +%{_libdir}/pkgconfig/udisks2.pc + +# Note: please don't forget the %{?dist} in the changelog. Thanks +%changelog +* Tue Feb 06 2018 Vojtech Trefny - 2.7.3-6 +- Fix escaping mountpoint for the cleanup service + Related: rhbz#1384796 + +* Mon Feb 05 2018 Vojtech Trefny - 2.7.3-5 +- lvm2: Don't match prefixes in cmp_int_lv_name + Resolves: rhbz#1534904 + +* Thu Nov 30 2017 Vratislav Podzimek - 2.7.3-4 +- Add 'no-discard' option to formatting methods (mvollmer) + Resolves: rhbz#1516697 + +* Mon Oct 23 2017 Vratislav Podzimek - 2.7.3-3 +- Add and use a service for cleaning up mount point directories + Resolves: rhbz#1384796 +- Do not try to create file watchers for RAIDs without redundancy + Resolves: rhbz#1400056 + +* Thu Oct 19 2017 Vratislav Podzimek - 2.7.3-2 +- Put back the hack to ensure hardening + Related: rhbz#1477736 +- Fix the relationship between new udisks2 and storaged + Related: rhbz#1477736 + +* Thu Oct 12 2017 Vratislav Podzimek - 2.7.3-1 +- Rebase to upstream version 2.7.3 + Resolves: rhbz#1477736 + +* Wed May 13 2015 Tomas Smetana - 2.1.2-6 +- Rename the Intel SW RAID (#1175225) +- Resolves: rhbz#1175225 + +* Wed Feb 26 2014 Jan Safranek - 2.1.2-5 +- Fix CVE-2014-0004: stack-based buffer overflow when handling long path names + (#1070144) + +* Fri Jan 24 2014 Daniel Mach - 2.1.2-4 +- Mass rebuild 2014-01-24 + +* Wed Jan 22 2014 Tomas Bzatek - 2.1.2-3%{?dist} +- Fix upgrade path from old udisks + +* Wed Jan 22 2014 Tomas Bzatek - 2.1.2-2%{?dist} +- Fix crash when loop-deleting non-loop device (#1036076) +- Fix some thread safety issues (#1036099) +- Fix lingering mount after CD-ROM drive is ejected (#835120) +- Fix some uninitializes variables (#1056580) + +* Thu Jan 16 2014 Tomas Bzatek - 2.1.2-1%{?dist} +- Update to 2.1.2 + +* Fri Dec 27 2013 Daniel Mach - 2.1.0-5 +- Mass rebuild 2013-12-27 + +* Thu Jul 25 2013 Tomas Bzatek - 2.1.0-4%{?dist} +- Add a man page for umount.udisks2 (#948926) + +* Tue Jul 02 2013 Tomas Bzatek - 2.1.0-3%{?dist} +- Sync with recent upstream changes +- Add Provides/Obsoletes udisks (#976796) + +* Thu Mar 28 2013 Tomas Bzatek - 2.1.0-2%{?dist} +- Fix firewire drives identification (#909010) + +* Wed Mar 20 2013 Kalev Lember - 2.1.0-1 +- Update to 2.1.0 + +* Fri Feb 15 2013 Fedora Release Engineering - 2.0.91-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Tue Jan 22 2013 Matthias Clasen - 2.0.91-2%{?dist} +- Hardened build + +* Mon Jan 07 2013 David Zeuthen - 2.0.91-1%{?dist} +- Update to release 2.0.91 + +* Tue Dec 18 2012 David Zeuthen - 2.0.90-1%{?dist} +- Update to release 2.0.90 + +* Fri Oct 02 2012 David Zeuthen - 2.0.0-1%{?dist} +- Update to release 2.0.0 + +* Fri Jul 27 2012 David Zeuthen - 1.99.0-1%{?dist} +- Update to release 1.99.0 + +* Sun Jul 22 2012 Fedora Release Engineering - 1.98.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Thu Jun 07 2012 David Zeuthen - 1.98.0-1%{?dist} +- Update to release 1.98.0 + +* Mon Jun 04 2012 Kay Sievers - 1.97.0-4 +- rebuild for libudev1 + +* Tue May 22 2012 Peter Robinson - 1.97.0-3 +- Add upstream patch to fix issue with rootfs being on a bound mount + +* Fri May 18 2012 Matthias Clasen - 1.97.0-2%{?dist} +- Add a Requires for eject (#810882) + +* Wed May 09 2012 David Zeuthen - 1.97.0-1%{?dist} +- Update to release 1.97.0 + +* Thu May 03 2012 David Zeuthen - 1.96.0-2%{?dist} +- Include patch so Fedora Live media is shown + +* Mon Apr 30 2012 David Zeuthen - 1.96.0-1%{?dist} +- Update to release 1.96.0 + +* Mon Apr 30 2012 David Zeuthen - 1.95.0-3%{?dist} +- BR: gnome-common + +* Mon Apr 30 2012 David Zeuthen - 1.95.0-2%{?dist} +- Make daemon actually link with libsystemd-login + +* Mon Apr 30 2012 David Zeuthen - 1.95.0-1%{?dist} +- Update to release 1.95.0 + +* Tue Apr 10 2012 David Zeuthen - 1.94.0-1%{?dist} +- Update to release 1.94.0 + +* Tue Apr 03 2012 David Zeuthen - 1.93.0-2%{?dist} +- Don't inadvertently unmount large block devices (fdo #48155) + +* Mon Mar 05 2012 David Zeuthen - 1.93.0-1%{?dist} +- Update to release 1.93.0 + +* Thu Feb 23 2012 David Zeuthen - 1.92.0-2%{?dist} +- Fix build + +* Thu Feb 23 2012 David Zeuthen - 1.92.0-1%{?dist} +- Update to release 1.92.0 + +* Wed Feb 22 2012 David Zeuthen - 1.91.0-2%{?dist} +- Avoid using $XDG_RUNTIME_DIR/media for now + +* Mon Feb 06 2012 David Zeuthen - 1.91.0-1%{?dist} +- Update to release 1.91.0 + +* Fri Jan 21 2012 David Zeuthen - 1.90.0-3%{?dist} +- Manually set PATH, if not set + +* Fri Jan 20 2012 David Zeuthen - 1.90.0-2%{?dist} +- Rebuild + +* Fri Jan 20 2012 David Zeuthen - 1.90.0-1%{?dist} +- Update to release 1.90.0 + +* Sat Jan 14 2012 Fedora Release Engineering - 1.90.0-0.git20111128.1 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Mon Nov 28 2011 David Zeuthen - 1.90.0-0.git20111128%{?dist} +- Updated for review comments (#756046) + +* Mon Nov 22 2011 David Zeuthen - 1.90.0-0.git20111122%{?dist} +- Initial packaging of udisks2