-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Daniel Ruthardt <[email protected]>
- Loading branch information
1 parent
26edd8a
commit af0ecbb
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# shellcheck shell=bash | ||
|
||
#include user/get_gid | ||
#include user/get_groups | ||
#include user/get_home | ||
#include user/get_shell | ||
#include user/get_uid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# shellcheck shell=bash | ||
|
||
# user::get_groups | ||
# Retrieves the group memberships of a specified user. | ||
# | ||
# Description: | ||
# This function fetches the group memberships of the user specified by the username argument. | ||
# If no username is provided, it defaults to the current user. This is useful for scripts | ||
# that need to manage permissions or access control based on user groups. | ||
# | ||
# Usage: | ||
# user::get_groups <username> | ||
# | ||
# Parameters: | ||
# username - The username whose group memberships are to be retrieved. Optional, defaults to the | ||
# current user. | ||
# | ||
# Outputs: | ||
# The group memberships of the specified or default user. | ||
# | ||
# Example: | ||
# user::get_groups "exampleUser" # Outputs the groups of 'exampleUser' | ||
# user::get_groups # Outputs the groups of the current user | ||
function user::get_groups() { | ||
local username=${1:-${user:-$(whoami)}} | ||
id --groups --name "$username" | ||
} |