]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/hostname/hostnamed.c
hostname: re-read file later when failed to update file
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 22 Jan 2021 07:38:52 +0000 (16:38 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 9 Feb 2021 04:49:27 +0000 (13:49 +0900)
commitba12e41d059349039993fd240046c858cae4256b
treed97de435cfecbae1689ff95c640a6f3182531160
parentc388618ec03aceb3c8d4dca75b639f876f28dd99
hostname: re-read file later when failed to update file

Previously, even when writing e.g. /etc/hostname fails, the static
hostname in Context is not restored. So, the subsequent call of the same
method succeeds:
```
$ sudo chattr +i /etc/hostname
$ sudo hostnamectl --static set-hostname aaa
Could not set static hostname: Access denied
$ echo $?
1
$ sudo hostnamectl --static set-hostname aaa
$ echo $?
0
```

This makes when updating file is failed, the saved stat is cleared. So,
the static hostname or machine information in the context are always
consistent to the corresponding files.
src/hostname/hostnamed.c