---
name: "peks-misc"
section: "3"
platform: "linux"
package: "libnessus-dev"
version: "1.0.10-2"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/peks-misc"
---

# peks-misc(3)

query user characteristics

## 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)](/gethostbyname/3.md) to resolve all host and network names that occur in a complex key tag as defined in [**peks-keyfile**(5)](/peks-keyfile/5.md). 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)](/peks-passwd/3.md) 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)](/peks-errnum/3.md).)

## 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)](/xfree/3.md), [**errno**(3)](/errno/3.md), [**peks-errnum**(3)](/peks-errnum/3.md),  [**peks-keyfile**(5)](/peks-keyfile/5.md), [**peks-passwd**(3)](/peks-passwd/3.md), **peks-key**(3),  **gethostbyname** (3)."

## AUTHOR

The **peks** package where these functions belong to was written by Jordan Hrycaj \<jordan@teddy-net.com\>, originally to support the **nessus** security scanner.
