Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Xubuntu 16.04.1 / Linux Mint 18 XFCE / Linux Mint 18 Mate / Ubuntu Server 16.04.1 / Lubuntu 16.04.1
Posts: 146
Rep:
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.
Distribution: Xubuntu 16.04.1 / Linux Mint 18 XFCE / Linux Mint 18 Mate / Ubuntu Server 16.04.1 / Lubuntu 16.04.1
Posts: 146
Original Poster
Rep:
Quote:
Originally Posted by jefro
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.
I thought the same thing, that somehow I had messed up the permissions, but I can't find anything to support that premise. Just to be sure, though, I performed a fresh unmodified install of Xubuntu 16.04.1 onto an old hard drive, and the same situation occurred on first boot - no password is required to change the hostname through hostnamectl. As to the 'traditional host name', hostnamectl is changing the text in /etc/hostname, and I thought that was the reference for the systems's hostname.
I also tried one of my Linux Mint 18 Mate installations on a different computer, and again hostnamectl does not require a password to rewrite /etc/hostname. At the moment I'm inclined to think this is a bug in either systemd or Ubuntu's implementation of systemd.
Last edited by genogebot; 10-26-2016 at 06:03 PM.
Reason: More information
Distribution: Xubuntu 16.04.1 / Linux Mint 18 XFCE / Linux Mint 18 Mate / Ubuntu Server 16.04.1 / Lubuntu 16.04.1
Posts: 146
Original Poster
Rep:
Quote:
Originally Posted by Jjanel
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
Speak, and it shall be done :
Code:
$ ls -l `which hostnamectl`
-rwxr-xr-x 1 root root 294096 Oct 5 10:13 /usr/bin/hostnamectl
$ sum /usr/bin/hostnamectl
29693 288
$ dpkg -V systemd
??5?????? c /etc/systemd/system.conf
??5?????? c /etc/systemd/timesyncd.conf
??5?????? c /etc/systemd/journald.conf
Code:
$ debsums systemd | grep hostnamectl
/usr/bin/hostnamectl OK
/usr/share/bash-completion/completions/hostnamectl OK
/usr/share/man/man1/hostnamectl.1.gz OK
/usr/share/zsh/vendor-completions/_hostnamectl OK
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' "Crash Systemd in One Line as Any User"
Distribution: Xubuntu 16.04.1 / Linux Mint 18 XFCE / Linux Mint 18 Mate / Ubuntu Server 16.04.1 / Lubuntu 16.04.1
Posts: 146
Original Poster
Rep:
Quote:
Originally Posted by Jjanel
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'
Yeah, I tried tracing the calls when I was first investigating this, and I hit the same wall. I was trying to see at what point /etc/hostname was modified, but I couldn't find any reference to that file in the output, so I just moved on.
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.
Distribution: Xubuntu 16.04.1 / Linux Mint 18 XFCE / Linux Mint 18 Mate / Ubuntu Server 16.04.1 / Lubuntu 16.04.1
Posts: 146
Original Poster
Rep:
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.
Distribution: Xubuntu 16.04.1 / Linux Mint 18 XFCE / Linux Mint 18 Mate / Ubuntu Server 16.04.1 / Lubuntu 16.04.1
Posts: 146
Original Poster
Rep:
Quote:
Originally Posted by Jjanel
it 'talks' over socket to Dbus, so I have no idea how to trace the systemd 'MONSTER'
I followed the info at https://wiki.ubuntu.com/DebuggingDBus - specifically the part about 'How to monitor the system bus'. I did the modification on the old hard drive installation of Xubuntu 16.04.1 and did
Code:
sudo dbus-monitor --system > dbus-mon.txt
then in another terminal did
Code:
hostnamectl set-hostname Xubuntu-Bad
This produced a 60kB file containing a lot of method call debug text such as:
Read access is generally granted to all clients, but changes may only be made by privileged clients. PolicyKit is not used by this service, and access controlled exclusively via the D-Bus policy enforcement.
So perhaps the problem lies in Ubuntu's dbus security configuration.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.