groups: Get a user's groups

Description Usage Arguments Value Possible Errors Possible Warnings Examples

Description

Get a user's groups

Usage

1
groups(user = NULL, unsafe = FALSE)

Arguments

user

The name of the user to check groups for. By default this is NULL and the groups will be provided for the user calling the function. Providing this parameter can be unsafe if you don't trust the source of the user name as much as you trust the source of your R code. It will be ignored (with a warning) unless unsafe= TRUE is set.

unsafe

Set TRUE to allow use of the user= parameter. Doing so without knowing that the user name is valid is unsafe.

Value

The vector of group names to which the user belongs.

Possible Errors

"System command failed with status <status> Command was: groups <user> The system-level error message (if any) was: ..."

Failure of the system command is caught and reported. E.g. if there is no system level groups command.

"groups() is only implemented for unix systems"

Will die with error if .Platform$OS.type != 'unix'.

Possible Warnings

"User '<user>' ignored; potentially unsafe."

As described above, you must explicitly allow use of the user parameter by agreeing to run this is an unsafe= TRUE way.

Examples

1
2
3
4
5
6
7
8
9
groups()
groups( user='root' )  # user ignored, caller's user name used.
groups( user='root', unsafe=TRUE )

# Example of unsafe use.
groups( user=';ls', unsafe=TRUE )
# Imagine if instead of ';ls' an evil user force-deleted, recursive on /
# and R itself ran as root (as it might be poorly configured to do to
# access some secure files...)

jefferys/DataRepo documentation built on May 19, 2019, 3:58 a.m.