timedatectl.c revision e1636421f46db6d06fbd028ef20a3113fa3e11f8
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering This file is part of systemd.
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering Copyright 2012 Lennart Poettering
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering Copyright 2013 Kay Sievers
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering systemd is free software; you can redistribute it and/or modify it
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering under the terms of the GNU Lesser General Public License as published by
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering (at your option) any later version.
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering systemd is distributed in the hope that it will be useful, but
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering Lesser General Public License for more details.
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering You should have received a copy of the GNU Lesser General Public License
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringstatic bool arg_no_pager = false;
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringstatic bool arg_ask_password = true;
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringstatic BusTransport arg_transport = BUS_TRANSPORT_LOCAL;
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringstatic bool arg_adjust_system_clock = false;
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringstatic void pager_open_if_enabled(void) {
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringstatic void polkit_agent_open_if_enabled(void) {
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering /* Open the polkit agent as a child process if necessary */
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringtypedef struct StatusInfo {
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringstatic const char *jump_str(int delta_minutes, char *s, size_t size) {
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering return "one hour forward";
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering return "one hour backwards";
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering snprintf(s, size, "%i minutes backwards", -delta_minutes);
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering snprintf(s, size, "%i minutes forward", delta_minutes);
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);
if (i->rtc_time > 0) {
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->rtc_local)
bus,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
name,
&error,
*target = b;
bus,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
name,
&error,
r = sd_bus_get_property(
bus,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
&error,
&reply,
usec_t t;
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
&error,
NULL,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
&error,
NULL,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
&error,
NULL,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
&error,
NULL,
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)
static int help(void) {
help();
case ARG_VERSION:
case ARG_NO_ASK_PASSWORD:
arg_ask_password = false;
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;
log_open();
goto finish;
goto finish;
goto finish;
pager_close();
return ret;