exec-invoke: don't double-close FDs on error
When a late error occurs in sd-executor, the cleanup-on-close of the context structs happen, but at that time all FDs might have already been closed via close_all_fds(), so a double-close happens. This can be seen when DynamicUser is enabled, with a non-existing WorkingDirectory. Invalidate the FDs in the context structs if close_all_fds succeeds.
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
f756bcdf17
commit
7b6d3dcdd2
@@ -858,3 +858,14 @@ void dynamic_creds_done(DynamicCreds *creds) {
|
||||
dynamic_user_free(creds->group);
|
||||
creds->group = creds->user = dynamic_user_free(creds->user);
|
||||
}
|
||||
|
||||
void dynamic_creds_close(DynamicCreds *creds) {
|
||||
if (!creds)
|
||||
return;
|
||||
|
||||
if (creds->user)
|
||||
safe_close_pair(creds->user->storage_socket);
|
||||
|
||||
if (creds->group && creds->group != creds->user)
|
||||
safe_close_pair(creds->group->storage_socket);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user