Previous: , Up: system passwd   [Contents][Index]


19.1.5 Converting user identifiers

We are meant to call these function after a call to mbfl_system_passwd_read(); Reading the file passwd.

Function: mbfl_system_passwd_uid_to_name uid
Function: mbfl_system_passwd_uid_to_name_var _RV uid

Print to stdout the name of the user whose uid is uid. When successful return true; otherwise return false.

The function variant _var stores the result in the variable _RV, rather than print it; Result variables.

local USER_NAME

if mbfl_system_passwd_read
then mbfl_system_passwd_uid_to_name 0
fi

# Using the "_var" variants.
if mbfl_system_passwd_read
then
    mbfl_system_passwd_uid_to_name_var USER_NAME 0
    echo "$USER_NAME"
fi
Function: mbfl_system_passwd_name_to_uid name
Function: mbfl_system_passwd_name_to_uid_var _RV name

Print to stdout the id of the user whose uid is uid. When successful return true; otherwise return false.

The function variant _var stores the result in the variable _RV, rather than print it; Result variables.

local USER_ID

if mbfl_system_passwd_read
then mbfl_system_passwd_name_to_uid 'root'
fi

# Using the "_var" variants.
if mbfl_system_passwd_read
then
    if mbfl_system_passwd_name_to_uid_var USER_ID 'root'
    then echo "$USER_ID"
    fi
fi
Function: mbfl_system_numerical_user_id_to_name id

Convert the numerical user id to the user name found in the /etc/passwd file; print the result to stdout. When successful return true; otherwise return false.

Function: mbfl_system_numerical_user_id_to_name name

Convert the symbolic user name to the numerical identifier found in the /etc/passwd file; print the result to stdout. When successful return true; otherwise return false.


Previous: , Up: system passwd   [Contents][Index]

This document describes version 3.0.0-devel.0 of Marcos Bash Functions Library.