NAME
peks_get_homedir peks_get_username - query user characteristics
SYNOPSIS
#include <peks.h> char *peks_get_homedir (const char *file); char *peks_get_dirfile (const char *file); void peks_set_homevar (const char *home); void peks_set_uservar (const char *user); char *peks_get_username (void); char *tagresolve (const char *pattern, size_t len);
DESCRIPTION
Peks_get_homedir() appends the string file given as argument to the vakue of the HOME environment variable. If there is no HOME variable, the passwd table is looked up for an appropriate value of a home directory.
Passing a NULL argument to peks_get_homedir() is allowed. In that case only the home directory (without a trailing slash) is returned.
Peks_get_dirfile() returns a string with an absolute path according to the argument file. If this argument starts with a tilde-slash looking like ~/filename, the tilde wil be substituted by the home directory using peks_get_homedir(). If file does not start with a slash it will be prepended by the current working directory.
Peks_set_homevar() stores the name of a custom environment variable to be checked before the HOME variable. Passing a NULL argument disables this feature.
Peks_set_uservar() stores the name of a custom environment variable to be checked as the user's login name. Passing a NULL argument disables this feature.
Passing a NULL argument peks_get_dirfile() is allowed. In that case only the current directory (without a trailing slash) is returned.
Peks_get_username() returns the user's current name. If present, this is the contents of the environment variable passed to the fuction peks_set_uservar().
Tagsresolve() uses gethostbyname(3) to resolve all host and network names that occur in a complex key tag as defined in peks-keyfile(5). Formally, the input syntax can be a <netspecs> or a <usrspecs>. But most commonly, it is a simple <usrspecs>, a user name with an ip-address or a network appended like <user>@<network>/<mask>.
In order to pre-evaluate such an expression before passed to a function like peks_edit_passwd_file() (see peks-passwd(3) for details,) this function is used.
It evaluates the input argument pattern and returnes a string with all host and network names resolved.
RETURN VALUE
All functions return dynamically allocated space that must be returned using xfree(), when done. In case of an error, NULL is returned while the global variable errno is set to some error code (see peks-errnum(3).)
ENVIRONMENT VARIABLES
- home
-
The argument given to the peks_set_homevar() function to checked before the HOME variable. If present on Windows machines, this variable takes precedence over userprofile.
- userprofile
-
Ignored on non-Windows machines, this variable takes precedence over HOME, which has the same meaning in the given context.
- HOME
-
The path to the user's home directory.
- user
-
The argument given to the peks_set_uservar() function to set a user login name variable.
SEE ALSO
xfree(3), errno(3), peks-errnum(3), peks-keyfile(5), peks-passwd(3), peks-key(3), gethostbyname (3)."
AUTHOR
The peks package where these functions belong to was written by Jordan Hrycaj <[email protected]>, originally to support the nessus security scanner.