LogoPear Docs
ReferencesBareModules

bare-posix

POSIX-specific bindings for Bare

stable

bare-posix — POSIX-specific bindings for Bare. It is a native addon.

npm i bare-posix

API

Functions

getgid(): number

Source

Returns the real group ID of the calling process.

setgid(id: number | string): void

Source

Set the real group ID of the calling process. Accepts a numeric ID or a group name, resolved via getgrnam.

Parameters

ParameterTypeDefaultDescription
idnumber | stringThe group to switch to: a numeric group ID, or a group name resolved via getgrnam.

Throws

  • On platforms without POSIX support (android, win32), throws Error: Platform not supported.

getegid(): number

Source

Returns the effective group ID of the calling process.

setegid(id: number | string): void

Source

Set the effective group ID of the calling process. Accepts a numeric ID or a group name, resolved via getgrnam.

Parameters

ParameterTypeDefaultDescription
idnumber | stringThe group to switch to: a numeric group ID, or a group name resolved via getgrnam.

Throws

  • On platforms without POSIX support (android, win32), throws Error: Platform not supported.

getuid(): number

Source

Returns the real user ID of the calling process.

setuid(id: number | string): void

Source

Set the real user ID of the calling process. Accepts a numeric ID or a username, resolved via getpwnam.

Parameters

ParameterTypeDefaultDescription
idnumber | stringThe user to switch to: a numeric user ID, or a username resolved via getpwnam.

Throws

  • On platforms without POSIX support (android, win32), throws Error: Platform not supported.

geteuid(): number

Source

Returns the effective user ID of the calling process.

seteuid(id: number | string): void

Source

Set the effective user ID of the calling process. Accepts a numeric ID or a username, resolved via getpwnam.

Parameters

ParameterTypeDefaultDescription
idnumber | stringThe user to switch to: a numeric user ID, or a username resolved via getpwnam.

Throws

  • On platforms without POSIX support (android, win32), throws Error: Platform not supported.

getgroups(): number[]

Source

Returns the supplementary group IDs of the calling process.

getgrnam(name: string): Group | null

Source

Look up a group by name, returning its Group record or null if it doesn't exist.

Parameters

ParameterTypeDefaultDescription
namestringThe group name to look up.

Returns Group | null — The matching Group record, or null if no such group exists.

getpwnam(name: string): Passwd | null

Source

Look up a user by name, returning its Passwd record or null if it doesn't exist.

Parameters

ParameterTypeDefaultDescription
namestringThe user name to look up.

Returns Passwd | null — The matching Passwd record, or null if no such user exists.

Types

Group

interface Group {
  groupname: string
  passwd: string
  gid: number
  members: string[]
}
Source

A POSIX group record, as returned by getgrnam.

Passwd

interface Passwd {
  username: string
  passwd: string
  uid: number
  gid: number
  gecos: string
  homedir: string
  shell: string
}
Source

A POSIX user record, as returned by getpwnam.

See also

On this page