[packages/systemd] do not inherit $HOSTNAME when setting up /etc/hostname in systemd-units post scriptlet

Elan Ruusamäe glen at pld-linux.org
Wed Jun 3 15:57:00 CEST 2015


  the previous code caused permission issues in docker:

[root at localhost] # docker run -i -t pld bash
[root at fee5a8d66c6a /]# echo $HOSTNAME
fee5a8d66c6a
[root at fee5a8d66c6a /]# cat /etc/hostname
fee5a8d66c6a
[root at fee5a8d66c6a /]# poldek -u systemd-units
5:systemd-units ###########################################
mv: cannot move '/etc/hostname' to '/etc/hostname.rpmsave': Device or 
resource busy
Operation failed: No such file or directory
[root at fee5a8d66c6a /]# ls -l /etc/sysconfig/network /etc/hostname
ls: cannot access /etc/sysconfig/network: No such file or directory
-rw-r--r-- 1 root root 13 Jun  3 13:52 /etc/hostname
[root at fee5a8d66c6a /]# grep hostname /proc/mounts
/dev/mapper/sys-docker /etc/hostname xfs 
rw,relatime,attr2,inode64,noquota 0 0



why set up the file at all if the file already exists and is not-empty?



On 03.06.2015 16:55, glen wrote:
> commit dcd9e39e7ef3c53450b7de3db410af2e1bf3d2c6
> Author: Elan Ruusamäe <glen at delfi.ee>
> Date:   Wed Jun 3 16:51:32 2015 +0300
>
>      do not inherit $HOSTNAME when setting up /etc/hostname in systemd-units post scriptlet
>
>   systemd.spec | 1 +
>   1 file changed, 1 insertion(+)
> ---
> diff --git a/systemd.spec b/systemd.spec
> index 5a51496..7f2c20a 100644
> --- a/systemd.spec
> +++ b/systemd.spec
> @@ -935,6 +935,7 @@ if [ $1 -eq 1 ]; then
>   	ln -s "$target" %{_sysconfdir}/systemd/system/default.target || :
>   
>   	# Setup hostname
> +	HOSTNAME=
>   	[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
>   	if [ -n "$HOSTNAME" -a "$HOSTNAME" != "pldmachine" ]; then
>   		[ -f /etc/hostname ] && mv -f /etc/hostname /etc/hostname.rpmsave
> ================================================================
>
> ---- gitweb:
>
> http://git.pld-linux.org/gitweb.cgi/packages/systemd.git/commitdiff/dcd9e39e7ef3c53450b7de3db410af2e1bf3d2c6
>
> _______________________________________________
> pld-cvs-commit mailing list
> pld-cvs-commit at lists.pld-linux.org
> http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit


-- 
glen



More information about the pld-devel-en mailing list