summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2012-02-07 07:13:52 -0500
committerMartin Kosek <mkosek@redhat.com>2012-02-09 18:11:57 +0100
commitd706c411ef0c24a96451c15ef16c4fbfbfe177e0 (patch)
treefd9bf3d3403c3f3a66a2720ec87f569845e3b175 /ipalib
parent44c69ef33ef63030007e55b0f0dddcac12372543 (diff)
downloadfreeipa-d706c411ef0c24a96451c15ef16c4fbfbfe177e0.tar.gz
freeipa-d706c411ef0c24a96451c15ef16c4fbfbfe177e0.tar.xz
freeipa-d706c411ef0c24a96451c15ef16c4fbfbfe177e0.zip
Honor default home directory and login shell in user_add
The homedirectory argument had a default_from '/home/<name>', ignoring the ipahomesrootdir config setting. This patch removes that default, and adds a test case for ipahomesrootdir. https://fedorahosted.org/freeipa/ticket/2332 The login shell had the same problem. Again this patch removes the client-side default and adds a test. Building the home directory from the default is changed to use posixpath.join instead of string formatting and ad-hoc cleanup, and to use '/home' instead of failing when the ipahomesrootdir setting is not present for some reason.
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/plugins/user.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/ipalib/plugins/user.py b/ipalib/plugins/user.py
index 70a111dd3..8c4cc49a0 100644
--- a/ipalib/plugins/user.py
+++ b/ipalib/plugins/user.py
@@ -27,6 +27,7 @@ import copy
from ipalib import _, ngettext
from ipapython.ipautil import ipa_generate_password
import string
+import posixpath
__doc__ = _("""
Users
@@ -207,11 +208,9 @@ class user(LDAPObject):
default_from=lambda givenname, sn: '%c%c' % (givenname[0], sn[0]),
autofill=True,
),
- Str('homedirectory',
+ Str('homedirectory?',
cli_name='homedir',
label=_('Home directory'),
- default_from=lambda uid: '/home/%s' % uid,
- autofill=True,
),
Str('gecos?',
label=_('GECOS field'),
@@ -221,7 +220,6 @@ class user(LDAPObject):
Str('loginshell?',
cli_name='shell',
label=_('Login shell'),
- default=u'/bin/sh',
),
Str('krbprincipalname?', validate_principal,
cli_name='principal',
@@ -413,17 +411,16 @@ class user_add(LDAPCreate):
len = int(config.get('ipamaxusernamelength')[0])
)
)
- entry_attrs.setdefault('loginshell', config.get('ipadefaultloginshell'))
+ default_shell = config.get('ipadefaultloginshell', ['/bin/sh'])[0]
+ entry_attrs.setdefault('loginshell', default_shell)
# hack so we can request separate first and last name in CLI
full_name = '%s %s' % (entry_attrs['givenname'], entry_attrs['sn'])
entry_attrs.setdefault('cn', full_name)
if 'homedirectory' not in entry_attrs:
# get home's root directory from config
- homes_root = config.get('ipahomesrootdir', '/home')[0]
+ homes_root = config.get('ipahomesrootdir', ['/home'])[0]
# build user's home directory based on his uid
- home_dir = '%s/%s' % (homes_root, keys[-1])
- home_dir = home_dir.replace('//', '/').rstrip('/')
- entry_attrs['homedirectory'] = home_dir
+ entry_attrs['homedirectory'] = posixpath.join(homes_root, keys[-1])
entry_attrs.setdefault('krbpwdpolicyreference', 'cn=global_policy,cn=%s,cn=kerberos,%s' % (api.env.realm, api.env.basedn))
entry_attrs.setdefault('krbprincipalname', '%s@%s' % (entry_attrs['uid'], api.env.realm))