AUTH_MKHOMEDIR(3)

✨ AUTH_MKHOMEDIR ✨

okay bestie, so this is auth_mkhomedir, a page from the authlib corner of the Courier universe, and it's genuinely one of the cutest little functions ever. she does exactly one thing and she does it well: she makes a brand new account's home directory for them πŸ’–


πŸ¦‹ NAME πŸ¦‹

auth_mkhomedir β€” autocreate a new account's home directory. yes, that's literally it. no cap.


🌸 SYNOPSIS 🌸

#include <courierauth.h>

int rc=auth_mkhomedir(struct authinfo *auth);

πŸ’… DESCRIPTION πŸ’…

so here's the vibe. auth_mkhomedir is a callback_func β€” meaning you pass it as a parameter to auth_getuserinfo_meta(3)[1] β€” and that callback can call this function to automatically create a new account's home directory. the catch? the authlib client has to be running as root, and you forward the authinfo pointer straight from the callback. slay.

here's what she actually checks, step by step, no skips:

  • she checks if the AUTH_MKHOMEDIR_SKEL environment variable is set
  • she checks if the authenticated account's home directory does not exist

if that env var is set, it has to point to a directory β€” think /etc/skel β€” that holds a template for what a new account's home directory should contain. it's giving blueprint energy πŸŽ€

now, the important part:

if AUTH_MKHOMEDIR_SKEL is not set, or if the home directory already exists, auth_mkhomedir() does nothing and returns 0. she's not doing extra work for nobody. πŸ’€

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. and the details matter here, bestie:

  • the permissions of AUTH_MKHOMEDIR_SKEL and everything inside it are preserved
  • the owner userid and groupid get set to the authenticated account's userid and groupid

so the template copies over with its vibe intact, but the ownership lands on the right person. iconic. πŸ‘‘


🫢 RETURNS 🫢

  • auth_mkhomedir() returns a non-zero value if an error occurred while creating the new account's home directory. 😭 (something went wrong, bestie)
  • auth_mkhomedir() returns zero if the new account's home directory was created successfully β€” or if the account's home directory already existed. either way, we're good. ✨

πŸ”₯ SEE ALSO πŸ”₯


πŸ“ NOTES πŸ“

  1. auth_getuserinfo_meta(3) https://www.courier-mta.org/authlib/auth_getuserinfo.html
  2. authlib(3) https://www.courier-mta.org/authlib/authlib.html

and that's the whole page, bestie πŸ’œ written by S. Varshavchik, dated 06/18/2026, from the AUTH_MKHOMEDIR(3) manual. go forth and make them home directories. periodt. πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from