pam_mkpolohomedir

PAM Make Home Dir module

This module will create a users home directory if it does not exist
when the session begins. This allows users to be present in central
database (such as nis, kerb or ldap) without using a distributed
file system or pre-creating a large number of directories.

The module creates the home directory in all nodes of the system,
thus ensuring that the system will be fully functional for the user.

Here is a sample /etc/pam.d/login file for Debian GNU/Linux
2.1:

auth       requisite  pam_securetty.so
auth       sufficient pam_ldap.so
auth       required   pam_pwdb.so
auth       optional   pam_group.so
auth       optional   pam_mail.so
account    requisite  pam_time.so
account    sufficient pam_ldap.so
account    required   pam_pwdb.so
session    required   pam_mkhomedir.so skel=/etc/skel/ umask=0022
session    required   pam_pwdb.so
session    optional   pam_lastlog.so
password   required   pam_pwdb.so   

Released under the GNU LGPL version 2 or later
Based on the pam_mkhomedir module originally written by 
Jason Gunthorpe <jgg@debian.org> Feb 1999
Structure taken from pam_lastlogin by Andrew Morgan 
    <morgan@parc.power.net> 1996

Defines

_GNU_SOURCE
PAM_SM_SESSION
MKPOLOHOMEDIR_DEBUG
MKPOLOHOMEDIR_QUIET

Functions

static void _log_err(int err, const char *format, ...)

Sends a message to the syslog

Parameters
  • err -

    Message priority

  • format -

    The formatting string for the message

  • ... -

    values for the formatting string

static int _pam_parse(int flags, int argc, const char **argv)

Parses the arguments

Return
A bitwise-modified integer with all the flags
Parameters
  • flags -

    Behaviour modifiers

  • argc -

    The number of arguments

  • argv -

    The arguments

static int converse(pam_handle_t *pamh, int ctrl, int nargs, struct pam_message **message, struct pam_response **response)

This common function is used to send a message to the applications conversion function. Our only use is to ask the application to print an informative message that we are creating a home directory

Parameters
  • pamh -

    Information about the user

  • ctrl -

    Controlling flags

  • nargs -

    The number of arguments in message

  • message -

    An array of messages

  • response -

    The responses to those messages

static int make_remark(pam_handle_t *pamh, int ctrl, const char *remark)

Ask the application to display a short text string for us.

Return
An status of the operation.
Parameters
  • pamh -

    Information about the user

  • ctrl -

    Controlling flags

  • remark -

    The message

static int create_homedir(pam_handle_t *pamh, int ctrl, const struct passwd *pwd, const char *source, const char *dest)

Creates the home directory, using MarcoPolo in the rest of the nodes

Parameters
  • pamh -

    The information about the PAM session

  • ctrl -

    Controlling flags

  • pwd -

    The information about the user

  • dest -

    The home directory to create

PAM_EXTERN int pam_sm_open_session(pam_handle_t * pamh, int flags, int argc, const char ** argv)

Opens a PAM session. This is the entry point to the module

Return
A status code
Parameters
  • pamh -

    The PAM session information given by PAM

  • flags -

    Several control flags

  • argc -

    The number of arguments passed to the module in the configuration files

  • argv -

    The arguments passed to the module

PAM_EXTERN int pam_sm_close_session(pam_handle_t * pamh, int flags, int argc, const char ** argv)

Closes the session. This is the exit point

Parameters
  • pamh -

    The PAM session information

  • flags -

    Some control flags

  • argc -

    The number of arguments passed

  • argv -

    The arguments

Variables

unsigned int UMask
char SkelDir[BUFSIZ]