Bug 14724 - [meta-tpm] tpm2-tss recipe: extrausers bbclass is used instead of useradd
Summary: [meta-tpm] tpm2-tss recipe: extrausers bbclass is used instead of useradd
Status: RESOLVED FIXED
Alias: None
Product: Other YP Layers
Classification: Build System, Metadata & Runtime
Component: meta-security (show other bugs)
Version: unspecified
Hardware: All Multiple
: Undecided normal
Target Milestone: 4.0 M3
Assignee: akuster
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2022-02-17 10:15 UTC by Mykyta Dorokhin
Modified: 2022-06-16 04:11 UTC (History)
0 users

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mykyta Dorokhin 2022-02-17 10:15:26 UTC
If you look at tpm2-tss recipe of any version (in my current setup I use tpm2-tss_2.3.2.bb) you can see that extrausers class is used to add tss user and group. This is odd since Yocto reference manual explicitly states:


[quote]
The user and group operations added using the extrausers class are not tied to a specific recipe outside of the recipe for the image. Thus, the operations can be performed across the image as a whole. Use the useradd class to add user and group configuration to a specific recipe. 
[/quote]

Other recipies in meta-tmp also add users (for instance tpm2-abrmd, swtpm, trousers) and they do it with the help of useradd bbclass. I suspect this is a correct way to add users/groups from within a recipe. 


For example (tpm2-abrmd recipe):
inherit autotools pkgconfig systemd update-rc.d useradd
USERADD_PACKAGES = "${PN}"
GROUPADD_PARAM_${PN} = "tss"
USERADD_PARAM_${PN} = "--system -M -d /var/lib/tpm -s /bin/false -g tss tss"

Moreover, you won't find extrausers usages in meta-openembedded and other mainline layers. 

So I suppose extrausers is designed to be used only on image recipes and not in spicific recipies. Let alone, in the example above the tss user/group is created using useradd class

As a side effect, I see that in the built image/filesystem the tss user gets created with uid 1000:

bash-5.0# cat /etc/passwd | grep tss
tss:x:999:1000::/var/lib/tpm:/bin/false

which is not a common practice for system users.
Comment 1 akuster 2022-02-17 23:06:11 UTC
Thanks for letting me know. I will take a look shortly.