Accepting request 516173 from home:sparschauer:branches:Base:System

- Amend parsing of empty GPT partition names to require quoted
  empty strings '""' or "''" (bsc#1023818, boo#1032562)
  - amend: parted-mkpart-allow-empty-gpt-part-name.patch

OBS-URL: https://build.opensuse.org/request/show/516173
OBS-URL: https://build.opensuse.org/package/show/Base:System/parted?expand=0&rev=130
This commit is contained in:
Sebastian Parschauer 2017-08-11 15:11:48 +00:00 committed by Git OBS Bridge
parent 3be8b0ebb2
commit c8d62f21e1
2 changed files with 47 additions and 31 deletions

View File

@ -1,8 +1,9 @@
From: Sebastian Parschauer <sparschauer@suse.de>
Date: Thu, 10 Aug 2017 14:52:47 +0200
Subject: parted/ui: Count empty strings as words in multi_word mode
Date: Fri, 11 Aug 2017 12:46:42 +0200
Subject: parted/ui: Count empty quoted strings as words in multi_word
mode
References: bsc#1023818, boo#1032562
Patch-mainline: submitted, 2017-08-10
Patch-mainline: submitted, 2017-08-11
In non-interactive mode, the command line arguments are appended
to a string list with command_line_push_line() in multi_word mode.
@ -14,46 +15,54 @@ partition name from command line this way.
Also setting a default name is no option as this causes duplicate
/dev/disk/by-partlabel/ symlinks and systemd errors this way.
So count empty strings as words in multi_word mode to allow the
So count empty quoted strings as words in multi_word mode to allow
the following commands to set an empty partition name.
parted -s /dev/vdb mkpart "" 1MiB 100%
parted -s /dev/vdb mkpart "" ext3 1MiB 100%
parted -s /dev/vdb mkpart "''" 1MiB 100%
parted -s /dev/vdb mkpart '""' ext3 1MiB 100%
parted -s /dev/vdb name 1 "''"
This does not break any other parts as these all check if the
provided string is a valid value.
The quoting is required as in interactive mode the command
"mkpart " (with a trailing space) would set the partition name to
an empty string already.
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
parted/ui.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
parted/ui.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/parted/ui.c b/parted/ui.c
index 752860baa087..b7e593bf12da 100644
index 752860baa087..9991596a3a5a 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -712,8 +712,8 @@ _str_is_spaces (const char* str)
* In single-word mode, only one word is parsed per line.
* Leading and trailing spaces are removed. For example: " a b c "
* is a single word "a b c". The motivation for this mode is partition
- * names, etc. In single-word mode, the empty string is a word.
- * (but not in multi-word mode).
+ * names, etc. The empty string is always a word to allow empty
+ * partition names in non-interactive mode.
*/
void
@@ -719,6 +719,7 @@ void
command_line_push_line (const char* line, int multi_word)
@@ -755,10 +755,9 @@ command_line_push_line (const char* line, int multi_word)
{
int quoted = 0;
+ int quotes_empty = 0;
char quote_char = 0;
char this_word [256];
int i;
@@ -746,6 +747,9 @@ command_line_push_line (const char* line, int multi_word)
if (quoted && *line == quote_char) {
quoted = 0;
+ /* allow empty partition name in script mode */
+ if (!i)
+ quotes_empty = 1;
continue;
}
@@ -753,9 +757,11 @@ command_line_push_line (const char* line, int multi_word)
if (quoted && line[0] == '\\' && line[1])
line++;
+ quotes_empty = 0;
this_word [i++] = *line;
}
- if (i || !multi_word) {
- this_word [i] = 0;
- command_line_push_word (this_word);
- }
+ this_word [i] = 0;
+ command_line_push_word (this_word);
+
} while (*line && multi_word);
}
+ if (i || !multi_word || quotes_empty) {
+ quotes_empty = 0;
this_word [i] = 0;
command_line_push_word (this_word);
}

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Aug 11 16:15:08 CEST 2017 - sparschauer@suse.de
- Amend parsing of empty GPT partition names to require quoted
empty strings '""' or "''" (bsc#1023818, boo#1032562)
- amend: parted-mkpart-allow-empty-gpt-part-name.patch
-------------------------------------------------------------------
Thu Aug 10 16:44:57 CEST 2017 - sparschauer@suse.de