24 Security Guards (BC)

► |  | Inside: Racket C API

I | Inside Racket CS
II | Inside Racket BC (3m and CGC)
III | Appendices
| Index

▼ | II | Inside Racket BC (3m and CGC)

8 | Overview (BC)
9 | Embedding into a Program (BC)
10 | Writing Racket Extensions (BC)
11 | Values and Types (BC)
12 | Memory Allocation (BC)
13 | Namespaces and Modules (BC)
14 | Procedures (BC)
15 | Evaluation (BC)
16 | Exceptions and Escape Continuations (BC)
17 | Threads (BC)
18 | Parameterizations (BC)
19 | Continuation Marks (BC)
20 | String Encodings (BC)
21 | Bignums, Rationals, and Complex Numbers (BC)
22 | Ports and the Filesystem (BC)
23 | Structures (BC)
24 | Security Guards (BC)
25 | Custodians (BC)
26 | Subprocesses (BC)
27 | Miscellaneous Utilities (BC)

top contents ← prev up next →

## 24 Security Guards (BC)🔗ℹ

Before a primitive procedure accesses the filesystem or creates a network connection, it should first consult the current security guard to determine whether such access is allowed for the current thread.

File access is normally preceded by a call to scheme_expand_filename, which accepts flags to indicate the kind of filesystem access needed, so that the security guard is consulted automatically.

An explicit filesystem-access check can be made by calling scheme_security_check_file. Similarly, an explicit network-access check is performed by calling scheme_security_check_network.

void |  | scheme_security_check_file | ( | const char* who,
|  |  |  | char* filename,
|  |  |  | int guards)

Consults the current security manager to determine whether access is allowed to filename. The guards argument should be a bitwise combination of the following:

- SCHEME_GUARD_FILE_READ

- SCHEME_GUARD_FILE_WRITE

- SCHEME_GUARD_FILE_EXECUTE

- SCHEME_GUARD_FILE_DELETE

- SCHEME_GUARD_FILE_EXISTS (do not combine with other values)

The filename argument can be NULL (in which case #f is sent to the security manager’s procedure), and guards should be SCHEME_GUARD_FILE_EXISTS in that case.

If access is denied, an exception is raised.

void |  | scheme_security_check_network | ( | const char* who,
|  |  |  | char* host,
|  |  |  | int portno)

Consults the current security manager to determine whether access is allowed for creating a client connection to host on port number portno. If host is NULL, the security manager is consulted for creating a server at port number portno.

If access is denied, an exception is raised.

top contents ← prev up next →