#12 Home Directory Creation / Group Creation & Membership fails silently
Closed: Invalid None Opened 8 years ago by abraunegg.

During the development of a product I am working on, I want to create / add a user through anaconda with the password as specified by the user / installer.

Following the code in anaconda (users.py) the following is passed through to libuser to create the user:
#if not self.users.createUser(name='admin',
# password=self.adminPassword["password"],
# isCrypted=self.adminPassword["isCrypted"],
# groups=['users', 'wheel'],
# homedir=None,
# shell='/bin/bash',
# uid=None,
# algo=self.getPassAlgo(),
# lock=False,
# root=self.anaconda.rootPath,
# gecos='Admin User',
# mkmailspool=True,
# mkhomedir=True):
# log.error("Cannot create Admin User for CLI access.")

Based on my understanding this should:

  • Create an instance of libuser via admin.initUser
  • pass through details to admin.addUser to add the user, create the home directory
  • Set the password to the entry as entered via the installation process
  • Create the users group
  • Add the user to additional groups

This works: the user is created, but that is it. To actually get the password set, I have to run the users.setUserPassword() method which does set the password for the user correctly. No groups are created, no group membership is done, no home directory is set.

Reading /usr/share/doc/libuser-python-0.56.13/modules.txt, also indicates that creating the home directory is done my default:
- addUser: Add a new user to the system:

A libuser.Entity object with the
new user or group's information

A true/false object indicating
whether or not the home
directory for the user
should be created (optional,
defaults yes).
Based on the above - what should I be calling the libuser addUser method with to ensure that:
The user account home directory gets created
The user account password get's set properly
* The user account gets added to the right groups

Rebuilt system with libuser-0.58-3.fc18.src.rpm - addUser now works as expected.

I suspect that there is a problem using the inbuilt CentOS libuser-0.56.13-5.el6.src.rpm version.

Thanks for your report. The "users.createUser" function is a part of anaconda, not libuser.

Do you have a specific reproducer that uses libuser calls?

Closed due to lack of response. Please reopen at pagure.io if this is still relevant.

Login to comment on this ticket.