]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
sed -i destroys symlinks
authorJoakim Tjernlund <joakim.tjernlund@infinera.com>
Tue, 14 Nov 2023 13:28:42 +0000 (14:28 +0100)
committerSteve Sakoman <steve@sakoman.com>
Thu, 28 Dec 2023 14:43:58 +0000 (04:43 -1000)
If /etc/passwd is a symlink, sed -i on same file will replace the
symlink with a new file. Prevent that by adding --follow-symlinks
option to sed

Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
(cherry picked from commit 6ec004b2e7b4342465af8e5e6cc66041834821a0)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
meta/classes-recipe/rootfs-postcommands.bbclass
meta/classes/useradd_base.bbclass

index 06388b72fb4e1fab8a4b6db1e46ec8abddb7891d..29ee74932a326d6becdbf65b6f932ecd4837b0a4 100644 (file)
@@ -241,10 +241,10 @@ read_only_rootfs_hook () {
 #
 zap_empty_root_password () {
        if [ -e ${IMAGE_ROOTFS}/etc/shadow ]; then
-               sed -i 's%^root::%root:*:%' ${IMAGE_ROOTFS}/etc/shadow
+               sed --follow-symlinks -i 's%^root::%root:*:%' ${IMAGE_ROOTFS}/etc/shadow
         fi
        if [ -e ${IMAGE_ROOTFS}/etc/passwd ]; then
-               sed -i 's%^root::%root:*:%' ${IMAGE_ROOTFS}/etc/passwd
+               sed --follow-symlinks -i 's%^root::%root:*:%' ${IMAGE_ROOTFS}/etc/passwd
        fi
 }
 
index 863cb7b76c529610546cbf95de69f2d929a1c16c..f1a7a9695dd13a4ee9fcc12fcc33a40fbabb8516 100644 (file)
@@ -160,7 +160,7 @@ perform_passwd_expire () {
        local username=`echo "$opts" | awk '{ print $NF }'`
        local user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
        if test "x$user_exists" != "x"; then
-               eval flock -x $rootdir${sysconfdir} -c \"$PSEUDO sed -i \''s/^\('$username':[^:]*\):[^:]*:/\1:0:/'\' $rootdir/etc/shadow \" || true
+               eval flock -x $rootdir${sysconfdir} -c \"$PSEUDO sed -follow-symlinks -i \''s/^\('$username':[^:]*\):[^:]*:/\1:0:/'\' $rootdir/etc/shadow \" || true
                local passwd_lastchanged="`grep "^$username:" $rootdir/etc/shadow | cut -d: -f3`"
                if test "x$passwd_lastchanged" != "x0"; then
                        bbfatal "${PN}: passwd --expire operation did not succeed."