Bug 14724

Summary: [meta-tpm] tpm2-tss recipe: extrausers bbclass is used instead of useradd
Product: [Build System, Metadata & Runtime] Other YP Layers Reporter: Mykyta Dorokhin <kit-d>
Component: meta-securityAssignee: akuster <akuster808>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Undecided    
Version: unspecified   
Target Milestone: 4.0 M3   
Hardware: All   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

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.