timedatectl.c revision 2311eb2ff0c3ff80ec3645b02c97170c9a565454
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sievers/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sievers This file is part of systemd.
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sievers Copyright 2012 Lennart Poettering
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sievers systemd is free software; you can redistribute it and/or modify it
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sievers under the terms of the GNU Lesser General Public License as published by
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sievers the Free Software Foundation; either version 2.1 of the License, or
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sievers (at your option) any later version.
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sievers systemd is distributed in the hope that it will be useful, but
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sievers WITHOUT ANY WARRANTY; without even the implied warranty of
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sievers MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sievers Lesser General Public License for more details.
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sievers You should have received a copy of the GNU Lesser General Public License
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sievers along with systemd; If not, see <http://www.gnu.org/licenses/>.
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sieversstatic bool arg_adjust_system_clock = false;
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sieversstatic bool arg_no_pager = false;
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sieversstatic bool arg_ask_password = true;
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sieversstatic void pager_open_if_enabled(void) {
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sieversstatic void polkit_agent_open_if_enabled(void) {
5ba2dc259f3cdd8fddef68cfd28380a32534e49aKay Sievers /* Open the polkit agent as a child process if necessary */
7f112f50fea585411ea2d493b3582bea77eb4d6eLennart Poetteringstatic bool ntp_synced(void) {
8f0e73f250f4a397ea07d29a339bd7e64d077612Dave Reisner return false;
if (delta_minutes < 0) {
if (delta_minutes > 0) {
usec_t n;
char a[FORMAT_TIMESTAMP_MAX];
char b[FORMAT_TIMESTAMP_MAX];
int dn;
assert(i);
fprintf(stderr, "Warning: ignoring the TZ variable, reading the system's timezone setting only.\n\n");
char_array_0(a);
char_array_0(a);
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;