1
0
forked from pool/util-linux

Accepting request 805239 from home:favogt:branches:Base:System

Tested, works.

- Add patch to fix sfdisk not reading its own scripts:
  * libfdisk-script-accept-sector-size.patch
- Use %autopatch

- Fix verification of mount, su and umount (bsc#1166948)

OBS-URL: https://build.opensuse.org/request/show/805239
OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=429
This commit is contained in:
Dirk Mueller 2020-05-19 18:19:32 +00:00 committed by Git OBS Bridge
parent 06d1a88bec
commit b8b77fde7a
7 changed files with 183 additions and 25 deletions

View File

@ -0,0 +1,131 @@
From d8c68b52cc939a16f04ec976648a37f5f5de718c Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 4 Feb 2020 15:11:19 +0100
Subject: [PATCH] libfdisk: (script) accept sector-size, ignore unknown headers
- add sector-size between supported headers (already in --dump output)
- report unknown headers by -ENOTSUP
- ignore ENOTSUP in sfdisk (but print warning) and in fdisk_script_read_file()
Addresses: https://github.com/karelzak/util-linux/issues/949
Signed-off-by: Karel Zak <kzak@redhat.com>
---
disk-utils/sfdisk.c | 6 +++++-
libfdisk/src/script.c | 49 +++++++++++++++++++++++--------------------
2 files changed, 31 insertions(+), 24 deletions(-)
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
index 0db797b2d..e08862aa8 100644
--- a/disk-utils/sfdisk.c
+++ b/disk-utils/sfdisk.c
@@ -1823,7 +1823,11 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
}
rc = fdisk_script_read_line(dp, stdin, buf, sizeof(buf));
- if (rc < 0) {
+ if (rc == -ENOTSUP) {
+ buf[sizeof(buf) - 1] = '\0';
+ fdisk_warnx(sf->cxt, _("Unknown script header '%s' -- ignore."), buf);
+ continue;
+ } else if (rc < 0) {
DBG(PARSE, ul_debug("script parsing failed, trying sfdisk specific commands"));
buf[sizeof(buf) - 1] = '\0';
rc = loop_control_commands(sf, dp, buf);
diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c
index a21771b6a..d3e67fa9c 100644
--- a/libfdisk/src/script.c
+++ b/libfdisk/src/script.c
@@ -805,8 +805,12 @@ static inline int is_header_line(const char *s)
/* parses "<name>: value", note modifies @s*/
static int parse_line_header(struct fdisk_script *dp, char *s)
{
- int rc = -EINVAL;
+ size_t i;
char *name, *value;
+ static const char *supported[] = {
+ "label", "unit", "label-id", "device", "grain",
+ "first-lba", "last-lba", "table-length", "sector-size"
+ };
DBG(SCRIPT, ul_debugobj(dp, " parse header '%s'", s));
@@ -816,7 +820,7 @@ static int parse_line_header(struct fdisk_script *dp, char *s)
name = s;
value = strchr(s, ':');
if (!value)
- goto done;
+ return -EINVAL;
*value = '\0';
value++;
@@ -825,32 +829,30 @@ static int parse_line_header(struct fdisk_script *dp, char *s)
ltrim_whitespace((unsigned char *) value);
rtrim_whitespace((unsigned char *) value);
+ if (!*name || !*value)
+ return -EINVAL;
+
+ /* check header name */
+ for (i = 0; i < ARRAY_SIZE(supported); i++) {
+ if (strcmp(name, supported[i]) == 0)
+ break;
+ }
+ if (i == ARRAY_SIZE(supported))
+ return -ENOTSUP;
+
+ /* header specific actions */
if (strcmp(name, "label") == 0) {
if (dp->cxt && !fdisk_get_label(dp->cxt, value))
- goto done; /* unknown label name */
+ return -EINVAL; /* unknown label name */
dp->force_label = 1;
+
} else if (strcmp(name, "unit") == 0) {
if (strcmp(value, "sectors") != 0)
- goto done; /* only "sectors" supported */
- } else if (strcmp(name, "label-id") == 0
- || strcmp(name, "device") == 0
- || strcmp(name, "grain") == 0
- || strcmp(name, "first-lba") == 0
- || strcmp(name, "last-lba") == 0
- || strcmp(name, "table-length") == 0) {
- ; /* whatever is possible */
- } else
- goto done; /* unknown header */
+ return -EINVAL; /* only "sectors" supported */
- if (*name && *value)
- rc = fdisk_script_set_header(dp, name, value);
-done:
- if (rc)
- DBG(SCRIPT, ul_debugobj(dp, "header parse error: "
- "[rc=%d, name='%s', value='%s']",
- rc, name, value));
- return rc;
+ }
+ return fdisk_script_set_header(dp, name, value);
}
/* returns zero terminated string with next token and @str is updated */
@@ -1363,7 +1365,8 @@ int fdisk_script_set_fgets(struct fdisk_script *dp,
*
* Reads next line into dump.
*
- * Returns: 0 on success, <0 on error, 1 when nothing to read.
+ * Returns: 0 on success, <0 on error, 1 when nothing to read. For unknown headers
+ * returns -ENOTSUP, it's usually safe to ignore this error.
*/
int fdisk_script_read_line(struct fdisk_script *dp, FILE *f, char *buf, size_t bufsz)
{
@@ -1428,7 +1431,7 @@ int fdisk_script_read_file(struct fdisk_script *dp, FILE *f)
while (!feof(f)) {
rc = fdisk_script_read_line(dp, f, buf, sizeof(buf));
- if (rc)
+ if (rc && rc != -ENOTSUP)
break;
}

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Wed May 13 10:19:22 UTC 2020 - Fabian Vogt <fvogt@suse.com>
- Add patch to fix sfdisk not reading its own scripts:
* libfdisk-script-accept-sector-size.patch
- Use %autopatch
-------------------------------------------------------------------
Fri May 8 07:54:57 UTC 2020 - Fabian Vogt <fvogt@suse.com>
- Fix verification of mount, su and umount (bsc#1166948)
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Apr 6 23:07:48 CEST 2020 - Stanislav Brabec <sbrabec@suse.com> Mon Apr 6 23:07:48 CEST 2020 - Stanislav Brabec <sbrabec@suse.com>

View File

@ -79,7 +79,7 @@ Name: python3-libmount
%endif %endif
Summary: %main_summary Summary: %main_summary
License: GPL-2.0-or-later License: GPL-2.0-or-later
Group: %main_group Group: %group_pl
BuildRequires: audit-devel BuildRequires: audit-devel
BuildRequires: binutils-devel BuildRequires: binutils-devel
BuildRequires: fdupes BuildRequires: fdupes
@ -148,6 +148,7 @@ Patch1: libmount-print-a-blacklist-hint-for-unknown-filesyst.patch
Patch2: Add-documentation-on-blacklisted-modules-to-mount-8-.patch Patch2: Add-documentation-on-blacklisted-modules-to-mount-8-.patch
Patch3: libeconf.patch Patch3: libeconf.patch
Patch4: libmount-Avoid-triggering-autofs-in-lookup_umount_fs.patch Patch4: libmount-Avoid-triggering-autofs-in-lookup_umount_fs.patch
Patch5: libfdisk-script-accept-sector-size.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
# #
%if %build_util_linux %if %build_util_linux
@ -409,11 +410,7 @@ library.
%prep %prep
%setup -q -n %{_name}-%{version} %setup -q -n %{_name}-%{version}
cp -a %{S:2} . cp -a %{S:2} .
%patch0 -p1 %autopatch -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%build %build
%global _lto_cflags %{_lto_cflags} -ffat-lto-objects %global _lto_cflags %{_lto_cflags} -ffat-lto-objects
@ -952,7 +949,7 @@ rmdir --ignore-fail-on-non-empty /run/run >/dev/null 2>&1 || :
/sbin/chcpu /sbin/chcpu
#EndUsrMerge #EndUsrMerge
%{_bindir}/kill %{_bindir}/kill
%{_bindir}/su %verify(not mode) %{_bindir}/su
%{_bindir}/eject %{_bindir}/eject
%{_bindir}/cal %{_bindir}/cal
%{_bindir}/chmem %{_bindir}/chmem
@ -990,7 +987,7 @@ rmdir --ignore-fail-on-non-empty /run/run >/dev/null 2>&1 || :
%{_bindir}/mcookie %{_bindir}/mcookie
%{_bindir}/mesg %{_bindir}/mesg
%{_bindir}/more %{_bindir}/more
%{_bindir}/mount %verify(not mode) %{_bindir}/mount
%{_bindir}/namei %{_bindir}/namei
%{_bindir}/nsenter %{_bindir}/nsenter
%{_bindir}/prlimit %{_bindir}/prlimit
@ -1005,7 +1002,7 @@ rmdir --ignore-fail-on-non-empty /run/run >/dev/null 2>&1 || :
%{_bindir}/setsid %{_bindir}/setsid
%{_bindir}/taskset %{_bindir}/taskset
%{_bindir}/ul %{_bindir}/ul
%{_bindir}/umount %verify(not mode) %{_bindir}/umount
%{_bindir}/unshare %{_bindir}/unshare
%{_bindir}/mountpoint %{_bindir}/mountpoint
%{_bindir}/utmpdump %{_bindir}/utmpdump

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Wed May 13 10:19:22 UTC 2020 - Fabian Vogt <fvogt@suse.com>
- Add patch to fix sfdisk not reading its own scripts:
* libfdisk-script-accept-sector-size.patch
- Use %autopatch
-------------------------------------------------------------------
Fri May 8 07:54:57 UTC 2020 - Fabian Vogt <fvogt@suse.com>
- Fix verification of mount, su and umount (bsc#1166948)
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Apr 6 23:07:48 CEST 2020 - Stanislav Brabec <sbrabec@suse.com> Mon Apr 6 23:07:48 CEST 2020 - Stanislav Brabec <sbrabec@suse.com>

View File

@ -148,6 +148,7 @@ Patch1: libmount-print-a-blacklist-hint-for-unknown-filesyst.patch
Patch2: Add-documentation-on-blacklisted-modules-to-mount-8-.patch Patch2: Add-documentation-on-blacklisted-modules-to-mount-8-.patch
Patch3: libeconf.patch Patch3: libeconf.patch
Patch4: libmount-Avoid-triggering-autofs-in-lookup_umount_fs.patch Patch4: libmount-Avoid-triggering-autofs-in-lookup_umount_fs.patch
Patch5: libfdisk-script-accept-sector-size.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
# #
%if %build_util_linux %if %build_util_linux
@ -409,11 +410,7 @@ library.
%prep %prep
%setup -q -n %{_name}-%{version} %setup -q -n %{_name}-%{version}
cp -a %{S:2} . cp -a %{S:2} .
%patch0 -p1 %autopatch -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%build %build
%global _lto_cflags %{_lto_cflags} -ffat-lto-objects %global _lto_cflags %{_lto_cflags} -ffat-lto-objects
@ -952,7 +949,7 @@ rmdir --ignore-fail-on-non-empty /run/run >/dev/null 2>&1 || :
/sbin/chcpu /sbin/chcpu
#EndUsrMerge #EndUsrMerge
%{_bindir}/kill %{_bindir}/kill
%{_bindir}/su %verify(not mode) %{_bindir}/su
%{_bindir}/eject %{_bindir}/eject
%{_bindir}/cal %{_bindir}/cal
%{_bindir}/chmem %{_bindir}/chmem
@ -990,7 +987,7 @@ rmdir --ignore-fail-on-non-empty /run/run >/dev/null 2>&1 || :
%{_bindir}/mcookie %{_bindir}/mcookie
%{_bindir}/mesg %{_bindir}/mesg
%{_bindir}/more %{_bindir}/more
%{_bindir}/mount %verify(not mode) %{_bindir}/mount
%{_bindir}/namei %{_bindir}/namei
%{_bindir}/nsenter %{_bindir}/nsenter
%{_bindir}/prlimit %{_bindir}/prlimit
@ -1005,7 +1002,7 @@ rmdir --ignore-fail-on-non-empty /run/run >/dev/null 2>&1 || :
%{_bindir}/setsid %{_bindir}/setsid
%{_bindir}/taskset %{_bindir}/taskset
%{_bindir}/ul %{_bindir}/ul
%{_bindir}/umount %verify(not mode) %{_bindir}/umount
%{_bindir}/unshare %{_bindir}/unshare
%{_bindir}/mountpoint %{_bindir}/mountpoint
%{_bindir}/utmpdump %{_bindir}/utmpdump

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Wed May 13 10:19:22 UTC 2020 - Fabian Vogt <fvogt@suse.com>
- Add patch to fix sfdisk not reading its own scripts:
* libfdisk-script-accept-sector-size.patch
- Use %autopatch
-------------------------------------------------------------------
Fri May 8 07:54:57 UTC 2020 - Fabian Vogt <fvogt@suse.com>
- Fix verification of mount, su and umount (bsc#1166948)
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Apr 6 23:07:48 CEST 2020 - Stanislav Brabec <sbrabec@suse.com> Mon Apr 6 23:07:48 CEST 2020 - Stanislav Brabec <sbrabec@suse.com>

View File

@ -148,6 +148,7 @@ Patch1: libmount-print-a-blacklist-hint-for-unknown-filesyst.patch
Patch2: Add-documentation-on-blacklisted-modules-to-mount-8-.patch Patch2: Add-documentation-on-blacklisted-modules-to-mount-8-.patch
Patch3: libeconf.patch Patch3: libeconf.patch
Patch4: libmount-Avoid-triggering-autofs-in-lookup_umount_fs.patch Patch4: libmount-Avoid-triggering-autofs-in-lookup_umount_fs.patch
Patch5: libfdisk-script-accept-sector-size.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
# #
%if %build_util_linux %if %build_util_linux
@ -409,11 +410,7 @@ library.
%prep %prep
%setup -q -n %{_name}-%{version} %setup -q -n %{_name}-%{version}
cp -a %{S:2} . cp -a %{S:2} .
%patch0 -p1 %autopatch -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%build %build
%global _lto_cflags %{_lto_cflags} -ffat-lto-objects %global _lto_cflags %{_lto_cflags} -ffat-lto-objects
@ -952,7 +949,7 @@ rmdir --ignore-fail-on-non-empty /run/run >/dev/null 2>&1 || :
/sbin/chcpu /sbin/chcpu
#EndUsrMerge #EndUsrMerge
%{_bindir}/kill %{_bindir}/kill
%{_bindir}/su %verify(not mode) %{_bindir}/su
%{_bindir}/eject %{_bindir}/eject
%{_bindir}/cal %{_bindir}/cal
%{_bindir}/chmem %{_bindir}/chmem
@ -990,7 +987,7 @@ rmdir --ignore-fail-on-non-empty /run/run >/dev/null 2>&1 || :
%{_bindir}/mcookie %{_bindir}/mcookie
%{_bindir}/mesg %{_bindir}/mesg
%{_bindir}/more %{_bindir}/more
%{_bindir}/mount %verify(not mode) %{_bindir}/mount
%{_bindir}/namei %{_bindir}/namei
%{_bindir}/nsenter %{_bindir}/nsenter
%{_bindir}/prlimit %{_bindir}/prlimit
@ -1005,7 +1002,7 @@ rmdir --ignore-fail-on-non-empty /run/run >/dev/null 2>&1 || :
%{_bindir}/setsid %{_bindir}/setsid
%{_bindir}/taskset %{_bindir}/taskset
%{_bindir}/ul %{_bindir}/ul
%{_bindir}/umount %verify(not mode) %{_bindir}/umount
%{_bindir}/unshare %{_bindir}/unshare
%{_bindir}/mountpoint %{_bindir}/mountpoint
%{_bindir}/utmpdump %{_bindir}/utmpdump