mount: restorecon: guard against execl() errors
authorDaniel Golle <daniel@makrotopia.org>
Fri, 16 Oct 2020 02:24:17 +0000 (03:24 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Sat, 12 Dec 2020 23:02:56 +0000 (23:02 +0000)
In the current implementation, in case of execl("/sbin/restorecon")
failing, the child process will also return and that will lead to
even more disasterous effects.
Though it seems unlikely that execl() would fail given that the file
exists, simply catch that case by exiting in case execl() returns.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
libfstools/mount.c

index b30e5a6d3846639a0522867b5285478a48e2a916..1691ce747f50921423e1ca43709549c612b6d1be 100644 (file)
@@ -99,7 +99,7 @@ selinux_restorecon(char *overlaydir)
 
        restorecon_pid = fork();
        if (!restorecon_pid)
-               execl("/sbin/restorecon", "restorecon", overlaydir, (char *) NULL);
+               exit(execl("/sbin/restorecon", "restorecon", overlaydir, (char *) NULL));
        else if (restorecon_pid > 0)
                waitpid(restorecon_pid, &status, 0);
 }