Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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??

share|improve this question
add comment

4 Answers

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 ;)

share|improve this answer
    
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 5 '12 at 8:43
    
No, but automatiing user creation will. That simple. Setting them up manually is a recipe for desaster anyway. –  TomTom Jul 5 '12 at 9:29
add comment

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.

share|improve this answer
    
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 5 '12 at 9: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 5 '12 at 14:11
    
@neildeadman: Just updated my answer with a working example. –  jlliagre Jul 5 '12 at 23:37
add comment

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.
share|improve this answer
    
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 5 '12 at 14:15
add comment

Use this project

https://github.com/benr/solaris_pam_mkhomedir

You can use the existing SUNWgcc package if you want.

share|improve this answer
    
Hello and welcome on serverfault. Can you please provide more detailed answer? –  Eric DANNIELOU Mar 25 at 21:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.