!33 [sync] PR-32: fix supermin: failure: ext2fs_namei: parent directory not found and adapted hce and remove unuse kernel

From: @openeuler-sync-bot 
Reviewed-by: @gitee-cmd 
Signed-off-by: @gitee-cmd
This commit is contained in:
openeuler-ci-bot 2022-12-13 06:20:31 +00:00 committed by Gitee
commit 81c42c88c6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 127 additions and 2 deletions

View File

@ -0,0 +1,55 @@
From 487e8c964078f823646d3b0584745ab7d0ef99ca Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 26 Nov 2019 09:01:21 +0000
Subject: [PATCH] ext2: Build symbolic links correctly (RHBZ#1770304).
We created symlinks in two steps, by creating the empty inode and then
calling ext2fs_symlink to populate it. This created broken symlinks
where the directory name contained a / character, eg:
lrwxrwxrwx 1 root root 7 Nov 26 08:43 /bin -> usr/bin
lrwxrwxrwx 1 root root 7 Nov 26 08:43 /lib -> usr/lib
lrwxrwxrwx 1 root root 9 Nov 26 08:43 /lib64 -> usr/lib64
lrwxrwxrwx 1 root root 8 Nov 26 08:43 /sbin -> usr/sbin
lrwxrwxrwx 1 root root 7 Nov 26 08:38 bin -> usr/bin
This breaks with Linux >= 5.3.8, most likely because of extra
validation now being done at the VFS layer:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/fs/readdir.c?id=8a23eb804ca4f2be909e372cf5a9e7b30ae476cd
It's unnecessary to create the empty inode since ext2fs_symlink can
create the inode for us perfectly fine if we simply pass ino == 0, and
it creates them correctly too.
Thanks: Toolybird for identifying the problem and kernel patch.
---
src/ext2fs-c.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/src/ext2fs-c.c b/src/ext2fs-c.c
index e8ab972..8903f74 100644
--- a/src/ext2fs-c.c
+++ b/src/ext2fs-c.c
@@ -782,12 +782,6 @@ ext2_copy_file (struct ext2_data *data, const char *src, const char *dest)
}
/* Create a symlink. */
else if (S_ISLNK (statbuf.st_mode)) {
- ext2_ino_t ino;
- ext2_empty_inode (data->fs, dir_ino, dirname, basename,
- statbuf.st_mode, statbuf.st_uid, statbuf.st_gid,
- statbuf.st_ctime, statbuf.st_atime, statbuf.st_mtime,
- 0, 0, EXT2_FT_SYMLINK, &ino);
-
char *buf = malloc (statbuf.st_size+1);
if (buf == NULL)
caml_raise_out_of_memory ();
@@ -797,7 +791,7 @@ ext2_copy_file (struct ext2_data *data, const char *src, const char *dest)
if (r > statbuf.st_size)
r = statbuf.st_size;
buf[r] = '\0';
- ext2fs_symlink (data->fs, dir_ino, ino, dest, buf);
+ ext2fs_symlink (data->fs, dir_ino, 0, basename, buf);
free (buf);
}
/* Create directory. */

View File

@ -0,0 +1,38 @@
From 62d5c774d6c8fcac11e28fcba99754b5478e5088 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 10 Dec 2019 18:43:00 +0000
Subject: [PATCH] ext2: Expand directory when adding symlinks (RHBZ#1770304).
This produced very weird bugs with missing symlinks under
certain conditions, see:
https://bugzilla.redhat.com/show_bug.cgi?id=1781803
Fixes commit 487e8c964078f823646d3b0584745ab7d0ef99ca.
---
src/ext2fs-c.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/ext2fs-c.c b/src/ext2fs-c.c
index 8903f74..0000865 100644
--- a/src/ext2fs-c.c
+++ b/src/ext2fs-c.c
@@ -791,7 +791,18 @@ ext2_copy_file (struct ext2_data *data, const char *src, const char *dest)
if (r > statbuf.st_size)
r = statbuf.st_size;
buf[r] = '\0';
- ext2fs_symlink (data->fs, dir_ino, 0, basename, buf);
+ symlink_again:
+ err = ext2fs_symlink (data->fs, dir_ino, 0, basename, buf);
+ if (err) {
+ if (err == EXT2_ET_DIR_NO_SPACE) {
+ err = ext2fs_expand_dir (data->fs, dir_ino);
+ if (err)
+ ext2_error_to_exception ("ext2fs_expand_dir", err, dirname);
+ goto symlink_again;
+ }
+ else
+ ext2_error_to_exception ("ext2fs_symlink", err, basename);
+ }
free (buf);
}
/* Create directory. */

