0

I'm trying to get the value of a user's home from a puppet script. This particular user is a Samba user, not a local one, with the username of the form DOMAIN\user.

I've tried the following, with no success:

  • echo "~DOMAIN\\user" ( outputs the exact input )
  • getent passwd DOMAIN\\user ( outputs nothing, the user is not even listed using getent passwd )

I'm surprised that getent did not work, since it is configured to do so:

$ cat /etc/nsswitch.conf | grep passwd
passwd: compat winbind

A simple C program using the getpwnam works, but that's going to be problematic to include and use from puppet.

How can I retrieve the user's home from puppet or a simple shell command?

Robert Munteanu
  • 1,644
  • 5
  • 23
  • 41

2 Answers2

4

I don't know how Samba figures in this, but otherwise...

finger -mlp $USER | grep Directory | cut -f2 -d ' '

(although this will ned some tweaks to handle spaces in the path)

symcbean
  • 21,009
  • 1
  • 31
  • 52
  • Aha, this does work! Does the `finger` command require extra privileges or setup to run locally? I recall that it does to run it remotely – Robert Munteanu Mar 31 '14 at 09:09
  • Not sure what you mean by "remotely" in this context. It only really makes sense running it on the machine where the user is expected to login - since the home dir is subject to the configuration of that machine as well as any centrally stored credentials. – symcbean Mar 31 '14 at 09:18
  • I was thinking on whether it requires fingerd or something similar. However, running it through strace shows that it does not need that. – Robert Munteanu Mar 31 '14 at 10:42
0

To make the getent call work, just enclose the argument in single quotes ':

getent passwd 'DOMAIN\user'
Robert Munteanu
  • 1,644
  • 5
  • 23
  • 41