| Extracted from Pike v7.8 release 866 at 2018-07-18.

[Top]
Pike
Pike.Security
Pike.Security.User

# Method Pike.Security.User()->valid_open()

Method valid_open

  `int(0..3)|string valid_open(string type, object current, string filename, string flags, int access)`

Description

  This callback gets called when a new file is to be opened (and the Creds object has BIT_CONDITIONAL_IO set).

Parameter `type`

  The type of file operation requested. Can either be `"read"` or `"write"`.

Parameter `current`

  The current object, i.e. the Fd object the user is trying to open.

Parameter `filename`

  The file name requested.

Parameter `flags`

  The flag string passed to open, e.g. `"cwt"`.

Parameter `access`

  The access flags requested for the file, e.g. `0666`.

Returns

  The function can either return a string, which means that the user is allowed to open a file, but the returned file should be opened instead, or it can return an integer. The integers are intepreted as follows.

  `0` | The user was not allowed to open the file. ERRNO will be set to EPERM and an exception is thrown.
  `1` | Do nothing, i.e. valid_open has initilized the current object with an open file. This can (natuarally) only be returned if a current object was given, which is not always the case.
  `2` | The user was allowed to open the file and the open code proceeds.
  `3` | The user was not allowed to open the file and an exception is thrown.