c27b31 core: introduce new Type=exec service type

7 files Authored by Lennart Poettering 4 years ago, Committed by Packit Service 4 years ago,
    core: introduce new Type=exec service type
    
    Users are often surprised that "systemd-run" command lines like
    "systemd-run -p User=idontexist /bin/true" will return successfully,
    even though the logs show that the process couldn't be invoked, as the
    user "idontexist" doesn't exist. This is because Type=simple will only
    wait until fork() succeeded before returning start-up success.
    
    This patch adds a new service type Type=exec, which is very similar to
    Type=simple, but waits until the child process completed the execve()
    before returning success. It uses a pipe that has O_CLOEXEC set for this
    logic, so that the kernel automatically sends POLLHUP on it when the
    execve() succeeded but leaves the pipe open if not. This means PID 1
    waits exactly until the execve() succeeded in the child, and not longer
    and not shorter, which is the desired functionality.
    
    Making use of this new functionality, the command line
    "systemd-run -p User=idontexist -p Type=exec /bin/true" will now fail,
    as expected.
    
    (cherry picked from commit 5686391b006ee82d8a4559067ad9818e3e631247)
    
    Resolves: #1683334
    
    patch_name: 0193-core-introduce-new-Type-exec-service-type.patch
    present_in_specfile: true
    location_in_specfile: 193
    squash_commits: true
    
        
file modified
+79 -10
file modified
+3 -0
file modified
+5 -4
file modified
+157 -10
file modified
+4 -0
file modified
+5 -4
file modified
+1 -0