mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 21:59:17 +02:00
They can be close()d explicitly with close-file-descriptor, and will close() on gc, but only explicitly closing the last port on them will close the fileno. Notably needed for network sockets where we open separate input and output ports on the same socket.
64 lines
1.9 KiB
Text
64 lines
1.9 KiB
Text
|
|
(c-system-include "unistd.h")
|
|
(c-system-include "pwd.h")
|
|
(c-system-include "sys/types.h")
|
|
|
|
;;> \subsubsubsection{\scheme{(user-information name-or-id)}}
|
|
|
|
;;> Returns the password entry for the given user. \var{name-or-id}
|
|
;;> should be a string indicating the user name, or an integer
|
|
;;> for the user id.
|
|
|
|
(define-c-struct passwd
|
|
predicate: user?
|
|
(string pw_name user-name)
|
|
(string pw_passwd user-password)
|
|
(uid_t pw_uid user-id)
|
|
(gid_t pw_gid user-group-id)
|
|
(string pw_gecos user-gecos)
|
|
(string pw_dir user-home)
|
|
(string pw_shell user-shell))
|
|
|
|
;;> Accessors for the password entry structure returned by
|
|
;;> \scheme{user-information}.
|
|
;;/
|
|
|
|
(define-c uid_t (current-user-id "getuid") ())
|
|
(define-c gid_t (current-group-id "getgid") ())
|
|
(define-c uid_t (current-effective-user-id "geteuid") ())
|
|
(define-c gid_t (current-effective-group-id "getegid") ())
|
|
|
|
(define-c errno (set-current-user-id! "setuid") (uid_t))
|
|
(define-c errno (set-current-effective-user-id! "seteuid") (uid_t))
|
|
(define-c errno (set-current-group-id! "setgid") (gid_t))
|
|
(define-c errno (set-current-effective-group-id! "setegid") (gid_t))
|
|
|
|
;;> Accessors for the current user credentials.
|
|
;;/
|
|
|
|
;;> Returns the session id of the specified process,
|
|
;;> defaulting to the current process.
|
|
|
|
(define-c pid_t (current-session-id "getsid") ((default 0 pid_t)))
|
|
|
|
;;> Creates a new session.
|
|
|
|
(define-c pid_t (create-session "setsid") ())
|
|
|
|
;;> Set \var{string} to be the new root directory, so that
|
|
;;> paths beginning with "/" are resolved relative to the
|
|
;;> new root.
|
|
|
|
(define-c errno (set-root-directory! "chroot") (string))
|
|
|
|
(define-c errno getpwuid_r
|
|
(uid_t (result passwd)
|
|
(link string)
|
|
(value (string-size arg2) int)
|
|
(result pointer passwd)))
|
|
|
|
(define-c errno getpwnam_r
|
|
(string (result passwd)
|
|
(link string)
|
|
(value (string-size arg2) int)
|
|
(result pointer passwd)))
|