chiark / gitweb /
test: extend calendarspec test a bit
[elogind.git] / src / hostname / hostnamectl.c
index 33245dd4f98d4d6e21622454ea40bb64953e8ed0..265c7ecbfe6ccc1c2bf14b1bcce03737cd2979ca 100644 (file)
 #include <stdbool.h>
 #include <unistd.h>
 #include <getopt.h>
+#include <locale.h>
 #include <string.h>
 #include <sys/timex.h>
+#include <sys/utsname.h>
 
 #include "dbus-common.h"
 #include "util.h"
@@ -66,7 +68,9 @@ typedef struct StatusInfo {
 static void print_status_info(StatusInfo *i) {
         sd_id128_t mid, bid;
         int r;
-        const char *id;
+        const char *id = NULL;
+        _cleanup_free_ char *pretty_name = NULL, *cpe_name = NULL;
+        struct utsname u;
 
         assert(i);
 
@@ -90,8 +94,24 @@ static void print_status_info(StatusInfo *i) {
         if (r >= 0)
                 printf("           Boot ID: " SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(bid));
 
-        if (detect_virtualization(&id) >= 0)
+        if (detect_virtualization(&id) > 0)
                 printf("    Virtualization: %s\n", id);
+
+        r = parse_env_file("/etc/os-release", NEWLINE,
+                           "PRETTY_NAME", &pretty_name,
+                           "CPE_NAME", &cpe_name,
+                           NULL);
+
+        if (!isempty(pretty_name))
+                printf("  Operating System: %s\n", pretty_name);
+
+        if (!isempty(cpe_name))
+                printf("       CPE OS Name: %s\n", cpe_name);
+
+        assert_se(uname(&u) >= 0);
+        printf("            Kernel: %s %s\n"
+               "      Architecture: %s\n", u.sysname, u.release, u.machine);
+
 }
 
 static int status_property(const char *name, DBusMessageIter *iter, StatusInfo *i) {
@@ -383,6 +403,10 @@ static int parse_argv(int argc, char *argv[]) {
                         arg_set_static = true;
                         break;
 
+                case ARG_NO_ASK_PASSWORD:
+                        arg_ask_password = false;
+                        break;
+
                 case '?':
                         return -EINVAL;
 
@@ -411,7 +435,7 @@ static int hostnamectl_main(DBusConnection *bus, int argc, char *argv[], DBusErr
                 int (* const dispatch)(DBusConnection *bus, char **args, unsigned n);
         } verbs[] = {
                 { "status",              LESS,   1, show_status         },
-                { "set-hostname",        LESS,   2, set_hostname        },
+                { "set-hostname",        EQUAL,  2, set_hostname        },
                 { "set-icon-name",       EQUAL,  2, set_icon_name       },
         };
 
@@ -488,6 +512,7 @@ int main(int argc, char *argv[]) {
 
         dbus_error_init(&error);
 
+        setlocale(LC_ALL, "");
         log_parse_environment();
         log_open();