[Buildroot] [PATCH 02/10] package/systemd: add libnss-systemd to name resolution

Yann E. MORIN yann.morin.1998 at free.fr
Sun Jun 7 11:40:42 UTC 2020


Nrobert, All,

On 2020-02-06 10:36 +0100, Norbert Lange spake thusly:
> The feature DynamicUser creates users/groups without
> touching the /etc/{passwd,group} files on disk.
> Adding the dynamic resolver to /etc/nsswitch.conf
> ensures the Names are resolved consistently.
> 
> Signed-off-by: Norbert Lange <nolange79 at gmail.com>
> ---
>  package/systemd/systemd.mk | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
> index 05b07cfd1b..a390cdd1a9 100644
> --- a/package/systemd/systemd.mk
> +++ b/package/systemd/systemd.mk
> @@ -409,7 +409,15 @@ define SYSTEMD_INSTALL_MACHINEID_HOOK
>  	touch $(TARGET_DIR)/etc/machine-id
>  endef
>  
> +define SYSTEMD_ADD_NSSCONFIG_HOOK
> +	grep >/dev/null '^passwd:.*systemd' $(TARGET_DIR)/etc/nsswitch.conf || \

While this is valid sytx, we customarily put the redirection at the end
of the command.

However, in this case, you would want to use 'grep -q', as that does not
output anything.

> +		sed '/^passwd:/ s/$$/ systemd/' $(TARGET_DIR)/etc/nsswitch.conf

How can that even work? By default, sed will out put to stdout, not
replace in-place.

This clearly has not been tested (or git-commit --amend was forgotten).

In this case, you want to use $(SED) that includes the -i option to do
in-place modifications.

> +	grep >/dev/null '^group:.*systemd' $(TARGET_DIR)/etc/nsswitch.conf || \

Ditto grep -q.

> +		sed '/^group:/ s/$$/ systemd/' $(TARGET_DIR)/etc/nsswitch.conf

Ditto $(SED).

Regards,
Yann E. MORIN.

> +endef
> +
>  SYSTEMD_POST_INSTALL_TARGET_HOOKS += \
> +	SYSTEMD_ADD_NSSCONFIG_HOOK \
>  	SYSTEMD_INSTALL_INIT_HOOK \
>  	SYSTEMD_INSTALL_MACHINEID_HOOK \
>  	SYSTEMD_INSTALL_RESOLVCONF_HOOK
> -- 
> 2.24.1
> 

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'


More information about the buildroot mailing list