diff options
| -rw-r--r-- | meta/classes/useradd-staticids.bbclass | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/meta/classes/useradd-staticids.bbclass b/meta/classes/useradd-staticids.bbclass index 689c29c53f..5897fed20d 100644 --- a/meta/classes/useradd-staticids.bbclass +++ b/meta/classes/useradd-staticids.bbclass | |||
| @@ -96,27 +96,37 @@ def update_useradd_static_config(d): | |||
| 96 | # is used, and we disable the user_group option. | 96 | # is used, and we disable the user_group option. |
| 97 | # | 97 | # |
| 98 | uaargs.groupname = [uaargs.gid, uaargs.LOGIN][not uaargs.gid or uaargs.user_group] | 98 | uaargs.groupname = [uaargs.gid, uaargs.LOGIN][not uaargs.gid or uaargs.user_group] |
| 99 | uaargs.user_group = False | 99 | uaargs.groupid = [uaargs.gid, uaargs.groupname][not uaargs.gid] |
| 100 | uaargs.groupid = [field[3], uaargs.groupid][not field[3]] | ||
| 100 | 101 | ||
| 101 | uaargs.gid = [uaargs.gid, uaargs.groupname][not uaargs.gid] | 102 | if not uaargs.gid or uaargs.gid != uaargs.groupid: |
| 102 | uaargs.gid = [field[3], uaargs.gid][not field[3]] | 103 | if (uaargs.groupid and uaargs.groupid.isdigit()) and (uaargs.groupname and uaargs.groupname.isdigit()) and (uaargs.groupid != uaargs.groupname): |
| 103 | 104 | # We want to add a group, but we don't know it's name... so we can't add the group... | |
| 104 | if uaargs.groupname == uaargs.gid: | 105 | # We have to assume the group has previously been added or we'll fail on the adduser... |
| 105 | # Nothing to do... | 106 | # Note: specifying the actual gid is very rare in OE, usually the group name is specified. |
| 106 | pass | 107 | bb.warn("%s: Changing gid for login %s from (%s) to (%s), verify configuration files!" % (d.getVar('PN', True), uaargs.LOGIN, uaargs.groupname, uaargs.gid)) |
| 107 | elif (uaargs.groupname and uaargs.groupname.isdigit()) and (uaargs.gid and uaargs.gid.isdigit()) and (uaargs.groupname != uaargs.gid): | 108 | elif (uaargs.groupid and not uaargs.groupid.isdigit()) and uaargs.groupid == uaargs.groupname: |
| 108 | # We want to add a group, but we don't know it's name... so we can't add the group... | 109 | # We don't have a number, so we have to add a name |
| 109 | # We have to assume the group has previously been added or we'll fail on the adduser... | 110 | bb.debug(1, "Adding group %s!" % (uaargs.groupname)) |
| 110 | # Note: specifying the actual gid is very rare in OE, usually the group name is specified. | 111 | uaargs.gid = uaargs.groupid |
| 111 | bb.warn("%s: Changing gid for login %s from (%s) to (%s), verify configuration files!" % (d.getVar('PN', True), uaargs.LOGIN, uaargs.groupname, uaargs.gid)) | 112 | uaargs.user_group = False |
| 112 | elif uaargs.groupname and (uaargs.gid and uaargs.gid.isdigit()): | 113 | groupadd = d.getVar("GROUPADD_PARAM_%s" % pkg, True) |
| 113 | bb.debug(1, "Adding group %s gid (%s)!" % (uaargs.groupname, uaargs.gid)) | 114 | newgroup = "%s %s" % (['', ' --system'][uaargs.system], uaargs.groupname) |
| 114 | groupadd = d.getVar("GROUPADD_PARAM_%s" % pkg, True) | 115 | if groupadd: |
| 115 | newgroup = "-g %s %s" % (uaargs.gid, uaargs.groupname) | 116 | d.setVar("GROUPADD_PARAM_%s" % pkg, "%s ; %s" % (groupadd, newgroup)) |
| 116 | if groupadd: | 117 | else: |
| 117 | d.setVar("GROUPADD_PARAM_%s" % pkg, "%s ; %s" % (groupadd, newgroup)) | 118 | d.setVar("GROUPADD_PARAM_%s" % pkg, newgroup) |
| 118 | else: | 119 | elif uaargs.groupname and (uaargs.groupid and uaargs.groupid.isdigit()): |
| 119 | d.setVar("GROUPADD_PARAM_%s" % pkg, newgroup) | 120 | # We have a group name and a group number to assign it to |
| 121 | bb.debug(1, "Adding group %s gid (%s)!" % (uaargs.groupname, uaargs.groupid)) | ||
| 122 | uaargs.gid = uaargs.groupid | ||
| 123 | uaargs.user_group = False | ||
| 124 | groupadd = d.getVar("GROUPADD_PARAM_%s" % pkg, True) | ||
| 125 | newgroup = "-g %s %s" % (uaargs.gid, uaargs.groupname) | ||
| 126 | if groupadd: | ||
| 127 | d.setVar("GROUPADD_PARAM_%s" % pkg, "%s ; %s" % (groupadd, newgroup)) | ||
| 128 | else: | ||
| 129 | d.setVar("GROUPADD_PARAM_%s" % pkg, newgroup) | ||
| 120 | 130 | ||
| 121 | uaargs.comment = ["'%s'" % field[4], uaargs.comment][not field[4]] | 131 | uaargs.comment = ["'%s'" % field[4], uaargs.comment][not field[4]] |
| 122 | uaargs.home_dir = [field[5], uaargs.home_dir][not field[5]] | 132 | uaargs.home_dir = [field[5], uaargs.home_dir][not field[5]] |
