From bcd70d8f39312f3e696f46ffd8805d4464dafa63 Mon Sep 17 00:00:00 2001 From: Stelian Ionescu Date: Sun, 2 Jan 2011 00:40:31 +0100 Subject: [PATCH] Implement lfp_spawn() attributes setuid, setgid and resetids in create-process --- src/os/create-process-unix.lisp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/os/create-process-unix.lisp b/src/os/create-process-unix.lisp index c0f416b..34e7c8f 100644 --- a/src/os/create-process-unix.lisp +++ b/src/os/create-process-unix.lisp @@ -153,6 +153,14 @@ (:abort (close-fds ,infd ,outfd ,errfd)))))) +(defun process-other-spawn-args (attributes uid gid resetids) + (when uid + (lfp-spawnattr-setuid attributes uid)) + (when gid + (lfp-spawnattr-setgid attributes gid)) + (when resetids + (lfp-spawnattr-setflags attributes lfp-spawn-resetids))) + ;; program: :shell - the system shell ;; file-path designator - a path ;; arguments: list @@ -170,15 +178,18 @@ ;; t - inherit ;; nil - close ;; stderr: :stdout - the same as stdout +;; uid: user id - unsigned-byte or string +;; gid: group id - unsigned-byte or string +;; resetids: boolean - reset effective UID and GID to saved IDs (defun create-process (program arguments &key (search t) (environment t) (stdin t) (stdout t) (stderr t) - ;; path uid gid effective - ) + uid gid resetids) (with-lfp-spawn-arguments (attributes file-actions pid) (with-argv ((arg0 argv) program arguments) (with-c-environment (envp environment) (with-redirections ((infd outfd errfd) (file-actions stdin stdout stderr)) + (process-other-spawn-args attributes uid gid resetids) (if search (lfp-spawnp pid arg0 argv envp file-actions attributes) (lfp-spawn pid arg0 argv envp file-actions attributes)) -- 2.11.4.GIT