umask
valid-umask?
umask
with-umask
1 Examples
2 Project Information
8.3

umask

Winston Weinert

 (require umask) package: umask-lib

Set the default permissions on a Unix-like operating system. This allows one to control who may read from/write to/execute a file upon creation.

procedure

(valid-umask? mask)  boolean?

  mask : any
Predicate to determine if a value can be used passed into the umask procedure.

procedure

(umask mask)  (or void valid-umask?)

  mask : valid-umask?
Behaves like the unix umask(2) system call. If invoked with no arguments, this procedure returns the current umask (file mode creation mask). If invoked with argument mask, set the current umask to the value of mask and returns (void).

syntax

(with-umask umask-expr body ...)

 
  umask-expr : valid-umask?
Temporarily set the umask to umask-expr when evaluating body ....

1 Examples

Get input from the user then save it to a temporary file that will be only readable by the current user.

(with-umask #o077
  (define temporary-file (make-temporary-file))
  (define secret (read-line))
  (printf "Secret saved to ~a.\n" temporary-file)
  (with-output-to-file temporary-file (thunk (displayln secret))))

Get the umask

(umask)

Set the umask so subsequently files are only readable as the current user (and root).

(umask #o077)

2 Project Information