systemd hostnamectl changes hostname without sudo
If I want to change the hostname on one of my Xubuntu 16.04.1 installations I usually edit /etc/hostname and /etc/hosts, which requires doing the usual 'sudo' to access the files in write mode as both have '-rw-r--r-' permissions.
I recently saw reference to the systemd command 'hostnamectl' which changes the environment variable and edits /etc/hostname at the same time, but I have found that it does not require 'sudo'. I can just enter 'hostnamectl set-hostname <whatever>' in a terminal and the string in /etc/hostname has been changed, without ever being asked for a password. Is hostnamectl supposed to do that? It means anyone can change the hostname without root access. Surely this should require an admin password to do that. |
When I see this I assume that the user has been granted some higher level permission. You'd have to check on that to be sure. I get the feeling that you are not changing the traditional host name.
Look at this for some tips. https://www.freedesktop.org/software...stnamectl.html http://www.cyberciti.biz/faq/rhel-re...tname-command/ |
Quote:
Code:
phil@Xubuntu-Development:~$ hostname |
Wow! "If it's too good|bad to be true, it probably isn't [true]"! Maybe post output of:
ls -l `which hostnamectl` sum /usr/bin/hostnamectl dpkg -V systemd |
Quote:
Code:
$ ls -l `which hostnamectl` Code:
$ debsums systemd | grep hostnamectl |
file /usr/bin/hostnamectl
will probably say 64bit; mine is 32bit, but it's probably ok [because] I tried [strace then] ltrace -S -f -o xx [sudo] hostnamectl set-hostname whatever *BUT* it 'talks' over socket to Dbus, so I have no idea how to trace the systemd 'MONSTER' & gave up. No idea on the dpkg -V 'errors[?]' ... Over to next LQ 'hacker' :D "Crash Systemd in One Line as Any User" |
Quote:
|
It is true! I have a little domesticated Mint in a VM to support friends who run *buntus. User definitely can change the hostname without elevated rights.
|
Find the command and change file based permissions. ???
Another systemd bug. ?? |
Ok, on the (possibly incorrect) assumption that this is a bug in Ubuntu, I filed a bug report at https://bugs.launchpad.net/ubuntu/+s...d/+bug/1637030. The bug reporting system made it 'private' because it is security-related. Presumably that will change.
|
I have RPi here running Raspbian (Debian) for Agocontrol. I tried to change the hostname as unprivileged user and was asked to authenticate.
|
Quote:
|
Quote:
edit: also tried on one of my Arch linux machines, and was prompted when attempting as a non-privileged user. |
1 Attachment(s)
Quote:
Code:
sudo dbus-monitor --system > dbus-mon.txt Code:
hostnamectl set-hostname Xubuntu-Bad Code:
method call time=1477537351.012853 sender=:1.66 -> destination=org.freedesktop.hostname1 serial=4 path=/org/freedesktop/hostname1; interface=org.freedesktop.hostname1; member=SetHostname Was it helpful? Not in the least :) Not yet, anyway. I'm still digging through it. I did see (at https://www.freedesktop.org/wiki/Software/systemd/dbus/ this: Quote:
|
|
All times are GMT -5. The time now is 03:52 PM. |