chiark / gitweb /
Fix --no-ask-password
[elogind.git] / src / hostname / hostnamectl.c
index a1e1bd84437afb0cb79a04cf992f17f60c0e1cf3..d108a2489dfee175c3a3e2a747af1c5db763d97c 100644 (file)
@@ -79,14 +79,18 @@ static void print_status_info(StatusInfo *i) {
         printf("   Static hostname: %s\n",
                strna(i->static_hostname));
 
-        if (!streq_ptr(i->hostname, i->static_hostname))
+        if (!isempty(i->pretty_hostname) &&
+            !streq_ptr(i->pretty_hostname, i->static_hostname))
+                printf("   Pretty hostname: %s\n",
+                       strna(i->pretty_hostname));
+
+        if (!isempty(i->hostname) &&
+            !streq_ptr(i->hostname, i->static_hostname))
                 printf("Transient hostname: %s\n",
                        strna(i->hostname));
 
-        printf("   Pretty hostname: %s\n"
-               "         Icon name: %s\n"
+        printf("         Icon name: %s\n"
                "           Chassis: %s\n",
-               strna(i->pretty_hostname),
                strna(i->icon_name),
                strna(i->chassis));
 
@@ -215,7 +219,7 @@ static int show_status(DBusConnection *bus, char **args, unsigned n) {
 
 static int set_hostname(DBusConnection *bus, char **args, unsigned n) {
         _cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
-        dbus_bool_t interactive = true;
+        dbus_bool_t interactive = arg_ask_password;
         _cleanup_free_ char *h = NULL;
         const char *hostname = args[1];
         int r;
@@ -307,7 +311,7 @@ static int set_hostname(DBusConnection *bus, char **args, unsigned n) {
 
 static int set_icon_name(DBusConnection *bus, char **args, unsigned n) {
         _cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
-        dbus_bool_t interactive = true;
+        dbus_bool_t interactive = arg_ask_password;
 
         assert(args);
         assert(n == 2);
@@ -329,7 +333,7 @@ static int set_icon_name(DBusConnection *bus, char **args, unsigned n) {
 
 static int set_chassis(DBusConnection *bus, char **args, unsigned n) {
         _cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
-        dbus_bool_t interactive = true;
+        dbus_bool_t interactive = arg_ask_password;
 
         assert(args);
         assert(n == 2);
@@ -358,6 +362,7 @@ static int help(void) {
                "     --transient         Only set transient hostname\n"
                "     --static            Only set static hostname\n"
                "     --pretty            Only set pretty hostname\n"
+               "  -P --privileged        Acquire privileges before execution\n"
                "     --no-ask-password   Do not prompt for password\n"
                "  -H --host=[USER@]HOST  Operate on remote host\n\n"
                "Commands:\n"