[1/2] classes/image-account-extension:Move account configuration to post-process

Message ID 20220511131338.450234-2-Quirin.Gylstorff@siemens.com
State Superseded, archived
Headers show
Series Fix possible build errors due to expired root account | expand

Commit Message

Quirin Gylstorff May 11, 2022, 5:13 a.m. UTC
From: Quirin Gylstorff <quirin.gylstorff@siemens.com>

If the root account is deactivate during rootfs configuration
, e.g. by setting 'USER_root[expire]="01-01-1970"', the following error
occurs if a packages tries to create/modifies a user account.

```
Setting up systemd (247.3-7) ...
Created symlink /etc/systemd/system/getty.target.wants/getty@tty1.service -> /lib/systemd/system/getty@.service.
Created symlink /etc/systemd/system/multi-user.target.wants/remote-fs.target -> /lib/systemd/system/remote-fs.target.
Created symlink /etc/systemd/system/sysinit.target.wants/systemd-pstore.service -> /lib/systemd/system/systemd-pstore.service.
Initializing machine ID from random generator.
Your account has expired; please contact your system administrator.
chfn: PAM: Authentication failure
adduser: `/bin/chfn -f systemd Network Management systemd-network' returned error code 1. Exiting.
dpkg: error processing package systemd (--configure):
installed systemd package post-installation script subprocess returned error exit status 1
Setting up dmsetup (2:1.02.175-2.1) ...
Errors were encountered while processing:
systemd
E: Sub-process /usr/bin/dpkg returned an error code (1)
WARNING: exit code 100 from a shell command.
```

This move also allows  /etc/skel modification to be applicable to
all users.

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
 meta/classes/image-account-extension.bbclass | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Henning Schild May 11, 2022, 6:57 a.m. UTC | #1
I once had this in the context of adding users to groups which are
coming from packages. i.e. the docker group

In order to add a user to that group one will also have to add the
group, and essentially copy that group creation from the postinst from
the group creating package. Like what type of group, or a fixed gid and
things like that.

So moving the user creation into postinst is imho a really good idea.
However a significant change that might be worth a changelog entry. I
would have to drop group creation of "docker" or "www" and things like
that from some layers.

regards,
Henning

Am Wed, 11 May 2022 15:13:37 +0200
schrieb Quirin Gylstorff <Quirin.Gylstorff@siemens.com>:

> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> 
> If the root account is deactivate during rootfs configuration
> , e.g. by setting 'USER_root[expire]="01-01-1970"', the following
> error occurs if a packages tries to create/modifies a user account.
> 
> ```
> Setting up systemd (247.3-7) ...
> Created symlink
> /etc/systemd/system/getty.target.wants/getty@tty1.service ->
> /lib/systemd/system/getty@.service. Created symlink
> /etc/systemd/system/multi-user.target.wants/remote-fs.target ->
> /lib/systemd/system/remote-fs.target. Created symlink
> /etc/systemd/system/sysinit.target.wants/systemd-pstore.service ->
> /lib/systemd/system/systemd-pstore.service. Initializing machine ID
> from random generator. Your account has expired; please contact your
> system administrator. chfn: PAM: Authentication failure adduser:
> `/bin/chfn -f systemd Network Management systemd-network' returned
> error code 1. Exiting. dpkg: error processing package systemd
> (--configure): installed systemd package post-installation script
> subprocess returned error exit status 1 Setting up dmsetup
> (2:1.02.175-2.1) ... Errors were encountered while processing:
> systemd E: Sub-process /usr/bin/dpkg returned an error code (1)
> WARNING: exit code 100 from a shell command. ```
> 
> This move also allows  /etc/skel modification to be applicable to
> all users.
> 
> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> ---
>  meta/classes/image-account-extension.bbclass | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/meta/classes/image-account-extension.bbclass
> b/meta/classes/image-account-extension.bbclass index
> c9bebe85..caa962a0 100644 ---
> a/meta/classes/image-account-extension.bbclass +++
> b/meta/classes/image-account-extension.bbclass @@ -58,8 +58,7 @@
> IMAGE_ACCOUNTS_GROUPS =+ "${@gen_accounts_array(d, 'GROUPS', 'GROUP',
> ['gid', 'f do_rootfs_install[vardeps] += "${IMAGE_ACCOUNTS_GROUPS}
> ${IMAGE_ACCOUNTS_USERS}" 
> -ROOTFS_CONFIGURE_COMMAND += "image_configure_accounts"
> -image_configure_accounts[weight] = "3"
> +ROOTFS_POSTPROCESS_COMMAND += "image_configure_accounts"
>  image_configure_accounts() {
>      # Create groups
>      # Add space to the end of the list:
Jan Kiszka May 11, 2022, 9:53 p.m. UTC | #2
On 11.05.22 16:57, Henning Schild wrote:
> I once had this in the context of adding users to groups which are
> coming from packages. i.e. the docker group
> 
> In order to add a user to that group one will also have to add the
> group, and essentially copy that group creation from the postinst from
> the group creating package. Like what type of group, or a fixed gid and
> things like that.
> 
> So moving the user creation into postinst is imho a really good idea.
> However a significant change that might be worth a changelog entry. I
> would have to drop group creation of "docker" or "www" and things like
> that from some layers.
> 

Good points, and second reason to actually change the ordering. Then
let's do this, with a proper changelog.

Jan

> regards,
> Henning
> 
> Am Wed, 11 May 2022 15:13:37 +0200
> schrieb Quirin Gylstorff <Quirin.Gylstorff@siemens.com>:
> 
>> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>>
>> If the root account is deactivate during rootfs configuration
>> , e.g. by setting 'USER_root[expire]="01-01-1970"', the following
>> error occurs if a packages tries to create/modifies a user account.
>>
>> ```
>> Setting up systemd (247.3-7) ...
>> Created symlink
>> /etc/systemd/system/getty.target.wants/getty@tty1.service ->
>> /lib/systemd/system/getty@.service. Created symlink
>> /etc/systemd/system/multi-user.target.wants/remote-fs.target ->
>> /lib/systemd/system/remote-fs.target. Created symlink
>> /etc/systemd/system/sysinit.target.wants/systemd-pstore.service ->
>> /lib/systemd/system/systemd-pstore.service. Initializing machine ID
>> from random generator. Your account has expired; please contact your
>> system administrator. chfn: PAM: Authentication failure adduser:
>> `/bin/chfn -f systemd Network Management systemd-network' returned
>> error code 1. Exiting. dpkg: error processing package systemd
>> (--configure): installed systemd package post-installation script
>> subprocess returned error exit status 1 Setting up dmsetup
>> (2:1.02.175-2.1) ... Errors were encountered while processing:
>> systemd E: Sub-process /usr/bin/dpkg returned an error code (1)
>> WARNING: exit code 100 from a shell command. ```
>>
>> This move also allows  /etc/skel modification to be applicable to
>> all users.
>>
>> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>> ---
>>  meta/classes/image-account-extension.bbclass | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/meta/classes/image-account-extension.bbclass
>> b/meta/classes/image-account-extension.bbclass index
>> c9bebe85..caa962a0 100644 ---
>> a/meta/classes/image-account-extension.bbclass +++
>> b/meta/classes/image-account-extension.bbclass @@ -58,8 +58,7 @@
>> IMAGE_ACCOUNTS_GROUPS =+ "${@gen_accounts_array(d, 'GROUPS', 'GROUP',
>> ['gid', 'f do_rootfs_install[vardeps] += "${IMAGE_ACCOUNTS_GROUPS}
>> ${IMAGE_ACCOUNTS_USERS}" 
>> -ROOTFS_CONFIGURE_COMMAND += "image_configure_accounts"
>> -image_configure_accounts[weight] = "3"
>> +ROOTFS_POSTPROCESS_COMMAND += "image_configure_accounts"
>>  image_configure_accounts() {
>>      # Create groups
>>      # Add space to the end of the list:
>

Patch

diff --git a/meta/classes/image-account-extension.bbclass b/meta/classes/image-account-extension.bbclass
index c9bebe85..caa962a0 100644
--- a/meta/classes/image-account-extension.bbclass
+++ b/meta/classes/image-account-extension.bbclass
@@ -58,8 +58,7 @@  IMAGE_ACCOUNTS_GROUPS =+ "${@gen_accounts_array(d, 'GROUPS', 'GROUP', ['gid', 'f
 
 do_rootfs_install[vardeps] += "${IMAGE_ACCOUNTS_GROUPS} ${IMAGE_ACCOUNTS_USERS}"
 
-ROOTFS_CONFIGURE_COMMAND += "image_configure_accounts"
-image_configure_accounts[weight] = "3"
+ROOTFS_POSTPROCESS_COMMAND += "image_configure_accounts"
 image_configure_accounts() {
     # Create groups
     # Add space to the end of the list: