aboutsummaryrefslogtreecommitdiff
path: root/src/image.lisp
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-07-26 14:06:58 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-09-09 11:19:40 -0700
commit3e4a8149efbf7d6515ec6ac542ee8882320763d0 (patch)
tree47ea0ced2be5ce4f2a5ab246d5e10a686a98694c /src/image.lisp
parent009634f28b0443cc6a5dc37f733e281819c9947b (diff)
downloadconsfigurator-3e4a8149efbf7d6515ec6ac542ee8882320763d0.tar.gz
use CFFI, mostly via Osicat, for all syscalls/libc except fork(2)
Also replace some calls to chmod(1) with calls to chmod(2). Using CFFI rather than implementation-specific wrappers should be better for portability. Also with this commit we stop hard coding types like uid_t as :UNSIGNED-INT, which was less portable. Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/image.lisp')
-rw-r--r--src/image.lisp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/image.lisp b/src/image.lisp
index fc29179..cbd63c5 100644
--- a/src/image.lisp
+++ b/src/image.lisp
@@ -99,7 +99,7 @@ Thus, PREREQUEST must not start up any threads."
,@forms)))
(defun dump-consfigurator (filename form)
- (umask #o077)
+ (nix:umask #o077)
(uiop:register-image-restore-hook (lambda () (eval form)) nil)
(uiop:dump-image filename :executable t))
@@ -150,7 +150,7 @@ already running from FILENAME."
(eql :linux (uiop:operating-system))
(pathname-equal file (resolve-symlinks "/proc/self/exe")))
(unless filename
- (mrun "chmod" "0700" (pathname-directory-pathname file)))
+ (nix:chmod #o700 (unix-namestring (pathname-directory-pathname file))))
(if form
(dump-consfigurator-in-grandchild file form)
(dump-consfigurator-in-grandchild file))))
@@ -183,7 +183,7 @@ already running from FILENAME."
#'force-output
*standard-output* *error-output* *debug-io* *terminal-io*)
when (zerop (fork))
- do (setsid)
+ do (nix:setsid)
(close ,fork-control)
(handle-fork-request input output)
(uiop:quit))
@@ -197,8 +197,9 @@ already running from FILENAME."
(delete-file ,fork-control)
(unwind-protect (progn ,@forms)
(close *fork-control*)
- (let ((status (nth-value 1 (waitpid child 0))))
- (unless (and (wifexited status) (zerop (wexitstatus status)))
+ (let ((status (nth-value 1 (nix:waitpid child))))
+ (unless
+ (and (nix:WIFEXITED status) (zerop (nix:WEXITSTATUS status)))
(error "Fork control child did not exit zero."))))))))
;; IPC security considerations
@@ -258,8 +259,8 @@ already running from FILENAME."
(unwind-protect
(with-open-file (out out :element-type 'character)
(with-open-file (err err :element-type 'character)
- (let ((status (nth-value 1 (waitpid child 0))))
- (unless (wifexited status)
+ (let ((status (nth-value 1 (nix:waitpid child))))
+ (unless (nix:WIFEXITED status)
(failed-change
"~&Grandchild process did not exit normally, status #x~(~4,'0X~)."
status))
@@ -268,7 +269,7 @@ already running from FILENAME."
:element-type 'character)
(write-to-mkfifo (list (slurp-stream-string out)
(slurp-stream-string err)
- (wexitstatus status))
+ (nix:WEXITSTATUS status))
output)))))
(delete-file out) (delete-file err))))