changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / lisp/std/os.lisp

changeset 589: 16a3cdc06cbc
parent: a0dfde3cb3c4
child: ebe3315b7add
author: Richard Westhaver <ellis@rwest.io>
date: Mon, 12 Aug 2024 21:16:14 -0400
permissions: -rw-r--r--
description: add cli/tools/wg
1 ;;; std/os.lisp --- OS interop definitions
2 
3 ;; UNIX only.
4 
5 ;;; Code:
6 (in-package :std/os)
7 (require 'sb-posix)
8 
9 (defun list-all-users ()
10  "List all users via passwd. (uid gid name home shell comment)"
11  (let ((r nil))
12  (sb-posix:do-passwds (u r)
13  (push (list (sb-posix:passwd-uid u)
14  (sb-posix:passwd-gid u)
15  (sb-posix:passwd-name u)
16  (sb-posix:passwd-dir u)
17  (sb-posix:passwd-shell u)
18  (sb-posix:passwd-gecos u))
19  r))
20  r))
21 
22 (defun list-all-groups ()
23  "List all groups. (gid name mem)"
24  (let ((r nil))
25  (sb-posix:do-groups (g r) (push (list (sb-posix:group-gid g)
26  (sb-posix:group-name g)
27  (sb-posix:group-mem g))
28  r))))
29 
30 (defmacro with-umask (mask &body body)
31  "Temporarily set the system-wide umask for the extent of BODY."
32  (with-gensyms (umask)
33  `(let ((,umask (sb-posix:umask ,mask)))
34  (unwind-protect (progn ,@body)
35  (sb-posix:umask ,umask)))))
36 
37 ;; (with-umask #o22 nil)