View File

@ -0,0 +1,20 @@
diff --git a/src/ph_rpm.ml b/src/ph_rpm.ml
index 61537ce..8260396 100644
--- a/src/ph_rpm.ml
+++ b/src/ph_rpm.ml
@@ -31,11 +31,13 @@ let stringset_of_list pkgs =
let fedora_detect () =
Config.rpm <> "no" && Config.rpm2cpio <> "no" && rpm_is_available () &&
(Config.yumdownloader <> "no" || Config.dnf <> "no") &&
- (List.mem (Os_release.get_id ()) [ "fedora"; "rhel"; "centos"; "openEuler" ] ||
+ (List.mem (Os_release.get_id ()) [ "fedora"; "rhel"; "centos"; "openEuler"; "hce"; "euleros" ] ||
try
(stat "/etc/redhat-release").st_kind = S_REG ||
(stat "/etc/fedora-release").st_kind = S_REG ||
- (stat "/etc/openEuler-release").st_kind = S_REG
+ (stat "/etc/openEuler-release").st_kind = S_REG ||
+ (stat "/etc/euleros-release").st_kind = S_REG ||
+ (stat "/etc/hce-release").st_kind = S_REG
with Unix_error _ -> false)
let opensuse_detect () =

View File

@ -2,7 +2,7 @@
Name: supermin
Version: 5.1.19
Release: 13
Release: 16
Summary: A tool for building supermin appliances, required by libguestfs
License: GPLv2+
URL: http://libguestfs.org/
@ -11,10 +11,13 @@ Source1: supermin.attr
Source2: supermin-find-requires
Patch0001: 0001-Fix-Bytes-String-for-OCaml-4.06.patch
Patch0002: 0002-use-installed-packages-instead-of-dnf-downloading.patch
Patch0003: Build-symbolic-links-correctly.patch
Patch0004: Expand-directory-when-adding-symlinks.patch
Patch9000: 9000-fix-cannot-detect-package-manager.patch
Patch9001: add-pie-and-bind_now-flags.patch
Patch9002: fix-cannot-detect-package-manager-on-hce.patch
BuildRequires: augeas dietlibc-devel dnf dnf-plugins-core e2fsprogs-devel
BuildRequires: findutils gnupg2 grubby hivex kernel ocaml ocaml-findlib-devel
BuildRequires: findutils gnupg2 grubby hivex ocaml ocaml-findlib-devel
BuildRequires: rpm rpm-devel systemd-udev tar
BuildRequires: /usr/bin/pod2man /usr/bin/pod2html /usr/sbin/mke2fs
Requires: cpio dnf dnf-plugins-core e2fsprogs-libs >= 1.42 findutils
@ -76,6 +79,15 @@ install -m 0755 %{SOURCE2} $RPM_BUILD_ROOT%{_rpmconfigdir}/
%{_mandir}/man1/*
%changelog
* Tue Nov 15 2022 xu_ping <xuping33@h-partners.com> - 5.1.19-16
- fix cannot detect package manager on hce
* Mon Nov 14 2022 xu_ping <xuping33@h-partners.com> - 5.1.19-15
- fix ext2: copying kernel modules error
* Thu May 26 2022 Jun Yang <jun.yang@suse.com> - 5.1.19-14
- Remove dependency of kernel package
* Fri Nov 18 2022 liyanan <liyanan32@h-partners.com> - 5.1.19-13
- Replace openEuler with vendor