git.iko.soy/typeable/nixpkgs
on master help sign in
libredirect: add posix_spawnp support

After bumping sublime3 in #61636 we realized that saving files as root doesn’t work anymore and somehow the paths weren’t patched by `libredirect`. After some debugging it came out that Sublime switched from `posix_spawn(3)` to `posix_spawnp(3)` to start new processes internally. Since `libredirect` only handled the former, `/usr/bin/pkexec` stopped being redirected. Wrapping `posix_spawnp` fixes the problem.

commita3667ee6be57c9dd51a692aba6be94eef4f2d6f5 authorMaximilian Bosch <maximilian@mbosch.me> dateSun 16 Jun 2019, 17:27 (7 years ago) parente8cdece
1 file changed+13
pkgs/build-support/libredirect/libredirect.c+13
pkgs/build-support/libredirect/libredirect.c+13
@@ -160,6 +160,19 @@ int posix_spawn(pid_t * pid, const char * path,
160160 return posix_spawn_real(pid, rewrite(path, buf), file_actions, attrp, argv, envp);
161161}
162162
163+int posix_spawnp(pid_t * pid, const char * file,
164+ const posix_spawn_file_actions_t * file_actions,
165+ const posix_spawnattr_t * attrp,
166+ char * const argv[], char * const envp[])
167+{
168+ int (*posix_spawnp_real) (pid_t *, const char *,
169+ const posix_spawn_file_actions_t *,
170+ const posix_spawnattr_t *,
171+ char * const argv[], char * const envp[]) = dlsym(RTLD_NEXT, "posix_spawnp");
172+ char buf[PATH_MAX];
173+ return posix_spawnp_real(pid, rewrite(file, buf), file_actions, attrp, argv, envp);
174+}
175+
163176int execv(const char *path, char *const argv[])
164177{
165178 int (*execv_real) (const char *path, char *const argv[]) = dlsym(RTLD_NEXT, "execv");