public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Uladzimir Bely <ubely@ilbers.de>
To: isar-users@googlegroups.com,
	Quirin Gylstorff <Quirin.Gylstorff@siemens.com>
Subject: Re: [PATCH v3 1/2] classes/image-account-extension:Move account configuration to post-process
Date: Mon, 05 Sep 2022 14:01:05 +0300	[thread overview]
Message-ID: <25582074.1r3eYUQgxm@home> (raw)
In-Reply-To: <6790411.9J7NaK4W3v@home>

In the email from Friday, 2 September 2022 12:37:29 +03 user Uladzimir Bely 
wrote:
> During debugging the downstream I've found that this patch breaks build in
> case we want to have some specific homedir for 'root'.
> 
> E.g., if we have the following in local.conf:
> 
> USERS += "root"
> USER_root[home] = "/home/root"
> 
> it comes to "/usr/sbin/usermod --home /home/root --move-home root" execution
> under chroot and it fails with an error "usermod: user root is currently
> used by process NNN", where NNN seems to be PID of 'usermod' itself.
> 
> It looks a bit weird for me, because exactly the same thing was executed
> before the patch was applied, but with no any errors.
> 
> In default local.conf we don't change default root's homedir, so this issue
> was not caught earlier.
> 

After some investigations I found, that the issue is related to the mounted "/
proc" in case usermod is executed in chroot during "image post processing" 
stage. This leads to the error when attempting to change the current root's 
home directory.

Earlier, when it was done during "image configuration" stage, "/proc" was not 
yet mounted and we simply didn't see an error.

> Any ideas how that could be properly fixed without reverting?
> 
> In the email from Tuesday, 17 May 2022 15:37:12 +03 user Quirin Gylstorff
> 
> wrote:
> > 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>
> > ---
> > 
> >  RECIPE-API-CHANGELOG.md                      | 6 ++++++
> >  meta/classes/image-account-extension.bbclass | 5 ++---
> >  meta/classes/image.bbclass                   | 9 +++++++++
> >  3 files changed, 17 insertions(+), 3 deletions(-)
> > 
> > diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md
> > index f3b30351..d1ed6792 100644
> > --- a/RECIPE-API-CHANGELOG.md
> > +++ b/RECIPE-API-CHANGELOG.md
> > @@ -397,3 +397,9 @@ New conversions can be added by defining
> > CONVERSION_CMD_type. - the conversions appends its own type, e.g. the
> > output file of a conversion `xz` would be ${IMAGE_FULLNAME}.${type}.xz
> > 
> >      - a final chown is appended automatically
> > 
> > +
> > +### Handling of variables USERS and GROUPS is moved to image post
> > processing +
> > +The user and groups defined by the variables `USERS` and `GROUPS`
> > +was moved from image configuration to image post processing. The users
> > and
> > +groups are now created after all packages are installed.
> > diff --git a/meta/classes/image-account-extension.bbclass
> > b/meta/classes/image-account-extension.bbclass index c9bebe85..c64ba769
> > 100644
> > --- a/meta/classes/image-account-extension.bbclass
> > +++ b/meta/classes/image-account-extension.bbclass
> > @@ -58,9 +58,8 @@ 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"
> > -image_configure_accounts() {
> > +ROOTFS_POSTPROCESS_COMMAND += "image_postprocess_accounts"
> > +image_postprocess_accounts() {
> > 
> >      # Create groups
> >      # Add space to the end of the list:
> >      list='${@" ".join(d.getVar('IMAGE_ACCOUNTS_GROUPS', True).split())} '
> > 
> > diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> > index aa6c510c..0da56b7a 100644
> > --- a/meta/classes/image.bbclass
> > +++ b/meta/classes/image.bbclass
> > @@ -440,6 +440,15 @@ do_rootfs_quality_check() {
> > 
> >  	        args="${args} ! -path ${ROOTFSDIR}/etc/os-release";;
> >  	    
> >  	    image_postprocess_machine_id)
> >  	    
> >  	        args="${args} ! -path ${ROOTFSDIR}/etc/machine-id";;
> > 
> > +	    image_postprocess_accounts)
> > +	        args="${args} ! -path ${ROOTFSDIR}/etc/passwd \
> > +                          ! -path ${ROOTFSDIR}/etc/subgid \
> > +                          ! -path ${ROOTFSDIR}/etc/subuid \
> > +                          ! -path ${ROOTFSDIR}/etc/shadow- \
> > +                          ! -path ${ROOTFSDIR}/etc/gshadow \
> > +                          ! -path ${ROOTFSDIR}/etc/shadow \
> > +                          ! -path ${ROOTFSDIR}/etc/group"
> > +            ;;
> > 
> >  	esac
> >  	
> >      done
> >      found=$( sudo find ${ROOTFSDIR} -type f -newer $rootfs_install_stamp
> > 
> > $args )


-- 
Uladzimir Bely




  reply	other threads:[~2022-09-05 11:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-17 12:37 [PATCH v3 0/2] Fix possible build errors due to expired root account Quirin Gylstorff
2022-05-17 12:37 ` [PATCH v3 1/2] classes/image-account-extension:Move account configuration to post-process Quirin Gylstorff
2022-09-02  9:37   ` Uladzimir Bely
2022-09-05 11:01     ` Uladzimir Bely [this message]
2022-05-17 12:37 ` [PATCH v3 2/2] classes/image-account-extension: Add flag to force password change on first login Quirin Gylstorff
2022-05-25  6:17 ` [PATCH v3 0/2] Fix possible build errors due to expired root account Anton Mikanovich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=25582074.1r3eYUQgxm@home \
    --to=ubely@ilbers.de \
    --cc=Quirin.Gylstorff@siemens.com \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox