timedatectl.c revision f18ca9dcdeda247e208f7143e834fd2fb2070d80
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This file is part of systemd.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Copyright 2012 Lennart Poettering
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync systemd is free software; you can redistribute it and/or modify it
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync under the terms of the GNU Lesser General Public License as published by
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync the Free Software Foundation; either version 2.1 of the License, or
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (at your option) any later version.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync systemd is distributed in the hope that it will be useful, but
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync WITHOUT ANY WARRANTY; without even the implied warranty of
c9e322b412e61d2e8a70a12e23ddad716cd85a3fvboxsync MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Lesser General Public License for more details.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync You should have received a copy of the GNU Lesser General Public License
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync along with systemd; If not, see <http://www.gnu.org/licenses/>.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncstatic bool arg_adjust_system_clock = false;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncstatic bool arg_no_pager = false;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncstatic bool arg_ask_password = true;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncstatic void pager_open_if_enabled(void) {
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncstatic void polkit_agent_open_if_enabled(void) {
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /* Open the polkit agent as a child process if necessary */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynctypedef struct StatusInfo {
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync const char *timezone;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncstatic bool ntp_synced(void) {
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return false;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return false;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return true;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync assert_se(strftime(a, sizeof(a), "%a, %Y-%m-%d %H:%M:%S %Z", localtime_r(&sec, &tm)) > 0);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync assert_se(strftime(a, sizeof(a), "%a, %Y-%m-%d %H:%M:%S UTC", gmtime_r(&sec, &tm)) > 0);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if (r >= 0) {
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /* Calculcate the week-day */
char_array_0(a);
char_array_0(a);
char_array_0(a);
char_array_0(b);
char_array_0(a);
char_array_0(b);
if (i->local_rtc)
case DBUS_TYPE_STRING: {
if (!isempty(s)) {
i->timezone = s;
case DBUS_TYPE_BOOLEAN: {
dbus_bool_t b;
i->local_rtc = b;
i->ntp = b;
bus,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
&reply,
NULL,
return -EIO;
const char *name;
return -EIO;
return -EIO;
return -EIO;
usec_t t;
dbus_int64_t u;
u = (dbus_uint64_t) t;
return bus_method_call_with_reply(
bus,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
&reply,
NULL,
DBUS_TYPE_INT64, &u,
return bus_method_call_with_reply(
bus,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
&reply,
NULL,
return bus_method_call_with_reply(
bus,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
&reply,
NULL,
DBUS_TYPE_BOOLEAN, &b,
DBUS_TYPE_BOOLEAN, &q,
return bus_method_call_with_reply(
bus,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
&reply,
NULL,
DBUS_TYPE_BOOLEAN, &b,
return -errno;
char l[LINE_MAX], *p, **z, *w;
size_t k;
if (!fgets(l, sizeof(l), f)) {
if (feof(f))
return -errno;
p = strstrip(l);
w = strndup(p, k);
return log_oom();
free(w);
return log_oom();
zones = z;
if (zones)
puts(*i);
static int help(void) {
help();
case ARG_VERSION:
case ARG_ADJUST_SYSTEM_CLOCK:
arg_adjust_system_clock = true;
case ARG_NO_PAGER:
arg_no_pager = true;
return -EINVAL;
return -EINVAL;
const char* verb;
MORE,
LESS,
} argc_cmp;
const int argc;
} verbs[] = {
int left;
if (left <= 0)
help();
return -EINVAL;
case EQUAL:
return -EINVAL;
case MORE:
return -EINVAL;
case LESS:
return -EINVAL;
if (!bus) {
return -EIO;
log_open();
goto finish;
goto finish;
if (bus) {
pager_close();
return retval;