After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 679281 - No way to change pretty hostname
No way to change pretty hostname
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Control-Center Maintainers
Control-Center Maintainers
: 676979 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-07-02 21:40 UTC by William Jon McCann
Modified: 2012-08-22 13:24 UTC
See Also:
GNOME target: 3.6
GNOME version: ---



Description William Jon McCann 2012-07-02 21:40:29 UTC
The pretty hostname is not editable even for admin accounts.

Also, we don't seem to be monitoring the service for name changes.
Comment 1 Matthias Clasen 2012-07-02 21:45:53 UTC
The hostname is not editable because the default policy has

        <action id="org.freedesktop.hostname1.set-hostname">
                <description>Set host name</description>
                <description xml:lang="pl">Ustawienie nazwy komputera</description>
                <message>Authentication is required to set the local host name.</message>
                <message xml:lang="pl">Wymagane jest uwierzytelnienie, aby ustawić nazwę lokalnego komputera.</message>
                <defaults>
                        <allow_any>auth_admin_keep</allow_any>
                        <allow_inactive>auth_admin_keep</allow_inactive>
                        <allow_active>auth_admin_keep</allow_active>
                </defaults>
        </action>

And gnome-control-center doesn't make the field editable unless the polkit response is 'yes'. Possible solutions:

- add a way to bring up the polkit auth dialog when the reply from polkit is 'maybe'

- override the default policy by installing a rules file that sets allow_active to 'yes'
Comment 2 William Jon McCann 2012-07-03 12:58:03 UTC
Can we make it a "yes" for admins in active sessions?
Comment 3 Matthias Clasen 2012-07-03 19:27:17 UTC
It is possible to write a rule that does that, pretty sure.

http://www.freedesktop.org/software/polkit/docs/latest/polkit.8.html#polkit-rules

has instructive examples
Comment 4 William Jon McCann 2012-07-03 19:28:51 UTC
That would make a reasonable default I think.
Comment 5 Frederic Peters 2012-08-20 21:50:08 UTC
<hadess> fredp, another one for 3.6 blockers: https://bugzilla.gnome.org/show_bug.cgi?id=679281
Comment 6 Matthias Clasen 2012-08-22 04:01:30 UTC
Here's a rule that works:

polkit.addRule(function(action, subject) {
        if (action.id == "org.freedesktop.hostname1.set-static-hostname" &&
            subject.local &&
            subject.active &&
            subject.isInGroup ("wheel")) {
                return polkit.Result.YES;
        }
});

Put this in a file called gnome-control-center.rules, and install it in /usr/share/polkit-1/rules.d/
Comment 7 Bastien Nocera 2012-08-22 13:17:11 UTC
commit 4d62e05fb088d64c3133912f0995a42157b8e968
Author: Matthias Clasen <mclasen@redhat.com>
Date:   Wed Aug 22 14:15:04 2012 +0100

    common: Add Policykit rules for hostname setting
    
    Allow setting the computer's pretty hostname if the user is an admin.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679281
Comment 8 Allan Day 2012-08-22 13:24:49 UTC
*** Bug 676979 has been marked as a duplicate of this bug. ***