---
name: "auth_mkhomedir"
section: "3"
platform: "linux"
package: "courier-authlib-dev"
version: "0.72.4-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/auth_mkhomedir"
---

# auth\_mkhomedir(3)

Autocreate a new account's home directory

## NAME

auth\_mkhomedir - Autocreate a new account's home directory

## SYNOPSIS

```
#include <courierauth.h>
```

**int rc=auth\_mkhomedir(struct authinfo \****auth***);**

## DESCRIPTION

A *callback\_func* that's passed as a parameter to [**auth\_getuserinfo\_meta**(3)](/auth_getuserinfo_meta/3.md)\[1\] can invoke this function to automatically create a new account's home directory, if the authlib client is running as root, forwarding the authinfo pointer from the callback.

**auth\_mkhomedir**() checks if the **AUTH\_MKHOMEDIR\_SKEL** environment variable is set, and if the authenticated account's home directory does not exist. If the environment variable is set it must point to a directory like /etc/skel that contains a template for the contents of a new account's home directory.

If **AUTH\_MKHOMEDIR\_SKEL** is not set, or if the home directory exists, **auth\_mkhomedir**() does nothing and returns 0. Otherwise the account's home directory gets created, and the contents of the **AUTH\_MKHOMEDIR\_SKEL** directory get recursively copied into the new home directory. The permissions of **AUTH\_MKHOMEDIR\_SKEL** and its contents are preserved, and the owner userid and groupid is set to the authenticated account's userid and groupid.

## RETURNS

**auth\_mkhomedir**() returns a non-zero value if an error occured while creating the new account's home directory. **auth\_mkhomedir**() returns zero if the new account's home directory was created successfully, or if the account's home directory already exists.

## SEE ALSO

[**authlib**(3)](/authlib/3.md)\[2\], [**auth\_getuserinfo\_meta**(3)](/auth_getuserinfo_meta/3.md)\[1\].

## NOTES

- 1\.

  [**auth\_getuserinfo\_meta**(3)](/auth_getuserinfo_meta/3.md)

  http://www.courier-mta.org/authlib/auth\_getuserinfo.html

- 2\.

  [**authlib**(3)](/authlib/3.md)

  http://www.courier-mta.org/authlib/authlib.html
