4.12 Creating System Users and Groups with Info Packages

Use an "info-" package to create system users or groups (Linux groups, not Conary groups) on an underlying Linux system. This is typically necessary when you're packaging an application that needs to run as a specific user other than root. You can pair your application package with one or more info- packages as a dependency or in the same Conary group (such as in an appliance).

Create an info- package as you would any other package, and then use one of the templates here to start your package recipe.

Use the following template to start an info- package recipe used to create a new Linux system user:

class info_appuser(UserInfoRecipe):
    name = 'info-appuser'
    version = '1'

    def setup(r):
        r.User('appuser', 1001, group='examplegroup', groupid=1001,
               homedir='/home/appuser', shell='%(essentialbindir)s/bash',
               supplemental=['wheel','mysql'])

Replace the class name, package name, and version as appropriate, and replace the values in the User action to set up your Linux system user's information. You can remove or add arguments to the User action, too, as you need them. Use the following page in the Conary API for details about each argument you can use in the User action:

http://cvs.rpath.com/conary-docs/public/conary.build.usergroup.User-class.html

Use the following template to start an info- package recipe used to create a new Linux system group:

class info_examplegroup(GroupInfoRecipe):
    name = 'info-examplegroup'
    version = '1'

    def setup(r):
        r.Group('examplegroup', 999)

Replace the class name, package name, and version as appropriate, and replace the values in the Group action to set up your Linux system group's information. You can remove or add arguments to the Group action, too, as you need them, and you can add a SupplementalGroup action to create supplemental groups. Use the following pages in the Conary API for details about each arguments you can use in these action:

http://cvs.rpath.com/conary-docs/public/conary.build.usergroup.Group-class.html

http://cvs.rpath.com/conary-docs/public/conary.build.usergroup.SupplementalGroup-class.html

Avoiding User and Group Conflicts

Be aware of the system users and groups on the Linux platform for which you're developing. For rPath Linux, there is an rPath UID/GID registry that includes all the users and groups associated with packages in rPath Linux. This is currently maintained at rPath Linux:rPath UID Registry at wiki.rpath.com.