Commit 9011abf3 authored by Marco Mariani's avatar Marco Mariani

cygwin: always prefix partition group names with grp_

parent 322bea2b
...@@ -427,7 +427,7 @@ class Computer(object): ...@@ -427,7 +427,7 @@ class Computer(object):
# Reconstructing User's # Reconstructing User's
partition.path = os.path.join(self.instance_root, partition.reference) partition.path = os.path.join(self.instance_root, partition.reference)
partition.user.setPath(partition.path) partition.user.setPath(partition.path)
partition.user.additional_group_list = [slapsoft.name] partition.user.additional_group_list = [slapsoft.groupname]
if alter_user: if alter_user:
partition.user.create() partition.user.create()
...@@ -548,6 +548,17 @@ class User(object): ...@@ -548,6 +548,17 @@ class User(object):
def setPath(self, path): def setPath(self, path):
self.path = path self.path = path
@property
def groupname(self):
"""
Prepend 'grp_' in cygwin, where users and groups
cannot have the same name.
"""
if sys.platform == 'cygwin':
return 'grp_%s' % self.name
else:
return self.name
def create(self): def create(self):
""" """
Create a user on the system who will be named after the self.name with its Create a user on the system who will be named after the self.name with its
...@@ -559,14 +570,13 @@ class User(object): ...@@ -559,14 +570,13 @@ class User(object):
# XXX: This method shall be no-op in case if all is correctly setup # XXX: This method shall be no-op in case if all is correctly setup
# This method shall check if all is correctly done # This method shall check if all is correctly done
# This method shall not reset groups, just add them # This method shall not reset groups, just add them
grpname = 'grp_' + self.name if sys.platform == 'cygwin' else self.name
try: try:
grp.getgrnam(grpname) grp.getgrnam(self.groupname)
except KeyError: except KeyError:
callAndRead(['groupadd', grpname]) callAndRead(['groupadd', self.groupname])
user_parameter_list = ['-d', self.path, '-g', self.name] user_parameter_list = ['-d', self.path, '-g', self.groupname]
if self.additional_group_list is not None: if self.additional_group_list:
user_parameter_list.extend(['-G', ','.join(self.additional_group_list)]) user_parameter_list.extend(['-G', ','.join(self.additional_group_list)])
user_parameter_list.append(self.name) user_parameter_list.append(self.name)
try: try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment