|
|
590d18 |
From d17b314d405d2c127a3d51d2076e8982d43aa505 Mon Sep 17 00:00:00 2001
|
|
|
590d18 |
From: Jan Cholasta <jcholast@redhat.com>
|
|
|
590d18 |
Date: Wed, 23 Sep 2015 13:09:44 +0200
|
|
|
590d18 |
Subject: [PATCH] platform: add option to create home directory when adding
|
|
|
590d18 |
user
|
|
|
590d18 |
|
|
|
590d18 |
https://fedorahosted.org/freeipa/ticket/5314
|
|
|
590d18 |
|
|
|
590d18 |
Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
|
|
|
590d18 |
---
|
|
|
590d18 |
ipaplatform/base/tasks.py | 8 ++++++--
|
|
|
590d18 |
ipaplatform/redhat/tasks.py | 4 ++--
|
|
|
590d18 |
2 files changed, 8 insertions(+), 4 deletions(-)
|
|
|
590d18 |
|
|
|
590d18 |
diff --git a/ipaplatform/base/tasks.py b/ipaplatform/base/tasks.py
|
|
|
590d18 |
index 65715145af533c90038b3e8667da07fd28b7ec56..573287c6bf732991946a75c8817899ee6c1842e3 100644
|
|
|
590d18 |
--- a/ipaplatform/base/tasks.py
|
|
|
590d18 |
+++ b/ipaplatform/base/tasks.py
|
|
|
590d18 |
@@ -184,7 +184,7 @@ class BaseTaskNamespace(object):
|
|
|
590d18 |
|
|
|
590d18 |
return
|
|
|
590d18 |
|
|
|
590d18 |
- def create_system_user(self, name, group, homedir, shell, uid = None, gid = None, comment = None):
|
|
|
590d18 |
+ def create_system_user(self, name, group, homedir, shell, uid=None, gid=None, comment=None, create_homedir=False):
|
|
|
590d18 |
"""Create a system user with a corresponding group"""
|
|
|
590d18 |
try:
|
|
|
590d18 |
grp.getgrnam(group)
|
|
|
590d18 |
@@ -211,12 +211,16 @@ class BaseTaskNamespace(object):
|
|
|
590d18 |
'-g', group,
|
|
|
590d18 |
'-d', homedir,
|
|
|
590d18 |
'-s', shell,
|
|
|
590d18 |
- '-M', '-r', name,
|
|
|
590d18 |
+ '-r', name,
|
|
|
590d18 |
]
|
|
|
590d18 |
if uid:
|
|
|
590d18 |
args += ['-u', str(uid)]
|
|
|
590d18 |
if comment:
|
|
|
590d18 |
args += ['-c', comment]
|
|
|
590d18 |
+ if create_homedir:
|
|
|
590d18 |
+ args += ['-m']
|
|
|
590d18 |
+ else:
|
|
|
590d18 |
+ args += ['-M']
|
|
|
590d18 |
try:
|
|
|
590d18 |
ipautil.run(args)
|
|
|
590d18 |
log.debug('Done adding user')
|
|
|
590d18 |
diff --git a/ipaplatform/redhat/tasks.py b/ipaplatform/redhat/tasks.py
|
|
|
590d18 |
index 1af99d318c6745b1e5285c7829c2b292f86c8390..db31cd04cb234fac8fee97f3579ba2ca919f3262 100644
|
|
|
590d18 |
--- a/ipaplatform/redhat/tasks.py
|
|
|
590d18 |
+++ b/ipaplatform/redhat/tasks.py
|
|
|
590d18 |
@@ -399,7 +399,7 @@ class RedHatTaskNamespace(BaseTaskNamespace):
|
|
|
590d18 |
|
|
|
590d18 |
return True
|
|
|
590d18 |
|
|
|
590d18 |
- def create_system_user(self, name, group, homedir, shell, uid = None, gid = None, comment = None):
|
|
|
590d18 |
+ def create_system_user(self, name, group, homedir, shell, uid=None, gid=None, comment=None, create_homedir=False):
|
|
|
590d18 |
"""
|
|
|
590d18 |
Create a system user with a corresponding group
|
|
|
590d18 |
|
|
|
590d18 |
@@ -420,7 +420,7 @@ class RedHatTaskNamespace(BaseTaskNamespace):
|
|
|
590d18 |
comment = 'DS System User'
|
|
|
590d18 |
|
|
|
590d18 |
super(RedHatTaskNamespace, self).create_system_user(name, group,
|
|
|
590d18 |
- homedir, shell, uid, gid, comment)
|
|
|
590d18 |
+ homedir, shell, uid, gid, comment, create_homedir)
|
|
|
590d18 |
|
|
|
590d18 |
|
|
|
590d18 |
tasks = RedHatTaskNamespace()
|
|
|
590d18 |
--
|
|
|
590d18 |
2.4.3
|
|
|
590d18 |
|