Hello community,

here is the log from the commit of package parted for openSUSE:Factory checked 
in at 2017-11-25 08:40:24
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/parted (Old)
 and      /work/SRC/openSUSE:Factory/.parted.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "parted"

Sat Nov 25 08:40:24 2017 rev:120 rq:544142 version:3.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/parted/parted.changes    2017-11-16 
13:57:43.372781439 +0100
+++ /work/SRC/openSUSE:Factory/.parted.new/parted.changes       2017-11-25 
08:40:26.191116189 +0100
@@ -1,0 +2,15 @@
+Tue Nov 21 09:26:23 UTC 2017 - sebastian.parscha...@suse.com
+
+- Fix the resizepart and rm command (bsc#1058667)
+  - fix asking for the partition end for resizepart in interactive mode
+    when the partition is busy
+  - allow resizepart shrinking and rm of busy partitions in script mode
+    by adding the --ignore-busy option
+  - allow growing busy partitions in script mode by default
+  - print a warning when shrinking a non-busy partition in script mode
+  - fix help text printing of long options without short option
+  - remove: parted-do-not-warn-when-shrinking-in-script-mode.patch
+  - add: parted-add-ignore-busy-option.patch
+  - add: parted-fix-resizepart-and-rm-command.patch
+
+-------------------------------------------------------------------

Old:
----
  parted-do-not-warn-when-shrinking-in-script-mode.patch

New:
----
  parted-add-ignore-busy-option.patch
  parted-fix-resizepart-and-rm-command.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ parted.spec ++++++
--- /var/tmp/diff_new_pack.DIMYyN/_old  2017-11-25 08:40:27.239078007 +0100
+++ /var/tmp/diff_new_pack.DIMYyN/_new  2017-11-25 08:40:27.243077862 +0100
@@ -52,7 +52,7 @@
 # Remove following compatibility patch once bnc#931765 is resolved
 Patch29:        parted-resize-alias-to-resizepart.patch
 Patch30:        libparted-avoid-libdevice-mapper-warnings.patch
-Patch31:        parted-do-not-warn-when-shrinking-in-script-mode.patch
+# Patch31 dropped for bsc#1058667
 Patch32:        libparted-Use-read-only-when-probing-devices-on-linu.patch
 Patch33:        libparted-open-the-device-RO-and-lazily-switch-to-RW.patch
 Patch34:        parted-implement-wipesignatures-option.patch
@@ -83,6 +83,8 @@
 Patch55:        libparted-Add-support-for-NVDIMM-devices.patch
 Patch56:        libparted-fix-NVDIMM-partition-naming.patch
 Patch57:        parted-escape-printed-device-path.patch
+Patch58:        parted-add-ignore-busy-option.patch
+Patch59:        parted-fix-resizepart-and-rm-command.patch
 # Fatresize
 Patch100:       parted-fatresize-autoconf.patch
 # Upstream tests patches
@@ -163,7 +165,6 @@
 %patch28 -p1
 %patch29 -p1
 %patch30 -p1
-%patch31 -p1
 %patch32 -p1
 %patch33 -p1
 %patch34 -p1
@@ -190,6 +191,8 @@
 %patch55 -p1
 %patch56 -p1
 %patch57 -p1
+%patch58 -p1
+%patch59 -p1
 %patch100 -p1
 %patch150 -p1
 %patch151 -p1


++++++ parted-add-ignore-busy-option.patch ++++++
From: Sebastian Parschauer <sparscha...@suse.de>
Date: Mon, 20 Nov 2017 18:01:56 +0100
Subject: parted: Add '--ignore-busy' option
References: bsc#1058667
Patch-mainline: not yet, based on v3 submitted on 2017-11-07

There are dangerous actions like e.g. shrinking or removing a busy
partition which should be possible in script mode but not without
using an option to enforce that. This is meant to prevent buggy
scripts from doing those actions unintentionally.

Also add proper printing of the help text for a long option without
a short option.

Suggested-by: Phillip Susi <ps...@ubuntu.com>
Signed-off-by: Sebastian Parschauer <sparscha...@suse.de>
---
 doc/C/parted.8  |  3 +++
 parted/parted.c | 16 ++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/doc/C/parted.8 b/doc/C/parted.8
index e2a24dc..ff01162 100644
--- a/doc/C/parted.8
+++ b/doc/C/parted.8
@@ -30,6 +30,9 @@ never prompts for user intervention
 .B -v, --version
 displays the version
 .TP
+.B --ignore-busy
+perform the requested action in script mode although a partition is busy
+.TP
 .B --wipesignatures
 mkpart wipes the superblock signatures from the disk region where it is
 about to create the partition
diff --git a/parted/parted.c b/parted/parted.c
index 3d7ec4b..3cc8f77 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -76,7 +76,8 @@ static int MEGABYTE_SECTORS (PedDevice* dev)
 enum
 {
   PRETEND_INPUT_TTY = CHAR_MAX + 1,
-  WIPESIGNATURES = CHAR_MAX + 2,
+  IGNORE_BUSY = CHAR_MAX + 2,
+  WIPESIGNATURES = CHAR_MAX + 3,
 };
 
 enum
@@ -118,6 +119,7 @@ static struct option const options[] = {
         {"script",      0, NULL, 's'},
         {"version",     0, NULL, 'v'},
         {"align",       required_argument, NULL, 'a'},
+        {"ignore-busy", 0, NULL, IGNORE_BUSY},
         {"wipesignatures", 0, NULL, WIPESIGNATURES},
         {"-pretend-input-tty", 0, NULL, PRETEND_INPUT_TTY},
         {NULL,          0, NULL, 0}
@@ -130,10 +132,13 @@ static const char *const options_help [][2] = {
         {"script",      N_("never prompts for user intervention")},
         {"version",     N_("displays the version")},
         {"align=[none|cyl|min|opt]", N_("alignment for new partitions")},
+        {"ignore-busy",    N_("perform action although partition is busy")},
         {"wipesignatures", N_("wipe superblock signatures when creating 
partition")},
         {NULL,          NULL}
 };
 
+#define LONGOPT_HELP_START 6  /* index to first long option help */
+
 int     opt_script_mode = 0;
 int     pretend_input_tty = 0;
 int     wipesignatures = 0;
@@ -141,6 +146,7 @@ int     opt_machine_mode = 0;
 int     disk_is_modified = 0;
 int     is_toggle_mode = 0;
 int     alignment = ALIGNMENT_OPTIMAL;
+int     ignore_busy = 0;
 
 static const char* number_msg = N_(
 "NUMBER is the partition number used by Linux.  On MS-DOS disk labels, the "
@@ -513,12 +519,17 @@ print_options_help ()
 {
         int             i;
 
-        for (i=0; options_help [i][0]; i++) {
+        for (i=0; i < LONGOPT_HELP_START; i++) {
                 printf ("  -%c, --%-25.25s %s\n",
                         options_help [i][0][0],
                         options_help [i][0],
                         _(options_help [i][1]));
         }
+        for (i=LONGOPT_HELP_START; options_help [i][0]; i++) {
+                printf ("  --%-29.25s %s\n",
+                        options_help [i][0],
+                        _(options_help [i][1]));
+        }
 }
 
 int
@@ -2244,6 +2255,7 @@ while (1)
                   alignment = XARGMATCH ("--align", optarg,
                                          align_args, align_types);
                   break;
+                case IGNORE_BUSY: ignore_busy = 1; break;
                 case PRETEND_INPUT_TTY:
                   pretend_input_tty = 1;
                   break;
++++++ parted-fix-resizepart-and-rm-command.patch ++++++
From: Sebastian Parschauer <sparscha...@suse.de>
Date: Tue, 7 Nov 2017 14:09:46 +0100
Subject: parted: Fix resizepart and rm command
References: bsc#1058667
Patch-mainline: not yet, based on v3 submitted on 2017-11-07

In script mode the resizepart command fails when shrinking and
if the partition is busy. Also the warnings printed in this
case are only applicable to interactive mode. A similar problem
exists with the rm command.
So print different warnings in script mode and continue if growing
a busy partition. Require the '--ignore-busy' option to be set in
order to shrink or remove a busy partition. Shrinking cannot be
more dangerous in script mode than removing. So allow shrinking a
partition in script mode which is not busy.

In interactive mode there is a problem if providing the partition
number and the end of the partition as arguments to the resizepart
command directly with a busy partition. The warning is shown and
after continuing anyway parted asks for the partition end although
it has already been provided. So count the number of words on
command line and warn after processing all of them or after getting
the partition number.

Fixes: 21c58e17c473 ("parted: add resizepart command")
Reported-by: Arvin Schnell <aschn...@suse.com>
Signed-off-by: Sebastian Parschauer <sparscha...@suse.de>
---
 parted/parted.c | 39 ++++++++++++++++++++++++++++++++-------
 2 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/parted/parted.c b/parted/parted.c
index 3cc8f77..2e31659 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -228,13 +228,19 @@ _timer_handler (PedTimer* timer, void* context)
 }
 
 static int
-_partition_warn_busy (PedPartition* part)
+_partition_warn_busy (PedPartition* part, bool dangerous)
 {
         char* path;
 
         if (ped_partition_is_busy (part)) {
                 path = ped_partition_get_path (part);
-                if (ped_exception_throw (
+                if (opt_script_mode && (!dangerous || ignore_busy)) {
+                        ped_exception_throw (
+                            PED_EXCEPTION_WARNING,
+                            PED_EXCEPTION_UNHANDLED,
+                            _("Partition %s is being used, continuing 
anyway."),
+                            path);
+                } else if (ped_exception_throw (
                             PED_EXCEPTION_WARNING,
                             PED_EXCEPTION_YES_NO,
                             _("Partition %s is being used. Are you sure you " \
@@ -1634,6 +1640,11 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
         PedSector               start, end, oldend;
         PedGeometry             *range_end = NULL;
         PedConstraint*          constraint;
+        int                     cmdline_words = command_line_get_word_count();
+        /* update this if adding/removing arguments to/from this command */
+        const int               part_idx = 1;
+        const int               end_idx = 2;
+        const bool              danger_if_busy = false;
         int rc = 0;
 
         if (!disk) {
@@ -1650,26 +1661,39 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
 
         if (!command_line_get_partition (_("Partition number?"), disk, &part))
                 goto error;
-        if (!_partition_warn_busy (part))
+        /* warn early if the partition end is not provided on cmdline */
+        if (cmdline_words <= part_idx && !_partition_warn_busy (part, 
danger_if_busy))
                 goto error;
-
         start = part->geom.start;
         end = oldend = part->geom.end;
         if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, NULL))
                 goto error;
+        if (cmdline_words >= end_idx && !_partition_warn_busy (part, 
danger_if_busy))
+                goto error;
+
         /* Do not move start of the partition */
         constraint = constraint_from_start_end_fixed_start (*dev, start, 
range_end);
         if (!ped_disk_set_partition_geom (disk, part, constraint,
                                           start, end))
                 goto error_destroy_constraint;
         /* warn when shrinking partition - might lose data */
-        if (part->geom.end < oldend)
-                if (ped_exception_throw (
+        if (part->geom.end < oldend) {
+                if (opt_script_mode && (!ped_partition_is_busy (part) || 
ignore_busy)) {
+                        char *path = ped_partition_get_path (part);
+                        ped_exception_throw (
+                            PED_EXCEPTION_WARNING,
+                            PED_EXCEPTION_UNHANDLED,
+                            _("Shrinking partition %s, data loss possible."), 
path);
+                        free(path);
+                } else if (ped_exception_throw (
                             PED_EXCEPTION_WARNING,
                             PED_EXCEPTION_YES_NO,
                             _("Shrinking a partition can cause data loss, " \
                               "are you sure you want to continue?")) != 
PED_EXCEPTION_YES)
+                {
                         goto error_destroy_constraint;
+                }
+        }
         ped_disk_commit (disk);
 
         if ((*dev)->type != PED_DEVICE_FILE)
@@ -1690,6 +1714,7 @@ static int
 do_rm (PedDevice** dev, PedDisk** diskp)
 {
         PedPartition*           part = NULL;
+        const bool              danger_if_busy = true;
 
         if (!*diskp)
                 *diskp = ped_disk_new (*dev);
@@ -1698,7 +1723,7 @@ do_rm (PedDevice** dev, PedDisk** diskp)
 
         if (!command_line_get_partition (_("Partition number?"), *diskp, 
&part))
                 goto error;
-        if (!_partition_warn_busy (part))
+        if (!_partition_warn_busy (part, danger_if_busy))
                 goto error;
 
         ped_disk_delete_partition (*diskp, part);


Reply via email to