umask
valid-umask?
umask
with-umask
1 Examples
2 Project Information
3 Tested Platforms
8.6

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)  valid-umask?

(umask mask)  void?
  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

3 Tested Platforms

Windows is not supported because umask semantics are not available on Windows.