1

I have a number of existing users in Active Directory that need a home directory created. They don't log directly in to Solaris but into a service running on that box.

If I login as them their home directory gets created and then they can login.

This is the same for new users too!

As there are a lot of users, I need a way to automate this so new users and existing users have it created automatically.

Is this possible??

neildeadman
  • 664
  • 2
  • 20
  • 33

4 Answers4

4

Unlike Linux, there is no standard pam module like pam_mkhomedir to achieve this task on Solaris. While compiling this pam module would likely just work, there are alternatives like creating the home directory if missing in /etc/profile or setting up an executable auto_home map.

Using /etc/profile to create the user's home directory would require using rbac or sudo so an automounter based solution is simpler to implement, eg:

In the /etc/auto_master file, comment out the line:

# /home         auto_home       -nobrowse

and add this line:

/home           /opt/local/mkhomedir

Note: I'm assuming here the previous auto_home map wasn't already used by actual users.

Create the /opt/local/mkhomedir script with this content:

#!/bin/ksh -p
actual=/tmp/home # top directory to store user's home directories
homedir=$(echo ~$1)
hd=$actual/$1
if [ $(dirname $homedir) = /home -a ! -d $hd ]; then
  mkdir -p $hd
  chmod 0700 $hd
  chown $1 $hd
fi
echo localhost:$hd

and that's it. Every user configured to have his home in /home/username will have this directory automatically created at first access if necessary. Of course, you should replace /tmp/home by something more persistent in the mkhomedir script, eg /export/home which is the usual location for home directory back-end storage on Solaris.

jlliagre
  • 8,691
  • 16
  • 36
  • Could you expand on these workarounds at all? Or point me in the direction of a website? Tried Googling the terms you used, but it didn't show anything that looked helpful. – neildeadman Jul 05 '12 at 09:32
  • Creating the home directory from within /etc/profile seems to be a neat idea but I don't think it's practical. The profile script is executed under the user's id, i.e. the place where the home directories are located must be writable by everybody. Then there are other caveats, like the shell would not make the newly created directory its cwd, etc. etc. For using auto_home as a place to kick of a script check the man page for automount(1M) under the heading "Executable Maps". – mghocke Jul 05 '12 at 14:11
  • @neildeadman: Just updated my answer with a working example. – jlliagre Jul 05 '12 at 23:37
0

You have two options:

  • if you can have your service use PAM, then you can have pam_mkhomedir create it for you.
  • you can do a batch overnight job and create homedirs based on the user list.
Konrads
  • 860
  • 2
  • 20
  • 38
  • pam_mkhomedir does not come with Solaris. You have to scout the web for a download location and try to build it on your own. A quick Google showed that it is indeed possible and folks have done this in the past. I personally think that this is a better way to solve this problem. – mghocke Jul 05 '12 at 14:15
-1

Use this project

https://github.com/benr/solaris_pam_mkhomedir

You can use the existing SUNWgcc package if you want.

  • Hello and welcome on serverfault. Can you please provide more detailed answer? –  Mar 25 '14 at 21:24
-3

It IS Happening automatically - when a user logs into a computer. Sorry, that is the way MS has designed it.

Best chance you have is logging in via remote desktop on a windows machine (should be scriptable) with a logoff automatic script ;)

TomTom
  • 50,857
  • 7
  • 52
  • 134
  • The home directory does get created automatically at logon, but I want to automate this so when a new user is created this happens without needing to login. The reason is that users might be created by someone who is not knowledgeable and thus won't know how to login to Solaris via SSH and it probably isn't wise to show them. Will logging into Windows really help here?? – neildeadman Jul 05 '12 at 08:43
  • No, but automatiing user creation will. That simple. Setting them up manually is a recipe for desaster anyway. – TomTom Jul 05 '12 at 09:29