chiark / gitweb /
Merge nss-myhostname
[elogind.git] / src / login / loginctl.c
index 97c6617d7d4ef3f131d3e36584acdd6afba7b52b..e2b33a626c0029191a3f119fe43b442e90ba57f5 100644 (file)
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <getopt.h>
 #include <pwd.h>
+#include <locale.h>
 
 #include "log.h"
 #include "util.h"
@@ -50,26 +51,9 @@ static enum transport {
 static bool arg_ask_password = true;
 static const char *arg_host = NULL;
 
-static bool on_tty(void) {
-        static int t = -1;
-
-        /* Note that this is invoked relatively early, before we start
-         * the pager. That means the value we return reflects whether
-         * we originally were started on a tty, not if we currently
-         * are. But this is intended, since we want colour and so on
-         * when run in our own pager. */
-
-        if (_unlikely_(t < 0))
-                t = isatty(STDOUT_FILENO) > 0;
-
-        return t;
-}
-
 static void pager_open_if_enabled(void) {
 
         /* Cache result before we open the pager */
-        on_tty();
-
         if (arg_no_pager)
                 return;
 
@@ -339,7 +323,7 @@ typedef struct SeatStatusInfo {
 } SeatStatusInfo;
 
 static void print_session_status_info(SessionStatusInfo *i) {
-        char since1[FORMAT_TIMESTAMP_PRETTY_MAX], *s1;
+        char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
         char since2[FORMAT_TIMESTAMP_MAX], *s2;
         assert(i);
 
@@ -350,7 +334,7 @@ static void print_session_status_info(SessionStatusInfo *i) {
         else
                 printf("%u\n", (unsigned) i->uid);
 
-        s1 = format_timestamp_pretty(since1, sizeof(since1), i->timestamp);
+        s1 = format_timestamp_relative(since1, sizeof(since1), i->timestamp);
         s2 = format_timestamp(since2, sizeof(since2), i->timestamp);
 
         if (s1)
@@ -434,7 +418,7 @@ static void print_session_status_info(SessionStatusInfo *i) {
 }
 
 static void print_user_status_info(UserStatusInfo *i) {
-        char since1[FORMAT_TIMESTAMP_PRETTY_MAX], *s1;
+        char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
         char since2[FORMAT_TIMESTAMP_MAX], *s2;
         assert(i);
 
@@ -443,7 +427,7 @@ static void print_user_status_info(UserStatusInfo *i) {
         else
                 printf("%u\n", (unsigned) i->uid);
 
-        s1 = format_timestamp_pretty(since1, sizeof(since1), i->timestamp);
+        s1 = format_timestamp_relative(since1, sizeof(since1), i->timestamp);
         s2 = format_timestamp(since2, sizeof(since2), i->timestamp);
 
         if (s1)
@@ -1410,7 +1394,6 @@ static int parse_argv(int argc, char *argv[]) {
 
                 case ARG_VERSION:
                         puts(PACKAGE_STRING);
-                        puts(DISTRIBUTION);
                         puts(SYSTEMD_FEATURES);
                         return 0;
 
@@ -1585,6 +1568,7 @@ int main(int argc, char*argv[]) {
 
         dbus_error_init(&error);
 
+        setlocale(LC_ALL, "");
         log_parse_environment();
         log_open();