~axino/mojo/devel

« back to all changes in this revision

Viewing changes to mojo/contain.py

  • Committer: mergebot at canonical
  • Author(s): "Tom Haddon"
  • Date: 2021-04-08 10:00:49 UTC
  • mfrom: (584.1.1 build-str-buffer)
  • Revision ID: mergebot@juju-139df4-prod-is-toolbox-0.canonical.com-20210408100049-2fwumg8ouokx081g
Convert subprocess output to string before trying to split on colon in create_user method

Reviewed-on: https://code.launchpad.net/~mthaddon/mojo/build-str-buffer/+merge/400785
Reviewed-by: Benjamin Allot <benjamin.allot@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
844
844
        getent_command, _ = get_command("getent")
845
845
        (username, shadow, uid, gid, name, home, shell) = subprocess.check_output(
846
846
            [getent_command, "passwd", user]
847
 
        ).split(":")
 
847
        ).decode("utf-8").strip().split(":")
848
848
        # if the uid exists update the name to match the caller
849
849
        try:
850
850
            command = "useradd --home {} --create-home --uid {} {}".format(home, uid, username)