SHIFT-WIKI

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


aixautohomedir

AIX Home Directory

Under normal circumstances you would use the PAM module pam_mkhomedir.so to create a home directory when it not exists and a user logins. This does not work using SSH because this is considered a security breach. This article is about the autocreation of a home directory when users login using SSH. Because the pam module doesn't work anymore we use the “make_home_dir” program from TrustSec.

Note: The recommendations used here are mostly from the readme, this readme was however created for linux so a few commands didn't work. The commands used here are for AIX.

Installation make_home_dir

The installation of make_home_dir on AIX is not so straight forward as hoped for. I had to perform these steps to get it working:

  1. System setup
  2. Modification make file
  3. Compile source
  4. Configure /etc/profile

System setup

Before the program can be installed you need to setup your system: Do the following, to setup your system: Add a group named 'home':

$ mkgroup home

Now make the parent of the home-directories writeable to this group:

$ chgrp home /home
$ chmod g+w /home

AIX 6.1

Additionally, on AIX 6.1 you have to manually create the directory /usr/local/sbin:

mkdir /usr/local
mkdir /usr/local/sbin

Modification make file

The makefile is created for linux and doesn't work out of the box on AIX. This is the original makefile:

# (c) Copyright 2003 -- Frank Kirschner <kirschner@trustsec.de>
#
# The install-dir of the binary
BIN_DIR=/usr/local/sbin
# The group, that make_home_dir should be started with
GROUP=home
# The parent-directory of all home-directories
HOME_PARENT=/home




SRC=make_home_dir.c
FILE=make_home_dir
DEST=$(BIN_DIR)/$(FILE)

all:	$(FILE)

install: $(FILE)
	cp $(FILE) $(DEST)
	strip $(DEST)
	chgrp $(GROUP) $(DEST)
	chmod g+s $(DEST)

setup:
	groupadd $(GROUP)
	chgrp $(GROUP) $(HOME_PARENT)
	chmod g+w $(HOME_PARENT)

clean:
	rm -f $(FILE)


$(FILE):	$(SRC)
	gcc -Wall -o $@ $<

To make this file work on AIX you'll have to edit the last line:

gcc -Wall -o $@ $<

to:

gcc -Wall -o $@ $(SRC)

error

If you don't change the makefile you'll get this error:

root@ms-lpar04:/tmp/sft/make_home_dir-1.0>make
        gcc -Wall -o make_home_dir
gcc: no input files
make: The error code from the last command is 1.

Compile source

After this you can finally compile the source:

root@ms-lpar04:/tmp/sft/make_home_dir-1.0>make
Target "all" is up to date.
root@ms-lpar04:/tmp/sft/make_home_dir-1.0>make install
        cp make_home_dir /usr/local/sbin/make_home_dir
        strip /usr/local/sbin/make_home_dir
        chgrp home /usr/local/sbin/make_home_dir
        chmod g+s /usr/local/sbin/make_home_dir
root@ms-lpar04:/tmp/sft/make_home_dir-1.0>ls
COPYRIGHT        Makefile         README           make_home_dir    make_home_dir.c

Configure profile

Now you have to add some code to the /etc/profile script. The original code is again for linux and doesn't work completely on AIX. This is the original code:

if [ ! -d $HOME ]
then
   logger Creating new home-directory $HOME
   /usr/local/sbin/make_home_dir
   cd $HOME
   cp -a /etc/skel/. $HOME/.
   echo Home directory created
fi

To make it work on AIX change this line:

cp -a /etc/skel/. $HOME/.

to

cp /etc/skel/.[^\.]* $HOME/

NOTE: for this to work you'll have to change the default shell to /bin/bash. This is already been set for LUM enabled users in eDirectory.

aixautohomedir.txt · Last modified: 2021/09/24 00:24 by 127.0.0.1