|
|
3e09d8 |
From 3f4082478351da51d7c4c8907ec691238a384313 Mon Sep 17 00:00:00 2001
|
|
|
3e09d8 |
From: Michal Sekletar <msekleta@redhat.com>
|
|
|
3e09d8 |
Date: Wed, 22 Nov 2023 20:40:31 +0100
|
|
|
3e09d8 |
Subject: [PATCH] Revert "fstab-generator: Chase symlinks where possible
|
|
|
3e09d8 |
(#6293)"
|
|
|
3e09d8 |
|
|
|
3e09d8 |
This reverts commit a4c51f1bb38f272fb9c3dbaa33f1f383639ce345.
|
|
|
3e09d8 |
|
|
|
3e09d8 |
Resolves: RHEL-17164
|
|
|
3e09d8 |
---
|
|
|
3e09d8 |
man/systemd-fstab-generator.xml | 8 -----
|
|
|
3e09d8 |
man/systemd.mount.xml | 5 ++--
|
|
|
3e09d8 |
src/fstab-generator/fstab-generator.c | 42 +++++----------------------
|
|
|
3e09d8 |
3 files changed, 10 insertions(+), 45 deletions(-)
|
|
|
3e09d8 |
|
|
|
3e09d8 |
diff --git a/man/systemd-fstab-generator.xml b/man/systemd-fstab-generator.xml
|
|
|
3e09d8 |
index 6f45c680cc..bdc2dc1d0e 100644
|
|
|
3e09d8 |
--- a/man/systemd-fstab-generator.xml
|
|
|
3e09d8 |
+++ b/man/systemd-fstab-generator.xml
|
|
|
3e09d8 |
@@ -71,14 +71,6 @@
|
|
|
3e09d8 |
for more information about special <filename>/etc/fstab</filename>
|
|
|
3e09d8 |
mount options this generator understands.</para>
|
|
|
3e09d8 |
|
|
|
3e09d8 |
- <para>One special topic is handling of symbolic links. Historical init
|
|
|
3e09d8 |
- implementations supported symlinks in <filename>/etc/fstab</filename>.
|
|
|
3e09d8 |
- Because mount units will refuse mounts where the target is a symbolic link,
|
|
|
3e09d8 |
- this generator will resolve any symlinks as far as possible when processing
|
|
|
3e09d8 |
- <filename>/etc/fstab</filename> in order to enhance backwards compatibility.
|
|
|
3e09d8 |
- If a symlink target does not exist at the time that this generator runs, it
|
|
|
3e09d8 |
- is assumed that the symlink target is the final target of the mount.</para>
|
|
|
3e09d8 |
-
|
|
|
3e09d8 |
<para><filename>systemd-fstab-generator</filename> implements
|
|
|
3e09d8 |
<citerefentry><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
|
|
|
3e09d8 |
</refsect1>
|
|
|
3e09d8 |
diff --git a/man/systemd.mount.xml b/man/systemd.mount.xml
|
|
|
3e09d8 |
index 5021db5584..1590c44cec 100644
|
|
|
3e09d8 |
--- a/man/systemd.mount.xml
|
|
|
3e09d8 |
+++ b/man/systemd.mount.xml
|
|
|
3e09d8 |
@@ -295,9 +295,8 @@
|
|
|
3e09d8 |
|
|
|
3e09d8 |
<varlistentry>
|
|
|
3e09d8 |
<term><varname>Where=</varname></term>
|
|
|
3e09d8 |
- <listitem><para>Takes an absolute path of a directory for the
|
|
|
3e09d8 |
- mount point; in particular, the destination cannot be a symbolic
|
|
|
3e09d8 |
- link. If the mount point does not exist at the time of
|
|
|
3e09d8 |
+ <listitem><para>Takes an absolute path of a directory of the
|
|
|
3e09d8 |
+ mount point. If the mount point does not exist at the time of
|
|
|
3e09d8 |
mounting, it is created. This string must be reflected in the
|
|
|
3e09d8 |
unit filename. (See above.) This option is
|
|
|
3e09d8 |
mandatory.</para></listitem>
|
|
|
3e09d8 |
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
|
|
|
3e09d8 |
index 91603b08f4..23b5457e43 100644
|
|
|
3e09d8 |
--- a/src/fstab-generator/fstab-generator.c
|
|
|
3e09d8 |
+++ b/src/fstab-generator/fstab-generator.c
|
|
|
3e09d8 |
@@ -240,7 +240,6 @@ static int write_idle_timeout(FILE *f, const char *where, const char *opts) {
|
|
|
3e09d8 |
static int add_mount(
|
|
|
3e09d8 |
const char *what,
|
|
|
3e09d8 |
const char *where,
|
|
|
3e09d8 |
- const char *original_where,
|
|
|
3e09d8 |
const char *fstype,
|
|
|
3e09d8 |
const char *opts,
|
|
|
3e09d8 |
int passno,
|
|
|
3e09d8 |
@@ -328,14 +327,12 @@ static int add_mount(
|
|
|
3e09d8 |
}
|
|
|
3e09d8 |
|
|
|
3e09d8 |
fprintf(f,
|
|
|
3e09d8 |
- "\n"
|
|
|
3e09d8 |
+ "\n"
|
|
|
3e09d8 |
"[Mount]\n"
|
|
|
3e09d8 |
- "What=%s\n",
|
|
|
3e09d8 |
- what);
|
|
|
3e09d8 |
-
|
|
|
3e09d8 |
- if (original_where)
|
|
|
3e09d8 |
- fprintf(f, "# Canonicalized from %s\n", original_where);
|
|
|
3e09d8 |
- fprintf(f, "Where=%s\n", where);
|
|
|
3e09d8 |
+ "What=%s\n"
|
|
|
3e09d8 |
+ "Where=%s\n",
|
|
|
3e09d8 |
+ what,
|
|
|
3e09d8 |
+ where);
|
|
|
3e09d8 |
|
|
|
3e09d8 |
if (!isempty(fstype) && !streq(fstype, "auto"))
|
|
|
3e09d8 |
fprintf(f, "Type=%s\n", fstype);
|
|
|
3e09d8 |
@@ -439,7 +436,7 @@ static int parse_fstab(bool initrd) {
|
|
|
3e09d8 |
}
|
|
|
3e09d8 |
|
|
|
3e09d8 |
while ((me = getmntent(f))) {
|
|
|
3e09d8 |
- _cleanup_free_ char *where = NULL, *what = NULL, *canonical_where = NULL;
|
|
|
3e09d8 |
+ _cleanup_free_ char *where = NULL, *what = NULL;
|
|
|
3e09d8 |
bool noauto, nofail;
|
|
|
3e09d8 |
int k;
|
|
|
3e09d8 |
|
|
|
3e09d8 |
@@ -459,28 +456,8 @@ static int parse_fstab(bool initrd) {
|
|
|
3e09d8 |
if (!where)
|
|
|
3e09d8 |
return log_oom();
|
|
|
3e09d8 |
|
|
|
3e09d8 |
- if (is_path(where)) {
|
|
|
3e09d8 |
+ if (is_path(where))
|
|
|
3e09d8 |
path_kill_slashes(where);
|
|
|
3e09d8 |
- /* Follow symlinks here; see 5261ba901845c084de5a8fd06500ed09bfb0bd80 which makes sense for
|
|
|
3e09d8 |
- * mount units, but causes problems since it historically worked to have symlinks in e.g.
|
|
|
3e09d8 |
- * /etc/fstab. So we canonicalize here. Note that we use CHASE_NONEXISTENT to handle the case
|
|
|
3e09d8 |
- * where a symlink refers to another mount target; this works assuming the sub-mountpoint
|
|
|
3e09d8 |
- * target is the final directory.
|
|
|
3e09d8 |
- */
|
|
|
3e09d8 |
- r = chase_symlinks(where, initrd ? "/sysroot" : NULL,
|
|
|
3e09d8 |
- CHASE_PREFIX_ROOT | CHASE_NONEXISTENT,
|
|
|
3e09d8 |
- &canonical_where);
|
|
|
3e09d8 |
- if (r < 0)
|
|
|
3e09d8 |
- /* In this case for now we continue on as if it wasn't a symlink */
|
|
|
3e09d8 |
- log_warning_errno(r, "Failed to read symlink target for %s: %m", where);
|
|
|
3e09d8 |
- else {
|
|
|
3e09d8 |
- if (streq(canonical_where, where))
|
|
|
3e09d8 |
- canonical_where = mfree(canonical_where);
|
|
|
3e09d8 |
- else
|
|
|
3e09d8 |
- log_debug("Canonicalized what=%s where=%s to %s",
|
|
|
3e09d8 |
- what, where, canonical_where);
|
|
|
3e09d8 |
- }
|
|
|
3e09d8 |
- }
|
|
|
3e09d8 |
|
|
|
3e09d8 |
noauto = fstab_test_yes_no_option(me->mnt_opts, "noauto\0" "auto\0");
|
|
|
3e09d8 |
nofail = fstab_test_yes_no_option(me->mnt_opts, "nofail\0" "fail\0");
|
|
|
3e09d8 |
@@ -505,8 +482,7 @@ static int parse_fstab(bool initrd) {
|
|
|
3e09d8 |
post = SPECIAL_LOCAL_FS_TARGET;
|
|
|
3e09d8 |
|
|
|
3e09d8 |
k = add_mount(what,
|
|
|
3e09d8 |
- canonical_where ?: where,
|
|
|
3e09d8 |
- canonical_where ? where: NULL,
|
|
|
3e09d8 |
+ where,
|
|
|
3e09d8 |
me->mnt_type,
|
|
|
3e09d8 |
me->mnt_opts,
|
|
|
3e09d8 |
me->mnt_passno,
|
|
|
3e09d8 |
@@ -550,7 +526,6 @@ static int add_sysroot_mount(void) {
|
|
|
3e09d8 |
log_debug("Found entry what=%s where=/sysroot type=%s", what, strna(arg_root_fstype));
|
|
|
3e09d8 |
return add_mount(what,
|
|
|
3e09d8 |
"/sysroot",
|
|
|
3e09d8 |
- NULL,
|
|
|
3e09d8 |
arg_root_fstype,
|
|
|
3e09d8 |
opts,
|
|
|
3e09d8 |
1,
|
|
|
3e09d8 |
@@ -608,7 +583,6 @@ static int add_sysroot_usr_mount(void) {
|
|
|
3e09d8 |
log_debug("Found entry what=%s where=/sysroot/usr type=%s", what, strna(arg_usr_fstype));
|
|
|
3e09d8 |
return add_mount(what,
|
|
|
3e09d8 |
"/sysroot/usr",
|
|
|
3e09d8 |
- NULL,
|
|
|
3e09d8 |
arg_usr_fstype,
|
|
|
3e09d8 |
opts,
|
|
|
3e09d8 |
1,
|