1 Language Model
2 Syntactic Forms
3 Datatypes
4 Structures
5 Classes and Objects
6 Units
7 Contracts
8 Pattern Matching
9 Control Flow
10 Concurrency
11 Macros
12 Input and Output
13 Reflection and Security
14 Operating System
15 Memory Management
16 Running PLT Scheme
Bibliography
Index
On this page:
security-guard?
make-security-guard
current-security-guard
Version: 4.0.2

 

13.5 Security Guards

(security-guard? v)  boolean?

  v : any/c

Returns #t if v is a security guard value as created by make-security-guard, #f otherwise.

A security guard provides a set of access-checking procedures to be called when a thread initiates access of a file, directory, or network connection through a primitive procedure. For example, when a thread calls open-input-file, the thread’s current security guard is consulted to check whether the thread is allowed read access to the file. If access is granted, the thread receives a port that it may use indefinitely, regardless of changes to the security guard (although the port’s custodian could shut down the port; see Custodians).

A thread’s current security guard is determined by the current-security-guard parameter. Every security guard has a parent, and a parent’s access procedures are called whenever a child’s access procedures are called. Thus, a thread cannot increase its own access arbitrarily by installing a new guard. The initial security guard enforces no access restrictions other than those enforced by the host platform.

(make-security-guard

 

parent

 

 

 

 

 

 

file-guard

 

 

 

 

 

 

network-guard

 

 

 

 

 

 [

link])

 

 

security-guard?

  parent : security-guard?

  

file-guard

 

:

 

(symbol?

 (or/c path? false/c)

 (listof symbol?)

 . -> . any)

  

network-guard

 

:

 

(symbol?

 (or/c (and/c string? immutable?) false/c)

 (or/c (integer-in 1 65535) false/c)

 (one-of/c 'server 'client)

 . -> . any)

  

link

 

:

 

(or/c (symbol? path? path? . -> . any)

      false/c)

 

=

 

#f

Creates a new security guard as child of parent.

The file-guard procedure must accept three arguments:

The network-guard procedure must accept four arguments:

The link-guard argument can be #f or a procedure of three arguments:

If link-guard is #f, then a default procedure is used that always raises exn:fail.

The return value of file-guard, network-guard, or link-guard is ignored. To deny access, the procedure must raise an exception or otherwise escape from the context of the primitive call. If the procedure returns, the parent’s corresponding procedure is called on the same inputs, and so on up the chain of security guards.

The file-guard, network-guard, and link-guard procedures are invoked in the thread that called the access-checked primitive. Breaks may or may not be enabled (see Breaks). Full continuation jumps are blocked going into or out of the file-guard or network-guard call (see Prompts, Delimited Continuations, and Barriers).

(current-security-guard)  security-guard?

(current-security-guard guard)  void?

  guard : security-guard?

A parameter that determines the current security guard that controls access to the filesystem and network.