From e2c90d75b64afd0fc71edefc822c051ad8b14ad0 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Tue, 30 Apr 2013 19:06:31 +0200 Subject: [PATCH] dracut-027-45.git20130430 - fixed fips mode more Resolves: rhbz#956521 --- ...ut.sh-do-not-preunlink-for-fips-mode.patch | 28 + ...-immediatly-after-loading-the-crypto.patch | 23 + ...install-make-use-of-_cleanup_-macros.patch | 785 ++++++++++++++++++ ...-Show-current-working-directory-corr.patch | 51 ++ ...-option-F-and-install-etc-os-release.patch | 584 +++++++++++++ ...-match-udev-rule-against-KERNEL-zfcp.patch | 19 + dracut.spec | 12 +- 7 files changed, 1501 insertions(+), 1 deletion(-) create mode 100644 0039-dracut.sh-do-not-preunlink-for-fips-mode.patch create mode 100644 0040-fips-do-not-fail-immediatly-after-loading-the-crypto.patch create mode 100644 0041-dracut-install-make-use-of-_cleanup_-macros.patch create mode 100644 0042-_emergency_shell-Show-current-working-directory-corr.patch create mode 100644 0043-test-use-grep-option-F-and-install-etc-os-release.patch create mode 100644 0044-zfcp-match-udev-rule-against-KERNEL-zfcp.patch diff --git a/0039-dracut.sh-do-not-preunlink-for-fips-mode.patch b/0039-dracut.sh-do-not-preunlink-for-fips-mode.patch new file mode 100644 index 0000000..c96b92e --- /dev/null +++ b/0039-dracut.sh-do-not-preunlink-for-fips-mode.patch @@ -0,0 +1,28 @@ +From 8461734ee47fb1078e543f55f9ca6f8530855361 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Thu, 25 Apr 2013 21:16:03 +0200 +Subject: [PATCH] dracut.sh: do not preunlink for fips mode + +just install prelink and the cache files +--- + dracut.sh | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +diff --git a/dracut.sh b/dracut.sh +index 82b4a5f..5f0a1b3 100755 +--- a/dracut.sh ++++ b/dracut.sh +@@ -1140,12 +1140,8 @@ fi + PRELINK_BIN=$(command -v prelink) + if [[ $UID = 0 ]] && [[ $PRELINK_BIN ]]; then + if [[ $DRACUT_FIPS_MODE ]]; then +- dinfo "*** Pre-unlinking files ***" ++ dinfo "*** Installing prelink files ***" + dracut_install -o prelink /etc/prelink.conf /etc/prelink.conf.d/*.conf /etc/prelink.cache +- chroot "$initdir" $PRELINK_BIN -u -a +- rm -f "$initdir"/$PRELINK_BIN +- rm -fr "$initdir"/etc/prelink.* +- dinfo "*** Pre-unlinking files done ***" + else + dinfo "*** Pre-linking files ***" + dracut_install -o prelink /etc/prelink.conf /etc/prelink.conf.d/*.conf diff --git a/0040-fips-do-not-fail-immediatly-after-loading-the-crypto.patch b/0040-fips-do-not-fail-immediatly-after-loading-the-crypto.patch new file mode 100644 index 0000000..08c8a59 --- /dev/null +++ b/0040-fips-do-not-fail-immediatly-after-loading-the-crypto.patch @@ -0,0 +1,23 @@ +From 26a077fc7e5a381284a9b474acdf22a58fb47dda Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Mon, 29 Apr 2013 11:34:26 +0200 +Subject: [PATCH] fips: do not fail immediatly after loading the crypto modules + +Fail only if tcrypt insmod failed. +--- + modules.d/01fips/fips.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/modules.d/01fips/fips.sh b/modules.d/01fips/fips.sh +index ce3e49c..0095416 100755 +--- a/modules.d/01fips/fips.sh ++++ b/modules.d/01fips/fips.sh +@@ -63,7 +63,7 @@ do_fips() + info "Loading and integrity checking all crypto modules" + for module in $FIPSMODULES; do + if [ "$module" != "tcrypt" ]; then +- modprobe ${module} || return 1 ++ modprobe ${module} + fi + done + info "Self testing crypto algorithms" diff --git a/0041-dracut-install-make-use-of-_cleanup_-macros.patch b/0041-dracut-install-make-use-of-_cleanup_-macros.patch new file mode 100644 index 0000000..ca1319e --- /dev/null +++ b/0041-dracut-install-make-use-of-_cleanup_-macros.patch @@ -0,0 +1,785 @@ +From 3ed08d1e4dbb52dc181be01b6e147017327aa6d9 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Mon, 29 Apr 2013 11:35:23 +0200 +Subject: [PATCH] dracut-install: make use of _cleanup_* macros + +--- + install/dracut-install.c | 230 +++++++++++++++++++++++++---------------------- + install/macro.h | 150 +++++++++++++++++++++++++------ + install/util.h | 36 ++++++++ + 3 files changed, 281 insertions(+), 135 deletions(-) + +diff --git a/install/dracut-install.c b/install/dracut-install.c +index 2fad6df..b4bf681 100644 +--- a/install/dracut-install.c ++++ b/install/dracut-install.c +@@ -62,6 +62,10 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + static size_t dir_len(char const *file) + { + size_t length; ++ ++ if(!file) ++ return 0; ++ + /* Strip the basename and any redundant slashes before it. */ + for (length = strlen(file)-1; 0 < length; length--) + if (file[length] == '/' && file[length-1] != '/') +@@ -73,20 +77,22 @@ static char *convert_abs_rel(const char *from, const char *target) + { + /* we use the 4*MAXPATHLEN, which should not overrun */ + char relative_from[MAXPATHLEN * 4]; +- char *realtarget = NULL; +- char *p, *q; ++ _cleanup_free_ char *realtarget = NULL; ++ _cleanup_free_ char *target_dir_p = NULL, *realpath_p = NULL; + const char *realfrom = from; + int level = 0, fromlevel = 0, targetlevel = 0; + int l, i, rl; + int dirlen; + +- p = strdup(target); +- dirlen = dir_len(p); +- p[dirlen] = '\0'; +- q = realpath(p, NULL); ++ target_dir_p = strdup(target); ++ if (!target_dir_p) ++ return strdup(from); ++ ++ dirlen = dir_len(target_dir_p); ++ target_dir_p[dirlen] = '\0'; ++ realpath_p = realpath(target_dir_p, NULL); + +- if (q == NULL) { +- free(p); ++ if (realpath_p == NULL) { + log_warning("convert_abs_rel(): target '%s' directory has no realpath.", target); + return strdup(from); + } +@@ -95,11 +101,9 @@ static char *convert_abs_rel(const char *from, const char *target) + * character - need to skip all leading /'s */ + rl = strlen(target); + for (i = dirlen+1; i < rl; ++i) +- if (p[i] != '/') ++ if (target_dir_p[i] != '/') + break; +- asprintf(&realtarget, "%s/%s", q, &p[i]); +- free(p); +- free(q); ++ asprintf(&realtarget, "%s/%s", realpath_p, &target_dir_p[i]); + + /* now calculate the relative path from to and + store it in +@@ -122,8 +126,6 @@ static char *convert_abs_rel(const char *from, const char *target) + if (realtarget[i] == '/') + level++; + +- free(realtarget); +- + /* add "../" to the relative_from path, until the common pathname is + reached */ + for (i = level; i < targetlevel; i++) { +@@ -155,18 +157,16 @@ static char *convert_abs_rel(const char *from, const char *target) + static int ln_r(const char *src, const char *dst) + { + int ret; +- const char *points_to = convert_abs_rel(src, dst); ++ _cleanup_free_ const char *points_to = convert_abs_rel(src, dst); ++ + log_info("ln -s '%s' '%s'", points_to, dst); + ret = symlink(points_to, dst); + + if (ret != 0) { + log_error("ERROR: ln -s '%s' '%s': %m", points_to, dst); +- free((char *)points_to); + return 1; + } + +- free((char *)points_to); +- + return 0; + } + +@@ -186,11 +186,11 @@ static bool use_clone = true; + static int cp(const char *src, const char *dst) + { + int pid; +- int ret; ++ int ret = 0; + + if (use_clone) { + struct stat sb; +- int dest_desc, source_desc; ++ _cleanup_close_ int dest_desc = -1, source_desc = -1; + + if (lstat(src, &sb) != 0) + goto normal_copy; +@@ -207,12 +207,11 @@ static int cp(const char *src, const char *dst) + (sb.st_mode) & (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)); + + if (dest_desc < 0) { +- close(source_desc); + goto normal_copy; + } + + ret = clone_file(dest_desc, source_desc); +- close(source_desc); ++ + if (ret == 0) { + struct timeval tv[2]; + if (fchown(dest_desc, sb.st_uid, sb.st_gid) != 0) +@@ -222,11 +221,10 @@ static int cp(const char *src, const char *dst) + tv[1].tv_sec = sb.st_mtime; + tv[1].tv_usec = 0; + futimes(dest_desc, tv); +- close(dest_desc); + return ret; + } + close(dest_desc); +- ++ dest_desc = -1; + /* clone did not work, remove the file */ + unlink(dst); + /* do not try clone again */ +@@ -243,10 +241,11 @@ static int cp(const char *src, const char *dst) + while (waitpid(pid, &ret, 0) < 0) { + if (errno != EINTR) { + ret = -1; ++ log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps -fL %s %s", src, dst); + break; + } + } +- ++ log_debug("cp ret = %d", ret); + return ret; + } + +@@ -256,15 +255,17 @@ static int resolve_deps(const char *src) + + char *buf = malloc(LINE_MAX); + size_t linesize = LINE_MAX; +- FILE *fptr; +- char *cmd; ++ _cleanup_pclose_ FILE *fptr = NULL; ++ _cleanup_free_ char *cmd = NULL; + + if (strstr(src, ".so") == 0) { +- int fd; ++ _cleanup_close_ int fd = -1; + fd = open(src, O_RDONLY | O_CLOEXEC); ++ if (fd < 0) ++ return -errno; ++ + read(fd, buf, LINE_MAX); + buf[LINE_MAX - 1] = '\0'; +- close(fd); + if (buf[0] == '#' && buf[1] == '!') { + /* we have a shebang */ + char *p, *q; +@@ -280,7 +281,11 @@ static int resolve_deps(const char *src) + } + + /* run ldd */ +- asprintf(&cmd, "ldd %s 2>&1", src); ++ ret = asprintf(&cmd, "ldd %s 2>&1", src); ++ if (ret < 0) ++ return ret; ++ ret = 0; ++ + fptr = popen(cmd, "r"); + + while (!feof(fptr)) { +@@ -336,7 +341,6 @@ static int resolve_deps(const char *src) + } + } + } +- pclose(fptr); + + return ret; + } +@@ -344,10 +348,14 @@ static int resolve_deps(const char *src) + /* Install "..hmac" file for FIPS self-checks */ + static int hmac_install(const char *src, const char *dst, const char *hmacpath) + { +- char *srcpath = strdup(src); +- char *dstpath = strdup(dst); +- char *srchmacname = NULL; +- char *dsthmacname = NULL; ++ _cleanup_free_ char *srcpath = strdup(src); ++ _cleanup_free_ char *dstpath = strdup(dst); ++ _cleanup_free_ char *srchmacname = NULL; ++ _cleanup_free_ char *dsthmacname = NULL; ++ ++ if (!(srcpath && dstpath)) ++ return -ENOMEM; ++ + size_t dlen = dir_len(src); + + if (endswith(src, ".hmac")) +@@ -371,22 +379,18 @@ static int hmac_install(const char *src, const char *dst, const char *hmacpath) + } + log_debug("hmac cp '%s' '%s')", srchmacname, dsthmacname); + dracut_install(srchmacname, dsthmacname, false, false, true); +- free(dsthmacname); +- free(srchmacname); +- free(srcpath); +- free(dstpath); + return 0; + } + + static int dracut_install(const char *src, const char *dst, bool isdir, bool resolvedeps, bool hashdst) + { + struct stat sb, db; +- char *dname = NULL; +- char *fulldstpath = NULL; +- char *fulldstdir = NULL; ++ _cleanup_free_ char *fulldstpath = NULL; ++ _cleanup_free_ char *fulldstdir = NULL; + int ret; + bool src_exists = true; +- char *i, *existing; ++ char *i = NULL; ++ char *existing; + + log_debug("dracut_install('%s', '%s')", src, dst); + +@@ -419,6 +423,9 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + } + + i = strdup(dst); ++ if (!i) ++ return -ENOMEM; ++ + hashmap_put(items, i, i); + + asprintf(&fulldstpath, "%s%s", destrootdir, dst); +@@ -437,7 +444,6 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + } else + log_debug("'%s' already exists", fulldstpath); + +- free(fulldstpath); + /* dst does already exist */ + return ret; + } +@@ -449,6 +455,8 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + ret = stat(fulldstdir, &db); + + if (ret < 0) { ++ _cleanup_free_ char *dname = NULL; ++ + if (errno != ENOENT) { + log_error("ERROR: stat '%s': %m", fulldstdir); + return 1; +@@ -456,35 +464,34 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + /* create destination directory */ + log_debug("dest dir '%s' does not exist", fulldstdir); + dname = strdup(dst); ++ if (!dname) ++ return 1; ++ + dname[dir_len(dname)] = '\0'; + ret = dracut_install(dname, dname, true, false, true); + +- free(dname); +- + if (ret != 0) { + log_error("ERROR: failed to create directory '%s'", fulldstdir); +- free(fulldstdir); + return 1; + } + } + +- free(fulldstdir); +- + if (isdir && !src_exists) { + log_info("mkdir '%s'", fulldstpath); +- return mkdir(fulldstpath, 0755); ++ ret = mkdir(fulldstpath, 0755); ++ return ret; + } + + /* ready to install src */ + + if (S_ISDIR(sb.st_mode)) { + log_info("mkdir '%s'", fulldstpath); +- return mkdir(fulldstpath, sb.st_mode | S_IWUSR); ++ ret = mkdir(fulldstpath, sb.st_mode | S_IWUSR); ++ return ret; + } + + if (S_ISLNK(sb.st_mode)) { +- char *abspath; +- char *absdestpath = NULL; ++ _cleanup_free_ char *abspath = NULL; + + abspath = realpath(src, NULL); + +@@ -502,15 +509,13 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + } + + if (lstat(fulldstpath, &sb) != 0) { ++ _cleanup_free_ char *absdestpath = NULL; + + asprintf(&absdestpath, "%s%s", destrootdir, abspath); + + ln_r(absdestpath, fulldstpath); +- +- free(absdestpath); + } + +- free(abspath); + if (arg_hmac) { + /* copy .hmac files also */ + hmac_install(src, dst, NULL); +@@ -528,8 +533,12 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + } + } + ++ log_debug("dracut_install ret = %d", ret); + log_info("cp '%s' '%s'", src, fulldstpath); + ret += cp(src, fulldstpath); ++ ++ log_debug("dracut_install ret = %d", ret); ++ + return ret; + } + +@@ -540,49 +549,49 @@ static void item_free(char *i) + } + + static void usage(int status) +-{ +- /* */ +- printf("\ +-Usage: %s -D DESTROOTDIR [OPTION]... -a SOURCE...\n\ +- or: %s -D DESTROOTDIR [OPTION]... SOURCE DEST\n\ +-\n\ +-Install SOURCE to DEST in DESTROOTDIR with all needed dependencies.\n\ +-\n\ +- -D --destrootdir Install all files to DESTROOTDIR as the root\n\ +- -a --all Install all SOURCE arguments to DESTROOTDIR\n\ +- -o --optional If SOURCE does not exist, do not fail\n\ +- -d --dir SOURCE is a directory\n\ +- -l --ldd Also install shebang executables and libraries\n\ +- -R --resolvelazy Only install shebang executables and libraries for all SOURCE files\n\ +- -H --fips Also install all '.SOURCE.hmac' files\n\ +- -v --verbose Show more output\n\ +- --debug Show debug output\n\ +- --version Show package version\n\ +- -h --help Show this help\n\ +-\n\ +-Example:\n\ +-# mkdir -p /var/tmp/test-root\n\ +-# %s -D /var/tmp/test-root --ldd -a sh tr\n\ +-# tree /var/tmp/test-root\n\ +-/var/tmp/test-root\n\ +-|-- lib64 -> usr/lib64\n\ +-`-- usr\n\ +- |-- bin\n\ +- | |-- bash\n\ +- | |-- sh -> bash\n\ +- | `-- tr\n\ +- `-- lib64\n\ +- |-- ld-2.15.90.so\n\ +- |-- ld-linux-x86-64.so.2 -> ld-2.15.90.so\n\ +- |-- libc-2.15.90.so\n\ +- |-- libc.so\n\ +- |-- libc.so.6 -> libc-2.15.90.so\n\ +- |-- libdl-2.15.90.so\n\ +- |-- libdl.so -> libdl-2.15.90.so\n\ +- |-- libdl.so.2 -> libdl-2.15.90.so\n\ +- |-- libtinfo.so.5 -> libtinfo.so.5.9\n\ +- `-- libtinfo.so.5.9\n\ +-", program_invocation_short_name, program_invocation_short_name, program_invocation_short_name); ++{ ++ /* */ ++ printf("Usage: %s -D DESTROOTDIR [OPTION]... -a SOURCE...\n" ++ "or: %s -D DESTROOTDIR [OPTION]... SOURCE DEST\n" ++ "\n" ++ "Install SOURCE to DEST in DESTROOTDIR with all needed dependencies.\n" ++ "\n" ++ " -D --destrootdir Install all files to DESTROOTDIR as the root\n" ++ " -a --all Install all SOURCE arguments to DESTROOTDIR\n" ++ " -o --optional If SOURCE does not exist, do not fail\n" ++ " -d --dir SOURCE is a directory\n" ++ " -l --ldd Also install shebang executables and libraries\n" ++ " -R --resolvelazy Only install shebang executables and libraries\n" ++ " for all SOURCE files\n" ++ " -H --fips Also install all '.SOURCE.hmac' files\n" ++ " -v --verbose Show more output\n" ++ " --debug Show debug output\n" ++ " --version Show package version\n" ++ " -h --help Show this help\n" ++ "\n" ++ "Example:\n" ++ "# mkdir -p /var/tmp/test-root\n" ++ "# %s -D /var/tmp/test-root --ldd -a sh tr\n" ++ "# tree /var/tmp/test-root\n" ++ "/var/tmp/test-root\n" ++ "|-- lib64 -> usr/lib64\n" ++ "`-- usr\n" ++ " |-- bin\n" ++ " | |-- bash\n" ++ " | |-- sh -> bash\n" ++ " | `-- tr\n" ++ " `-- lib64\n" ++ " |-- ld-2.15.90.so\n" ++ " |-- ld-linux-x86-64.so.2 -> ld-2.15.90.so\n" ++ " |-- libc-2.15.90.so\n" ++ " |-- libc.so\n" ++ " |-- libc.so.6 -> libc-2.15.90.so\n" ++ " |-- libdl-2.15.90.so\n" ++ " |-- libdl.so -> libdl-2.15.90.so\n" ++ " |-- libdl.so.2 -> libdl-2.15.90.so\n" ++ " |-- libtinfo.so.5 -> libtinfo.so.5.9\n" ++ " `-- libtinfo.so.5.9\n" ++ , program_invocation_short_name, program_invocation_short_name, program_invocation_short_name); + exit(status); + } + +@@ -595,7 +604,7 @@ static int parse_argv(int argc, char *argv[]) + ARG_DEBUG + }; + +- static const struct option const options[] = { ++ static struct option const options[] = { + {"help", no_argument, NULL, 'h'}, + {"version", no_argument, NULL, ARG_VERSION}, + {"dir", no_argument, NULL, 'd'}, +@@ -691,7 +700,7 @@ static int resolve_lazy(int argc, char **argv) + + static char *find_binary(const char *src) + { +- char *path; ++ _cleanup_free_ char *path = NULL; + char *p, *q; + bool end = false; + char *newsrc = NULL; +@@ -703,6 +712,12 @@ static char *find_binary(const char *src) + } + path = strdup(path); + p = path; ++ ++ if (path == NULL) { ++ log_error("Out of memory!"); ++ exit(EXIT_FAILURE); ++ } ++ + log_debug("PATH=%s", path); + + do { +@@ -716,6 +731,11 @@ static char *find_binary(const char *src) + *q = '\0'; + + asprintf(&newsrc, "%s/%s", p, src); ++ if (newsrc == NULL) { ++ log_error("Out of memory!"); ++ exit(EXIT_FAILURE); ++ } ++ + p = q + 1; + + if (stat(newsrc, &sb) != 0) { +@@ -729,9 +749,9 @@ static char *find_binary(const char *src) + + } while (!end); + +- free(path); + if (newsrc) + log_debug("find_binary(%s) == %s", src, newsrc); ++ + return newsrc; + } + +@@ -773,22 +793,20 @@ static int install_all(int argc, char **argv) + log_debug("Handle '%s'", argv[i]); + + if (strchr(argv[i], '/') == NULL) { +- char *newsrc = find_binary(argv[i]); ++ _cleanup_free_ char *newsrc = find_binary(argv[i]); + if (newsrc) { + log_debug("dracut_install '%s'", newsrc); + ret = dracut_install(newsrc, newsrc, arg_createdir, arg_resolvedeps, true); + if (ret == 0) { + log_debug("dracut_install '%s' OK", newsrc); + } +- free(newsrc); + } else { + ret = -1; + } + + } else { +- char *dest = strdup(argv[i]); ++ _cleanup_free_ char *dest = strdup(argv[i]); + ret = dracut_install(argv[i], dest, arg_createdir, arg_resolvedeps, true); +- free(dest); + } + + if ((ret != 0) && (!arg_optional)) { +diff --git a/install/macro.h b/install/macro.h +index 1c0aa91..ac61b49 100644 +--- a/install/macro.h ++++ b/install/macro.h +@@ -1,7 +1,6 @@ + /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +-#ifndef foomacrohfoo +-#define foomacrohfoo ++#pragma once + + /*** + This file is part of systemd. +@@ -45,16 +44,38 @@ + #define _hidden_ __attribute__ ((visibility("hidden"))) + #define _weakref_(x) __attribute__((weakref(#x))) + #define _introspect_(x) __attribute__((section("introspect." x))) ++#define _alignas_(x) __attribute__((aligned(__alignof(x)))) ++#define _cleanup_(x) __attribute__((cleanup(x))) ++ ++/* automake test harness */ ++#define EXIT_TEST_SKIP 77 + + #define XSTRINGIFY(x) #x + #define STRINGIFY(x) XSTRINGIFY(x) + + /* Rounds up */ +-#define ALIGN(l) ALIGN_TO((l), sizeof(void*)) ++ ++#define ALIGN4(l) (((l) + 3) & ~3) ++#define ALIGN8(l) (((l) + 7) & ~7) ++ ++#if __SIZEOF_POINTER__ == 8 ++#define ALIGN(l) ALIGN8(l) ++#elif __SIZEOF_POINTER__ == 4 ++#define ALIGN(l) ALIGN4(l) ++#else ++#error "Wut? Pointers are neither 4 nor 8 bytes long?" ++#endif ++ ++#define ALIGN_PTR(p) ((void*) ALIGN((unsigned long) p)) ++#define ALIGN4_PTR(p) ((void*) ALIGN4((unsigned long) p)) ++#define ALIGN8_PTR(p) ((void*) ALIGN8((unsigned long) p)) ++ + static inline size_t ALIGN_TO(size_t l, size_t ali) { + return ((l + ali - 1) & ~(ali - 1)); + } + ++#define ALIGN_TO_PTR(p, ali) ((void*) ALIGN_TO((unsigned long) p)) ++ + #define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0])) + + /* +@@ -64,34 +85,35 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) { + * @member: the name of the member within the struct. + * + */ +-#define container_of(ptr, type, member) ({ \ +- const typeof( ((type *)0)->member ) *__mptr = (ptr); \ +- (type *)( (char *)__mptr - offsetof(type,member) );}) ++#define container_of(ptr, type, member) \ ++ __extension__ ({ \ ++ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ ++ (type *)( (char *)__mptr - offsetof(type,member) ); \ ++ }) + +-#ifndef MAX +-#define MAX(a,b) \ +- __extension__ ({ \ +- typeof(a) _a = (a); \ +- typeof(b) _b = (b); \ +- _a > _b ? _a : _b; \ ++#undef MAX ++#define MAX(a,b) \ ++ __extension__ ({ \ ++ typeof(a) _a = (a); \ ++ typeof(b) _b = (b); \ ++ _a > _b ? _a : _b; \ + }) +-#endif + +-#define MAX3(a,b,c) \ +- MAX(MAX(a,b),c) ++#define MAX3(x,y,z) \ ++ __extension__ ({ \ ++ typeof(x) _c = MAX(x,y); \ ++ MAX(_c, z); \ ++ }) + +-#ifndef MIN ++#undef MIN + #define MIN(a,b) \ + __extension__ ({ \ + typeof(a) _a = (a); \ + typeof(b) _b = (b); \ + _a < _b ? _a : _b; \ + }) +-#endif +- +-#define MIN3(a,b,c) \ +- MIN(MIN(a,b),c) + ++#ifndef CLAMP + #define CLAMP(x, low, high) \ + __extension__ ({ \ + typeof(x) _x = (x); \ +@@ -99,6 +121,7 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) { + typeof(high) _high = (high); \ + ((_x > _high) ? _high : ((_x < _low) ? _low : _x)); \ + }) ++#endif + + #define assert_se(expr) \ + do { \ +@@ -119,14 +142,21 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) { + log_assert_failed_unreachable(t, __FILE__, __LINE__, __PRETTY_FUNCTION__); \ + } while (false) + +-#define assert_cc(expr) \ +- do { \ +- switch (0) { \ +- case 0: \ +- case !!(expr): \ +- ; \ +- } \ ++#if defined(static_assert) ++#define assert_cc(expr) \ ++ do { \ ++ static_assert(expr, #expr); \ ++ } while (false) ++#else ++#define assert_cc(expr) \ ++ do { \ ++ switch (0) { \ ++ case 0: \ ++ case !!(expr): \ ++ ; \ ++ } \ + } while (false) ++#endif + + #define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p))) + #define UINT_TO_PTR(u) ((void*) ((uintptr_t) (u))) +@@ -149,6 +179,8 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) { + #define memzero(x,l) (memset((x), 0, (l))) + #define zero(x) (memzero(&(x), sizeof(x))) + ++#define CHAR_TO_STR(x) ((char[2]) { x, 0 }) ++ + #define char_array_0(x) x[sizeof(x)-1] = 0; + + #define IOVEC_SET_STRING(i, s) \ +@@ -187,6 +219,66 @@ static inline size_t IOVEC_INCREMENT(struct iovec *i, unsigned n, size_t k) { + return k; + } + +-#include "log.h" ++#define VA_FORMAT_ADVANCE(format, ap) \ ++do { \ ++ int _argtypes[128]; \ ++ size_t _i, _k; \ ++ _k = parse_printf_format((format), ELEMENTSOF(_argtypes), _argtypes); \ ++ assert(_k < ELEMENTSOF(_argtypes)); \ ++ for (_i = 0; _i < _k; _i++) { \ ++ if (_argtypes[_i] & PA_FLAG_PTR) { \ ++ (void) va_arg(ap, void*); \ ++ continue; \ ++ } \ ++ \ ++ switch (_argtypes[_i]) { \ ++ case PA_INT: \ ++ case PA_INT|PA_FLAG_SHORT: \ ++ case PA_CHAR: \ ++ (void) va_arg(ap, int); \ ++ break; \ ++ case PA_INT|PA_FLAG_LONG: \ ++ (void) va_arg(ap, long int); \ ++ break; \ ++ case PA_INT|PA_FLAG_LONG_LONG: \ ++ (void) va_arg(ap, long long int); \ ++ break; \ ++ case PA_WCHAR: \ ++ (void) va_arg(ap, wchar_t); \ ++ break; \ ++ case PA_WSTRING: \ ++ case PA_STRING: \ ++ case PA_POINTER: \ ++ (void) va_arg(ap, void*); \ ++ break; \ ++ case PA_FLOAT: \ ++ case PA_DOUBLE: \ ++ (void) va_arg(ap, double); \ ++ break; \ ++ case PA_DOUBLE|PA_FLAG_LONG_DOUBLE: \ ++ (void) va_arg(ap, long double); \ ++ break; \ ++ default: \ ++ assert_not_reached("Unknown format string argument."); \ ++ } \ ++ } \ ++} while(false) ++ ++ /* Because statfs.t_type can be int on some architecures, we have to cast ++ * the const magic to the type, otherwise the compiler warns about ++ * signed/unsigned comparison, because the magic can be 32 bit unsigned. ++ */ ++#define F_TYPE_CMP(a, b) (a == (typeof(a)) b) + +-#endif ++ ++/* Returns the number of chars needed to format variables of the ++ * specified type as a decimal string. Adds in extra space for a ++ * negative '-' prefix. */ ++ ++#define DECIMAL_STR_MAX(type) \ ++ (1+(sizeof(type) <= 1 ? 3 : \ ++ sizeof(type) <= 2 ? 5 : \ ++ sizeof(type) <= 4 ? 10 : \ ++ sizeof(type) <= 8 ? 20 : sizeof(int[-2*(sizeof(type) > 8)]))) ++ ++#include "log.h" +diff --git a/install/util.h b/install/util.h +index 9085935..e86b2f2 100644 +--- a/install/util.h ++++ b/install/util.h +@@ -507,6 +507,42 @@ void* memdup(const void *p, size_t l); + + int is_kernel_thread(pid_t pid); + ++static inline void freep(void *p) { ++ free(*(void**) p); ++} ++ ++static inline void fclosep(FILE **f) { ++ if (*f) ++ fclose(*f); ++} ++ ++static inline void pclosep(FILE **f) { ++ if (*f) ++ pclose(*f); ++} ++ ++static inline void closep(int *fd) { ++ if (*fd >= 0) ++ close_nointr_nofail(*fd); ++} ++ ++static inline void closedirp(DIR **d) { ++ if (*d) ++ closedir(*d); ++} ++ ++static inline void umaskp(mode_t *u) { ++ umask(*u); ++} ++ ++#define _cleanup_free_ _cleanup_(freep) ++#define _cleanup_fclose_ _cleanup_(fclosep) ++#define _cleanup_pclose_ _cleanup_(pclosep) ++#define _cleanup_close_ _cleanup_(closep) ++#define _cleanup_closedir_ _cleanup_(closedirp) ++#define _cleanup_umask_ _cleanup_(umaskp) ++#define _cleanup_globfree_ _cleanup_(globfree) ++ + int fd_inc_sndbuf(int fd, size_t n); + int fd_inc_rcvbuf(int fd, size_t n); + diff --git a/0042-_emergency_shell-Show-current-working-directory-corr.patch b/0042-_emergency_shell-Show-current-working-directory-corr.patch new file mode 100644 index 0000000..fe40aa2 --- /dev/null +++ b/0042-_emergency_shell-Show-current-working-directory-corr.patch @@ -0,0 +1,51 @@ +From b6f2e05819d9867b7ca69365091ff480556fcfe9 Mon Sep 17 00:00:00 2001 +From: WANG Chao +Date: Fri, 26 Apr 2013 15:16:19 +0800 +Subject: [PATCH] _emergency_shell: Show current working directory correctly in + shell. + +When dropped to emergency shell, for example, use rd.break=pre-pivot, +the PS1 won't correctly show current directory we're in: + +pre-pivot:/# cd /sysroot/ +pre-pivot:/# +(still shows "/") + +Let's take a look at PS1 variable: + +(I'm adding prefix/suffix 'x' to make it clear): +pre-pivot:/# echo x${PS1}x +xpre-pivot:/# x +(PS1 isn't dynamic) + +Regarding the current dracut code, it should be: + +pre-pivot:/# cd /sysroot/etc +pre-pivot:/sysroot/etc# + +With this patch: + +pre-pivot:/# echo x${PS1}x +xpre-pivot:${PWD}# x +(Now PS1 is dynamic, it will show the directory correctly) + +I tested for both normal boot and kdump boot. + +Signed-off-by: WANG Chao +--- + modules.d/99base/dracut-lib.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh +index 9bd25f4..5cb0add 100755 +--- a/modules.d/99base/dracut-lib.sh ++++ b/modules.d/99base/dracut-lib.sh +@@ -926,7 +926,7 @@ _emergency_shell() + local _name="$1" + if [ -n "$DRACUT_SYSTEMD" ]; then + > /.console_lock +- echo "PS1=\"$_name:\${PWD}# \"" >/etc/profile ++ echo "PS1=\"$_name:\\\${PWD}# \"" >/etc/profile + systemctl start dracut-emergency.service + rm -f /etc/profile + rm -f /.console_lock diff --git a/0043-test-use-grep-option-F-and-install-etc-os-release.patch b/0043-test-use-grep-option-F-and-install-etc-os-release.patch new file mode 100644 index 0000000..5f5f9e1 --- /dev/null +++ b/0043-test-use-grep-option-F-and-install-etc-os-release.patch @@ -0,0 +1,584 @@ +From 021b2fddff2db93c9936b0fd241b806c270b830a Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Tue, 30 Apr 2013 18:54:33 +0200 +Subject: [PATCH] test: use grep option "-F" and install /etc/os-release + +--- + test/TEST-01-BASIC/test.sh | 5 +++-- + test/TEST-02-SYSTEMD/test.sh | 5 +++-- + test/TEST-03-USR-MOUNT/test.sh | 5 +++-- + test/TEST-04-FULL-SYSTEMD/test.sh | 4 ++-- + test/TEST-10-RAID/test.sh | 7 ++++--- + test/TEST-11-LVM/test.sh | 5 +++-- + test/TEST-12-RAID-DEG/create-root.sh | 2 +- + test/TEST-12-RAID-DEG/test.sh | 11 ++++++----- + test/TEST-13-ENC-RAID-LVM/create-root.sh | 2 +- + test/TEST-13-ENC-RAID-LVM/test.sh | 11 ++++++----- + test/TEST-15-BTRFSRAID/create-root.sh | 10 +++++----- + test/TEST-15-BTRFSRAID/test.sh | 6 +++--- + test/TEST-16-DMSQUASH/test.sh | 3 ++- + test/TEST-20-NFS/test.sh | 4 +++- + test/TEST-30-ISCSI/test.sh | 6 ++++-- + test/TEST-40-NBD/test.sh | 9 ++++++--- + test/TEST-50-MULTINIC/test.sh | 6 ++++-- + test/TEST-99-RPM/test.sh | 2 +- + test/old.TEST-14-IMSM/test.sh | 4 ++-- + 19 files changed, 62 insertions(+), 45 deletions(-) + +diff --git a/test/TEST-01-BASIC/test.sh b/test/TEST-01-BASIC/test.sh +index 84f4b7d..d39556c 100755 +--- a/test/TEST-01-BASIC/test.sh ++++ b/test/TEST-01-BASIC/test.sh +@@ -16,7 +16,7 @@ test_run() { + -watchdog i6300esb -watchdog-action poweroff \ + -append "root=LABEL=dracut rw systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.debug console=ttyS0,115200n81 $DEBUGFAIL" \ + -initrd $TESTDIR/initramfs.testing || return 1 +- grep -m 1 -q dracut-root-block-success $TESTDIR/result || return 1 ++ grep -F -m 1 -q dracut-root-block-success $TESTDIR/result || return 1 + } + + test_setup() { +@@ -40,6 +40,7 @@ test_setup() { + inst "$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script" + inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup" + dracut_install grep ++ inst_simple /etc/os-release + inst ./test-init.sh /sbin/init + find_binary plymouth >/dev/null && dracut_install plymouth + (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp ) +@@ -74,7 +75,7 @@ test_setup() { + -kernel "/boot/vmlinuz-$kernel" \ + -append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \ + -initrd $TESTDIR/initramfs.makeroot || return 1 +- grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1 ++ grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1 + + + ( +diff --git a/test/TEST-02-SYSTEMD/test.sh b/test/TEST-02-SYSTEMD/test.sh +index 459cf03..c141527 100755 +--- a/test/TEST-02-SYSTEMD/test.sh ++++ b/test/TEST-02-SYSTEMD/test.sh +@@ -12,7 +12,7 @@ test_run() { + -net none -kernel /boot/vmlinuz-$KVERSION \ + -append "root=LABEL=dracut rw loglevel=77 systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug init=/sbin/init $DEBUGFAIL" \ + -initrd $TESTDIR/initramfs.testing +- grep -m 1 -q dracut-root-block-success $TESTDIR/root.ext3 || return 1 ++ grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext3 || return 1 + } + + test_setup() { +@@ -36,6 +36,7 @@ test_setup() { + inst "$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script" + inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup" + dracut_install grep ++ inst_simple /etc/os-release + inst ./test-init.sh /sbin/init + find_binary plymouth >/dev/null && dracut_install plymouth + (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp ) +@@ -70,7 +71,7 @@ test_setup() { + -kernel "/boot/vmlinuz-$kernel" \ + -append "root=/dev/fakeroot rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \ + -initrd $TESTDIR/initramfs.makeroot || return 1 +- grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1 ++ grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1 + + + ( +diff --git a/test/TEST-03-USR-MOUNT/test.sh b/test/TEST-03-USR-MOUNT/test.sh +index ca7dc12..01a6915 100755 +--- a/test/TEST-03-USR-MOUNT/test.sh ++++ b/test/TEST-03-USR-MOUNT/test.sh +@@ -29,7 +29,7 @@ client_run() { + return 1 + fi + +- if ! grep -m 1 -q dracut-root-block-success $TESTDIR/result; then ++ if ! grep -F -m 1 -q dracut-root-block-success $TESTDIR/result; then + echo "CLIENT TEST END: $test_name [FAILED]" + return 1 + fi +@@ -68,6 +68,7 @@ test_setup() { + inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup" + dracut_install grep + inst_simple ./fstab /etc/fstab ++ inst_simple /etc/os-release + inst ./test-init.sh /sbin/init + find_binary plymouth >/dev/null && dracut_install plymouth + (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp ) +@@ -109,7 +110,7 @@ test_setup() { + -kernel "/boot/vmlinuz-$kernel" \ + -append "root=/dev/dracut/root rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \ + -initrd $TESTDIR/initramfs.makeroot || return 1 +- grep -m 1 -q dracut-root-block-created $TESTDIR/root.btrfs || return 1 ++ grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.btrfs || return 1 + + + ( +diff --git a/test/TEST-04-FULL-SYSTEMD/test.sh b/test/TEST-04-FULL-SYSTEMD/test.sh +index d3dc7ef..6c972a3 100755 +--- a/test/TEST-04-FULL-SYSTEMD/test.sh ++++ b/test/TEST-04-FULL-SYSTEMD/test.sh +@@ -30,7 +30,7 @@ client_run() { + return 1 + fi + +- if ! grep -m 1 -q dracut-root-block-success $TESTDIR/result; then ++ if ! grep -F -m 1 -q dracut-root-block-success $TESTDIR/result; then + echo "CLIENT TEST END: $test_name [FAILED]" + return 1 + fi +@@ -251,7 +251,7 @@ EOF + -kernel "/boot/vmlinuz-$kernel" \ + -append "root=/dev/fakeroot rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \ + -initrd $TESTDIR/initramfs.makeroot || return 1 +- grep -m 1 -q dracut-root-block-created $TESTDIR/root.btrfs || return 1 ++ grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.btrfs || return 1 + + + ( +diff --git a/test/TEST-10-RAID/test.sh b/test/TEST-10-RAID/test.sh +index e11c518..ffce8fc 100755 +--- a/test/TEST-10-RAID/test.sh ++++ b/test/TEST-10-RAID/test.sh +@@ -14,7 +14,7 @@ test_run() { + -net none -kernel /boot/vmlinuz-$KVERSION \ + -append "root=/dev/dracut/root rd.auto rw rd.retry=10 console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \ + -initrd $TESTDIR/initramfs.testing +- grep -m 1 -q dracut-root-block-success $DISKIMAGE || return 1 ++ grep -F -m 1 -q dracut-root-block-success $DISKIMAGE || return 1 + } + + test_setup() { +@@ -35,6 +35,7 @@ test_setup() { + [ -f ${_terminfodir}/l/linux ] && break + done + dracut_install -o ${_terminfodir}/l/linux ++ inst_simple /etc/os-release + inst ./test-init.sh /sbin/init + inst "$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script" + inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup" +@@ -71,8 +72,8 @@ test_setup() { + -kernel "/boot/vmlinuz-$kernel" \ + -append "root=/dev/cannotreach rw rootfstype=ext2 console=ttyS0,115200n81 selinux=0" \ + -initrd $TESTDIR/initramfs.makeroot || return 1 +- grep -m 1 -q dracut-root-block-created $DISKIMAGE || return 1 +- eval $(grep -a -m 1 ID_FS_UUID $DISKIMAGE) ++ grep -F -m 1 -q dracut-root-block-created $DISKIMAGE || return 1 ++ eval $(grep -F -a -m 1 ID_FS_UUID $DISKIMAGE) + + ( + export initdir=$TESTDIR/overlay +diff --git a/test/TEST-11-LVM/test.sh b/test/TEST-11-LVM/test.sh +index d876e55..65cf588 100755 +--- a/test/TEST-11-LVM/test.sh ++++ b/test/TEST-11-LVM/test.sh +@@ -13,7 +13,7 @@ test_run() { + -net none -kernel /boot/vmlinuz-$KVERSION \ + -append "root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \ + -initrd $TESTDIR/initramfs.testing +- grep -m 1 -q dracut-root-block-success $TESTDIR/root.ext2 || return 1 ++ grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2 || return 1 + } + + test_setup() { +@@ -34,6 +34,7 @@ test_setup() { + inst "$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script" + inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup" + dracut_install grep ++ inst_simple /etc/os-release + inst ./test-init.sh /sbin/init + find_binary plymouth >/dev/null && dracut_install plymouth + (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp ) +@@ -65,7 +66,7 @@ test_setup() { + -kernel "/boot/vmlinuz-$kernel" \ + -append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \ + -initrd $TESTDIR/initramfs.makeroot || return 1 +- grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1 ++ grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1 + ( + export initdir=$TESTDIR/overlay + . $basedir/dracut-functions.sh +diff --git a/test/TEST-12-RAID-DEG/create-root.sh b/test/TEST-12-RAID-DEG/create-root.sh +index 07d0b39..5723b0b 100755 +--- a/test/TEST-12-RAID-DEG/create-root.sh ++++ b/test/TEST-12-RAID-DEG/create-root.sh +@@ -39,7 +39,7 @@ udevadm settle + cryptsetup luksClose /dev/mapper/dracut_crypt_test + udevadm settle + mdadm -W /dev/md0 || : +-mdadm --detail --export /dev/md0 |grep MD_UUID > /tmp/mduuid ++mdadm --detail --export /dev/md0 |grep -F MD_UUID > /tmp/mduuid + . /tmp/mduuid + eval $(udevadm info --query=env --name=/dev/md0|while read line; do [ "$line" != "${line#*ID_FS_UUID*}" ] && echo $line; done;) + { echo "dracut-root-block-created"; echo MD_UUID=$MD_UUID; echo "ID_FS_UUID=$ID_FS_UUID";} > /dev/sda1 +diff --git a/test/TEST-12-RAID-DEG/test.sh b/test/TEST-12-RAID-DEG/test.sh +index 1eae41a..1b5e756 100755 +--- a/test/TEST-12-RAID-DEG/test.sh ++++ b/test/TEST-12-RAID-DEG/test.sh +@@ -21,7 +21,7 @@ client_run() { + -net none -kernel /boot/vmlinuz-$KVERSION \ + -append "$* root=LABEL=root rw rd.retry=10 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL " \ + -initrd $TESTDIR/initramfs.testing +- if ! grep -m 1 -q dracut-root-block-success $TESTDIR/root.ext2; then ++ if ! grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2; then + echo "CLIENT TEST END: $@ [FAIL]" + return 1; + fi +@@ -32,7 +32,7 @@ client_run() { + } + + test_run() { +- eval $(grep --binary-files=text -m 1 MD_UUID $TESTDIR/root.ext2) ++ eval $(grep -F --binary-files=text -m 1 MD_UUID $TESTDIR/root.ext2) + echo "MD_UUID=$MD_UUID" + read LUKS_UUID < $TESTDIR/luksuuid + +@@ -75,6 +75,7 @@ test_setup() { + inst "$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script" + inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup" + dracut_install grep ++ inst_simple /etc/os-release + inst ./test-init.sh /sbin/init + find_binary plymouth >/dev/null && dracut_install plymouth + (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp ) +@@ -111,9 +112,9 @@ test_setup() { + -append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \ + -initrd $TESTDIR/initramfs.makeroot || return 1 + +- grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1 +- eval $(grep --binary-files=text -m 1 MD_UUID $TESTDIR/root.ext2) +- eval $(grep -a -m 1 ID_FS_UUID $TESTDIR/root.ext2) ++ grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1 ++ eval $(grep -F --binary-files=text -m 1 MD_UUID $TESTDIR/root.ext2) ++ eval $(grep -F -a -m 1 ID_FS_UUID $TESTDIR/root.ext2) + echo $ID_FS_UUID > $TESTDIR/luksuuid + + ( +diff --git a/test/TEST-13-ENC-RAID-LVM/create-root.sh b/test/TEST-13-ENC-RAID-LVM/create-root.sh +index c8b6781..c4c7a17 100755 +--- a/test/TEST-13-ENC-RAID-LVM/create-root.sh ++++ b/test/TEST-13-ENC-RAID-LVM/create-root.sh +@@ -48,7 +48,7 @@ cryptsetup luksClose /dev/mapper/dracut_sda4 && \ + { + echo "dracut-root-block-created" + for i in /dev/sda[234]; do +- udevadm info --query=env --name=$i|grep 'ID_FS_UUID=' ++ udevadm info --query=env --name=$i|grep -F 'ID_FS_UUID=' + done + } >/dev/sda1 + poweroff -f +diff --git a/test/TEST-13-ENC-RAID-LVM/test.sh b/test/TEST-13-ENC-RAID-LVM/test.sh +index b8fc7ff..93d48a5 100755 +--- a/test/TEST-13-ENC-RAID-LVM/test.sh ++++ b/test/TEST-13-ENC-RAID-LVM/test.sh +@@ -21,7 +21,7 @@ test_run() { + -net none -kernel /boot/vmlinuz-$KVERSION \ + -append "root=/dev/dracut/root rw rd.auto rd.retry=20 console=ttyS0,115200n81 selinux=0 rd.debug rootwait $LUKSARGS $DEBUGFAIL" \ + -initrd $TESTDIR/initramfs.testing +- grep -m 1 -q dracut-root-block-success $TESTDIR/check-success.img || return 1 ++ grep -F -m 1 -q dracut-root-block-success $TESTDIR/check-success.img || return 1 + echo "CLIENT TEST END: [OK]" + + dd if=/dev/zero of=$TESTDIR/check-success.img bs=1M count=1 +@@ -34,7 +34,7 @@ test_run() { + -net none -kernel /boot/vmlinuz-$KVERSION \ + -append "root=/dev/dracut/root rw quiet rd.auto rd.retry=20 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \ + -initrd $TESTDIR/initramfs.testing +- grep -m 1 -q dracut-root-block-success $TESTDIR/check-success.img || return 1 ++ grep -F -m 1 -q dracut-root-block-success $TESTDIR/check-success.img || return 1 + echo "CLIENT TEST END: [OK]" + + dd if=/dev/zero of=$TESTDIR/check-success.img bs=1M count=1 +@@ -47,7 +47,7 @@ test_run() { + -net none -kernel /boot/vmlinuz-$KVERSION \ + -append "root=/dev/dracut/root rw quiet rd.auto rd.retry=10 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL rd.luks.uuid=failme" \ + -initrd $TESTDIR/initramfs.testing +- grep -m 1 -q dracut-root-block-success $TESTDIR/check-success.img && return 1 ++ grep -F -m 1 -q dracut-root-block-success $TESTDIR/check-success.img && return 1 + echo "CLIENT TEST END: [OK]" + + return 0 +@@ -72,6 +72,7 @@ test_setup() { + inst "$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script" + inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup" + dracut_install grep ++ inst_simple /etc/os-release + inst ./test-init.sh /sbin/init + find_binary plymouth >/dev/null && dracut_install plymouth + (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp ) +@@ -102,8 +103,8 @@ test_setup() { + -kernel "/boot/vmlinuz-$kernel" \ + -append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \ + -initrd $TESTDIR/initramfs.makeroot || return 1 +- grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1 +- cryptoUUIDS=$(grep --binary-files=text -m 3 ID_FS_UUID $TESTDIR/root.ext2) ++ grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1 ++ cryptoUUIDS=$(grep -F --binary-files=text -m 3 ID_FS_UUID $TESTDIR/root.ext2) + for uuid in $cryptoUUIDS; do + eval $uuid + printf ' rd.luks.uuid=luks-%s ' $ID_FS_UUID +diff --git a/test/TEST-15-BTRFSRAID/create-root.sh b/test/TEST-15-BTRFSRAID/create-root.sh +index cd51935..69f9280 100755 +--- a/test/TEST-15-BTRFSRAID/create-root.sh ++++ b/test/TEST-15-BTRFSRAID/create-root.sh +@@ -5,15 +5,15 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do + done + udevadm control --reload + # save a partition at the beginning for future flagging purposes +-sfdisk -C 655600 -H 2 -S 32 -L /dev/sda </dev/null && dracut_install dhcpd + [ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd ++ inst_simple /etc/os-release + inst ./server-init.sh /sbin/init + inst ./hosts /etc/hosts + inst ./dhcpd.conf /etc/dhcpd.conf +diff --git a/test/TEST-40-NBD/test.sh b/test/TEST-40-NBD/test.sh +index 208b784..9ad95b9 100755 +--- a/test/TEST-40-NBD/test.sh ++++ b/test/TEST-40-NBD/test.sh +@@ -64,7 +64,7 @@ client_test() { + -append "$cmdline $DEBUGFAIL rd.auto rd.info rd.retry=10 ro console=ttyS0,115200n81 selinux=0 " \ + -initrd $TESTDIR/initramfs.testing + +- if [[ $? -ne 0 ]] || ! grep -m 1 -q nbd-OK $TESTDIR/flag.img; then ++ if [[ $? -ne 0 ]] || ! grep -F -m 1 -q nbd-OK $TESTDIR/flag.img; then + echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]" + return 1 + fi +@@ -205,6 +205,7 @@ make_encrypted_root() { + done + dracut_install -o ${_terminfodir}/l/linux + inst ./client-init.sh /sbin/init ++ inst_simple /etc/os-release + find_binary plymouth >/dev/null && dracut_install plymouth + cp -a /etc/ld.so.conf* $initdir/etc + sudo ldconfig -r "$initdir" +@@ -239,8 +240,8 @@ make_encrypted_root() { + -kernel "/boot/vmlinuz-$kernel" \ + -append "root=/dev/fakeroot rw quiet console=ttyS0,115200n81 selinux=0" \ + -initrd $TESTDIR/initramfs.makeroot || return 1 +- grep -m 1 -q dracut-root-block-created $TESTDIR/flag.img || return 1 +- grep -a -m 1 ID_FS_UUID $TESTDIR/flag.img > $TESTDIR/luks.uuid ++ grep -F -m 1 -q dracut-root-block-created $TESTDIR/flag.img || return 1 ++ grep -F -a -m 1 ID_FS_UUID $TESTDIR/flag.img > $TESTDIR/luks.uuid + } + + make_client_root() { +@@ -262,6 +263,7 @@ make_client_root() { + done + dracut_install -o ${_terminfodir}/l/linux + inst ./client-init.sh /sbin/init ++ inst_simple /etc/os-release + inst /etc/nsswitch.conf /etc/nsswitch.conf + inst /etc/passwd /etc/passwd + inst /etc/group /etc/group +@@ -303,6 +305,7 @@ make_server_root() { + type -P dhcpd >/dev/null && dracut_install dhcpd + [ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd + inst ./server-init.sh /sbin/init ++ inst_simple /etc/os-release + inst ./hosts /etc/hosts + inst ./dhcpd.conf /etc/dhcpd.conf + inst /etc/nsswitch.conf /etc/nsswitch.conf +diff --git a/test/TEST-50-MULTINIC/test.sh b/test/TEST-50-MULTINIC/test.sh +index 5cb0971..e2a8ab9 100755 +--- a/test/TEST-50-MULTINIC/test.sh ++++ b/test/TEST-50-MULTINIC/test.sh +@@ -61,7 +61,7 @@ client_test() { + -append "$cmdline $DEBUGFAIL rd.retry=5 rd.info ro console=ttyS0,115200n81 selinux=0 init=/sbin/init" \ + -initrd $TESTDIR/initramfs.testing + +- if [[ $? -ne 0 ]] || ! grep -m 1 -q OK $TESTDIR/client.img; then ++ if [[ $? -ne 0 ]] || ! grep -F -m 1 -q OK $TESTDIR/client.img; then + echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]" + return 1 + fi +@@ -69,7 +69,7 @@ client_test() { + + for i in $check ; do + echo $i +- if ! grep -m 1 -q $i $TESTDIR/client.img; then ++ if ! grep -F -m 1 -q $i $TESTDIR/client.img; then + echo "CLIENT TEST END: $test_name [FAILED - BAD IF]" + return 1 + fi +@@ -170,6 +170,7 @@ test_setup() { + type -P dhcpd >/dev/null && dracut_install dhcpd + [ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd + instmods nfsd sunrpc ipv6 lockd af_packet ++ inst_simple /etc/os-release + inst ./server-init.sh /sbin/init + inst ./hosts /etc/hosts + inst ./exports /etc/exports +@@ -208,6 +209,7 @@ test_setup() { + [ -f ${_terminfodir}/l/linux ] && break + done + dracut_install -o ${_terminfodir}/l/linux ++ inst_simple /etc/os-release + inst ./client-init.sh /sbin/init + ( + cd "$initdir" +diff --git a/test/TEST-99-RPM/test.sh b/test/TEST-99-RPM/test.sh +index f030cb0..8ae7f8e 100755 +--- a/test/TEST-99-RPM/test.sh ++++ b/test/TEST-99-RPM/test.sh +@@ -53,7 +53,7 @@ find / -xdev -type f -not -path '/var/*' \ + -not -path '/boot/*0-rescue*' \ + -not -path '/dev/null' \ + -exec rpm -qf '{}' ';' | \ +- fgrep 'not owned' &> /test.output ++ grep -F 'not owned' &> /test.output + exit + EOF + +diff --git a/test/old.TEST-14-IMSM/test.sh b/test/old.TEST-14-IMSM/test.sh +index cd2d715..d69f00d 100755 +--- a/test/old.TEST-14-IMSM/test.sh ++++ b/test/old.TEST-14-IMSM/test.sh +@@ -17,7 +17,7 @@ client_run() { + -net none -kernel /boot/vmlinuz-$KVERSION \ + -append "$@ root=LABEL=root rw quiet rd.retry=5 rd.debug console=ttyS0,115200n81 selinux=0 rd.info $DEBUGFAIL" \ + -initrd $TESTDIR/initramfs.testing +- if ! grep -m 1 -q dracut-root-block-success $TESTDIR/root.ext2; then ++ if ! grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2; then + echo "CLIENT TEST END: $@ [FAIL]" + return 1; + fi +@@ -102,7 +102,7 @@ test_setup() { + -kernel "/boot/vmlinuz-$kernel" \ + -append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \ + -initrd $TESTDIR/initramfs.makeroot || return 1 +- grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1 ++ grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1 + ( + export initdir=$TESTDIR/overlay + . $basedir/dracut-functions.sh diff --git a/0044-zfcp-match-udev-rule-against-KERNEL-zfcp.patch b/0044-zfcp-match-udev-rule-against-KERNEL-zfcp.patch new file mode 100644 index 0000000..18bdaf5 --- /dev/null +++ b/0044-zfcp-match-udev-rule-against-KERNEL-zfcp.patch @@ -0,0 +1,19 @@ +From 9584c6ae903fe6918f4a6b3ad0a5a295c1dbdc18 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Tue, 30 Apr 2013 18:55:12 +0200 +Subject: [PATCH] zfcp: match udev rule against KERNEL=="zfcp" + +zfcp_cfdc will go away in the future + + tt +--- + modules.d/95zfcp/56-zfcp.rules | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/modules.d/95zfcp/56-zfcp.rules b/modules.d/95zfcp/56-zfcp.rules +index 5e846a4..5558f8b 100644 +--- a/modules.d/95zfcp/56-zfcp.rules ++++ b/modules.d/95zfcp/56-zfcp.rules +@@ -1 +1 @@ +-KERNEL=="zfcp_cfdc", RUN+="/sbin/zfcpconf.sh" ++KERNEL=="zfcp", RUN+="/sbin/zfcpconf.sh" diff --git a/dracut.spec b/dracut.spec index bece2ed..2900710 100644 --- a/dracut.spec +++ b/dracut.spec @@ -10,7 +10,7 @@ Name: dracut Version: 027 -Release: 39.git20130425%{?dist} +Release: 45.git20130430%{?dist} Summary: Initramfs generator using udev %if 0%{?fedora} || 0%{?rhel} @@ -67,6 +67,12 @@ Patch35: 0035-dracut-install-error-out-if-ldd-reports-no-execution.patch Patch36: 0036-shutdown-redirect-output-to-dev-console-only-if-it-e.patch Patch37: 0037-fixup-3be5d63c2f.patch Patch38: 0038-fixed-fips-mode.patch +Patch39: 0039-dracut.sh-do-not-preunlink-for-fips-mode.patch +Patch40: 0040-fips-do-not-fail-immediatly-after-loading-the-crypto.patch +Patch41: 0041-dracut-install-make-use-of-_cleanup_-macros.patch +Patch42: 0042-_emergency_shell-Show-current-working-directory-corr.patch +Patch43: 0043-test-use-grep-option-F-and-install-etc-os-release.patch +Patch44: 0044-zfcp-match-udev-rule-against-KERNEL-zfcp.patch BuildRequires: dash bash git @@ -475,6 +481,10 @@ rm -rf $RPM_BUILD_ROOT %{dracutlibdir}/dracut.conf.d/02-norescue.conf %changelog +* Tue Apr 30 2013 Harald Hoyer 027-45.git20130430 +- fixed fips mode more +Resolves: rhbz#956521 + * Thu Apr 25 2013 Harald Hoyer 027-39.git20130425 - fix shutdown, if /dev/console is not writeable - fixed fips mode