summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--API.txt8
-rw-r--r--ipalib/plugins/user.py15
-rw-r--r--tests/test_xmlrpc/test_user_plugin.py130
3 files changed, 140 insertions, 13 deletions
diff --git a/API.txt b/API.txt
index 9605d1a0a..9c3ad9e99 100644
--- a/API.txt
+++ b/API.txt
@@ -3094,9 +3094,9 @@ option: Str('sn', attribute=True, cli_name='last', multivalue=False, required=Tr
option: Str('cn', attribute=True, autofill=True, cli_name='cn', multivalue=False, required=True)
option: Str('displayname', attribute=True, autofill=True, cli_name='displayname', multivalue=False, required=False)
option: Str('initials', attribute=True, autofill=True, cli_name='initials', multivalue=False, required=False)
-option: Str('homedirectory', attribute=True, autofill=True, cli_name='homedir', multivalue=False, required=True)
+option: Str('homedirectory', attribute=True, cli_name='homedir', multivalue=False, required=False)
option: Str('gecos', attribute=True, autofill=True, cli_name='gecos', multivalue=False, required=False)
-option: Str('loginshell', attribute=True, cli_name='shell', default=u'/bin/sh', multivalue=False, required=False)
+option: Str('loginshell', attribute=True, cli_name='shell', multivalue=False, required=False)
option: Str('krbprincipalname', attribute=True, autofill=True, cli_name='principal', multivalue=False, required=False)
option: Str('mail', attribute=True, cli_name='email', multivalue=True, required=False)
option: Password('userpassword', attribute=True, cli_name='password', exclude='webui', multivalue=False, required=False)
@@ -3154,7 +3154,7 @@ option: Str('displayname', attribute=True, autofill=False, cli_name='displayname
option: Str('initials', attribute=True, autofill=False, cli_name='initials', multivalue=False, query=True, required=False)
option: Str('homedirectory', attribute=True, autofill=False, cli_name='homedir', multivalue=False, query=True, required=False)
option: Str('gecos', attribute=True, autofill=False, cli_name='gecos', multivalue=False, query=True, required=False)
-option: Str('loginshell', attribute=True, autofill=False, cli_name='shell', default=u'/bin/sh', multivalue=False, query=True, required=False)
+option: Str('loginshell', attribute=True, autofill=False, cli_name='shell', multivalue=False, query=True, required=False)
option: Str('krbprincipalname', attribute=True, autofill=False, cli_name='principal', multivalue=False, query=True, required=False)
option: Str('mail', attribute=True, autofill=False, cli_name='email', multivalue=True, query=True, required=False)
option: Password('userpassword', attribute=True, autofill=False, cli_name='password', exclude='webui', multivalue=False, query=True, required=False)
@@ -3203,7 +3203,7 @@ option: Str('displayname', attribute=True, autofill=False, cli_name='displayname
option: Str('initials', attribute=True, autofill=False, cli_name='initials', multivalue=False, required=False)
option: Str('homedirectory', attribute=True, autofill=False, cli_name='homedir', multivalue=False, required=False)
option: Str('gecos', attribute=True, autofill=False, cli_name='gecos', multivalue=False, required=False)
-option: Str('loginshell', attribute=True, autofill=False, cli_name='shell', default=u'/bin/sh', multivalue=False, required=False)
+option: Str('loginshell', attribute=True, autofill=False, cli_name='shell', multivalue=False, required=False)
option: Str('mail', attribute=True, autofill=False, cli_name='email', multivalue=True, required=False)
option: Password('userpassword', attribute=True, autofill=False, cli_name='password', exclude='webui', multivalue=False, required=False)
option: Flag('random', attribute=False, autofill=True, cli_name='random', default=False, multivalue=False, required=False)
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))
diff --git a/tests/test_xmlrpc/test_user_plugin.py b/tests/test_xmlrpc/test_user_plugin.py
index 0370ec74d..c8984c51b 100644
--- a/tests/test_xmlrpc/test_user_plugin.py
+++ b/tests/test_xmlrpc/test_user_plugin.py
@@ -909,5 +909,135 @@ class test_user(Declarative):
expected=errors.MalformedUserPrincipal(principal='%s@BAD@NOTFOUND.ORG' % user1),
),
+ dict(
+ desc='Delete %r' % user1,
+ command=('user_del', [user1], {}),
+ expected=dict(
+ result=dict(failed=u''),
+ summary=u'Deleted user "tuser1"',
+ value=user1,
+ ),
+ ),
+
+ dict(
+ desc='Change default home directory',
+ command=(
+ 'config_mod', [], dict(ipahomesrootdir=u'/other-home'),
+ ),
+ expected=lambda x: True,
+ ),
+
+ dict(
+ desc='Create user %r with different default home directory' % user1,
+ command=(
+ 'user_add', [user1], dict(givenname=u'Test', sn=u'User1')
+ ),
+ expected=dict(
+ value=user1,
+ summary=u'Added user "tuser1"',
+ result=dict(
+ gecos=[u'Test User1'],
+ givenname=[u'Test'],
+ homedirectory=[u'/other-home/tuser1'],
+ krbprincipalname=[u'tuser1@' + api.env.realm],
+ loginshell=[u'/bin/sh'],
+ objectclass=objectclasses.user,
+ sn=[u'User1'],
+ uid=[user1],
+ uidnumber=[fuzzy_digits],
+ gidnumber=[fuzzy_digits],
+ displayname=[u'Test User1'],
+ cn=[u'Test User1'],
+ initials=[u'TU'],
+ ipauniqueid=[fuzzy_uuid],
+ krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \
+ [DN(('cn','global_policy'),('cn',api.env.realm),
+ ('cn','kerberos'),api.env.basedn)],
+ mepmanagedentry=lambda x: [DN(i) for i in x] == \
+ [DN(('cn',user1),('cn','groups'),('cn','accounts'),
+ api.env.basedn)],
+ memberof_group=[u'ipausers'],
+ has_keytab=False,
+ has_password=False,
+ dn=lambda x: DN(x) == \
+ DN(('uid','tuser1'),('cn','users'),('cn','accounts'),
+ api.env.basedn),
+ ),
+ ),
+ ),
+
+
+ dict(
+ desc='Reset default home directory',
+ command=(
+ 'config_mod', [], dict(ipahomesrootdir=u'/home'),
+ ),
+ expected=lambda x: True,
+ ),
+
+ dict(
+ desc='Delete %r' % user1,
+ command=('user_del', [user1], {}),
+ expected=dict(
+ result=dict(failed=u''),
+ summary=u'Deleted user "%s"' % user1,
+ value=user1,
+ ),
+ ),
+
+ dict(
+ desc='Change default login shell',
+ command=(
+ 'config_mod', [], dict(ipadefaultloginshell=u'/usr/bin/ipython'),
+ ),
+ expected=lambda x: True,
+ ),
+
+ dict(
+ desc='Create user %r with different default login shell' % user1,
+ command=(
+ 'user_add', [user1], dict(givenname=u'Test', sn=u'User1')
+ ),
+ expected=dict(
+ value=user1,
+ summary=u'Added user "tuser1"',
+ result=dict(
+ gecos=[u'Test User1'],
+ givenname=[u'Test'],
+ homedirectory=[u'/home/tuser1'],
+ krbprincipalname=[u'tuser1@' + api.env.realm],
+ loginshell=[u'/usr/bin/ipython'],
+ objectclass=objectclasses.user,
+ sn=[u'User1'],
+ uid=[user1],
+ uidnumber=[fuzzy_digits],
+ gidnumber=[fuzzy_digits],
+ displayname=[u'Test User1'],
+ cn=[u'Test User1'],
+ initials=[u'TU'],
+ ipauniqueid=[fuzzy_uuid],
+ krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \
+ [DN(('cn','global_policy'),('cn',api.env.realm),
+ ('cn','kerberos'),api.env.basedn)],
+ mepmanagedentry=lambda x: [DN(i) for i in x] == \
+ [DN(('cn',user1),('cn','groups'),('cn','accounts'),
+ api.env.basedn)],
+ memberof_group=[u'ipausers'],
+ has_keytab=False,
+ has_password=False,
+ dn=lambda x: DN(x) == \
+ DN(('uid','tuser1'),('cn','users'),('cn','accounts'),
+ api.env.basedn),
+ ),
+ ),
+ ),
+
+ dict(
+ desc='Reset default login shell',
+ command=(
+ 'config_mod', [], dict(ipadefaultloginshell=u'/bin/sh'),
+ ),
+ expected=lambda x: True,
+ ),
]