summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac13
-rw-r--r--m4/ax_compiler_vendor.m487
-rw-r--r--man/systemd-path.xml4
-rw-r--r--man/systemd-run.xml7
-rw-r--r--shell-completion/bash/systemd-run2
-rw-r--r--src/basic/time-util.c4
-rw-r--r--src/core/main.c27
-rw-r--r--src/libsystemd-network/sd-dhcp-lease.c6
-rw-r--r--src/libsystemd-network/sd-dhcp-server.c8
-rw-r--r--src/network/networkctl.c8
-rw-r--r--src/network/networkd-link.c8
-rw-r--r--src/network/networkd-network.c6
-rw-r--r--src/run/run.c39
13 files changed, 180 insertions, 39 deletions
diff --git a/configure.ac b/configure.ac
index d9ab3624dd..10e42c07be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,9 +39,14 @@ AM_SILENT_RULES([yes])
AC_CANONICAL_HOST
AC_DEFINE_UNQUOTED([CANONICAL_HOST], "$host", [Canonical host string.])
-AC_CHECK_TOOLS([AR], [gcc-ar ar], [:])
-AC_CHECK_TOOLS([NM], [gcc-nm nm], [:])
-AC_CHECK_TOOLS([RANLIB], [gcc-ranlib ranlib], [:])
+AC_PROG_CC_C99
+
+AX_COMPILER_VENDOR
+AS_IF([test "x$ax_cv_c_compiler_vendor" = "xgnu"], [
+ AC_CHECK_TOOLS([AR], [gcc-ar ar], [:])
+ AC_CHECK_TOOLS([NM], [gcc-nm nm], [:])
+ AC_CHECK_TOOLS([RANLIB], [gcc-ranlib ranlib], [:])
+])
LT_PREREQ(2.2)
LT_INIT([disable-static])
@@ -87,8 +92,6 @@ AC_PROG_SED
AC_PROG_GREP
AC_PROG_AWK
-AC_PROG_CC_C99
-
AC_PATH_PROG([M4], [m4])
AC_PATH_PROG([XSLTPROC], [xsltproc])
diff --git a/m4/ax_compiler_vendor.m4 b/m4/ax_compiler_vendor.m4
new file mode 100644
index 0000000000..39ca3c0f33
--- /dev/null
+++ b/m4/ax_compiler_vendor.m4
@@ -0,0 +1,87 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_COMPILER_VENDOR
+#
+# DESCRIPTION
+#
+# Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm, sun,
+# hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi, microsoft,
+# watcom, etc. The vendor is returned in the cache variable
+# $ax_cv_c_compiler_vendor for C and $ax_cv_cxx_compiler_vendor for C++.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
+# Copyright (c) 2008 Matteo Frigo
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 15
+
+AC_DEFUN([AX_COMPILER_VENDOR],
+[AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
+ dnl Please add if possible support to ax_compiler_version.m4
+ [# note: don't check for gcc first since some other compilers define __GNUC__
+ vendors="intel: __ICC,__ECC,__INTEL_COMPILER
+ ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__
+ pathscale: __PATHCC__,__PATHSCALE__
+ clang: __clang__
+ cray: _CRAYC
+ fujitsu: __FUJITSU
+ gnu: __GNUC__
+ sun: __SUNPRO_C,__SUNPRO_CC
+ hp: __HP_cc,__HP_aCC
+ dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER
+ borland: __BORLANDC__,__CODEGEARC__,__TURBOC__
+ comeau: __COMO__
+ kai: __KCC
+ lcc: __LCC__
+ sgi: __sgi,sgi
+ microsoft: _MSC_VER
+ metrowerks: __MWERKS__
+ watcom: __WATCOMC__
+ portland: __PGI
+ tcc: __TINYC__
+ unknown: UNKNOWN"
+ for ventest in $vendors; do
+ case $ventest in
+ *:) vendor=$ventest; continue ;;
+ *) vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;;
+ esac
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
+ #if !($vencpp)
+ thisisanerror;
+ #endif
+ ])], [break])
+ done
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1`
+ ])
+])
diff --git a/man/systemd-path.xml b/man/systemd-path.xml
index dfc75ee0ff..4f790d2cda 100644
--- a/man/systemd-path.xml
+++ b/man/systemd-path.xml
@@ -64,9 +64,9 @@
<para>When invoked without arguments a list of known paths and
their current values is shown. When at least one argument is
- passed the path with this is name is queried and its value shown.
+ passed the path with this name is queried and its value shown.
The variables whose name begins with <literal>search-</literal>
- don't refer to individual paths, but instead a to a list of
+ don't refer to individual paths, but instead to a list of
colon-separated search paths, in their order of precedence.</para>
</refsect1>
diff --git a/man/systemd-run.xml b/man/systemd-run.xml
index 80db148702..b220e0dce1 100644
--- a/man/systemd-run.xml
+++ b/man/systemd-run.xml
@@ -113,6 +113,13 @@
<variablelist>
<varlistentry>
+ <term><option>--no-ask-password</option></term>
+
+ <listitem><para>Do not query the user for authentication for
+ privileged operations.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>--scope</option></term>
<listitem>
diff --git a/shell-completion/bash/systemd-run b/shell-completion/bash/systemd-run
index 63c831b8f1..a948677516 100644
--- a/shell-completion/bash/systemd-run
+++ b/shell-completion/bash/systemd-run
@@ -36,7 +36,7 @@ _systemd_run() {
-r --remain-after-exit --send-sighup -H --host -M --machine --service-type
--on-active --on-boot --on-startup --on-unit-active --on-unit-inactive
--on-calendar --timer-property -t --pty -q --quiet --no-block
- --uid --gid --nice --setenv -p --property'
+ --uid --gid --nice --setenv -p --property --no-ask-password'
local mode=--system
local i
diff --git a/src/basic/time-util.c b/src/basic/time-util.c
index afc6a6eb24..531931f6e1 100644
--- a/src/basic/time-util.c
+++ b/src/basic/time-util.c
@@ -1046,7 +1046,7 @@ clockid_t clock_boottime_or_monotonic(void) {
return clock;
}
-int get_timezone(char **timezone) {
+int get_timezone(char **tz) {
_cleanup_free_ char *t = NULL;
const char *e;
char *z;
@@ -1069,6 +1069,6 @@ int get_timezone(char **timezone) {
if (!z)
return -ENOMEM;
- *timezone = z;
+ *tz = z;
return 0;
}
diff --git a/src/core/main.c b/src/core/main.c
index f29a595097..2736b272dc 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -538,9 +538,8 @@ static int config_parse_join_controllers(const char *unit,
void *data,
void *userdata) {
+ const char *whole_rvalue = rvalue;
unsigned n = 0;
- const char *word, *state;
- size_t length;
assert(filename);
assert(lvalue);
@@ -548,16 +547,22 @@ static int config_parse_join_controllers(const char *unit,
free_join_controllers();
- FOREACH_WORD_QUOTED(word, length, rvalue, state) {
- char *s, **l;
-
- s = strndup(word, length);
- if (!s)
- return log_oom();
+ for (;;) {
+ _cleanup_free_ char *word = NULL;
+ char **l;
+ int r;
- l = strv_split(s, ",");
- free(s);
+ r = extract_first_word(&rvalue, &word, WHITESPACE, EXTRACT_QUOTES);
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, r, "Invalid value for %s: %s", lvalue, whole_rvalue);
+ return r;
+ }
+ if (r == 0)
+ break;
+ l = strv_split(word, ",");
+ if (!l)
+ log_oom();
strv_uniq(l);
if (strv_length(l) <= 1) {
@@ -617,7 +622,7 @@ static int config_parse_join_controllers(const char *unit,
arg_join_controllers = t;
}
}
- if (!isempty(state))
+ if (!isempty(rvalue))
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Trailing garbage, ignoring.");
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index 6551e7c94c..aa07846693 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -1121,13 +1121,13 @@ int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id, size_t
return 0;
}
-int sd_dhcp_lease_get_timezone(sd_dhcp_lease *lease, const char **timezone) {
+int sd_dhcp_lease_get_timezone(sd_dhcp_lease *lease, const char **tz) {
assert_return(lease, -EINVAL);
- assert_return(timezone, -EINVAL);
+ assert_return(tz, -EINVAL);
if (!lease->timezone)
return -ENODATA;
- *timezone = lease->timezone;
+ *tz = lease->timezone;
return 0;
}
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
index 7a8b298b51..1f167485e3 100644
--- a/src/libsystemd-network/sd-dhcp-server.c
+++ b/src/libsystemd-network/sd-dhcp-server.c
@@ -1062,16 +1062,16 @@ int sd_dhcp_server_forcerenew(sd_dhcp_server *server) {
return r;
}
-int sd_dhcp_server_set_timezone(sd_dhcp_server *server, const char *timezone) {
+int sd_dhcp_server_set_timezone(sd_dhcp_server *server, const char *tz) {
int r;
assert_return(server, -EINVAL);
- assert_return(timezone_is_valid(timezone), -EINVAL);
+ assert_return(timezone_is_valid(tz), -EINVAL);
- if (streq_ptr(timezone, server->timezone))
+ if (streq_ptr(tz, server->timezone))
return 0;
- r = free_and_strdup(&server->timezone, timezone);
+ r = free_and_strdup(&server->timezone, tz);
if (r < 0)
return r;
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 2281d4b718..786579def0 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -497,7 +497,7 @@ static int link_status_one(
sd_hwdb *hwdb,
const char *name) {
_cleanup_strv_free_ char **dns = NULL, **ntp = NULL, **domains = NULL;
- _cleanup_free_ char *setup_state = NULL, *operational_state = NULL, *timezone = NULL;
+ _cleanup_free_ char *setup_state = NULL, *operational_state = NULL, *tz = NULL;
_cleanup_netlink_message_unref_ sd_netlink_message *req = NULL, *reply = NULL;
_cleanup_device_unref_ sd_device *d = NULL;
char devid[2 + DECIMAL_STR_MAX(int)];
@@ -662,9 +662,9 @@ static int link_status_one(
if (!strv_isempty(carrier_bound_by))
dump_list("Carrier Bound By: ", carrier_bound_by);
- (void) sd_network_link_get_timezone(ifindex, &timezone);
- if (timezone)
- printf(" Time Zone: %s", timezone);
+ (void) sd_network_link_get_timezone(ifindex, &tz);
+ if (tz)
+ printf(" Time Zone: %s", tz);
return 0;
}
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 979f3115f6..1dc9db0fca 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -967,14 +967,14 @@ static int set_timezone_handler(sd_bus_message *m, void *userdata, sd_bus_error
return 1;
}
-int link_set_timezone(Link *link, const char *timezone) {
+int link_set_timezone(Link *link, const char *tz) {
int r;
assert(link);
assert(link->manager);
- assert(timezone);
+ assert(tz);
- log_link_debug(link, "Setting system timezone: '%s'", timezone);
+ log_link_debug(link, "Setting system timezone: '%s'", tz);
if (!link->manager->bus) {
log_link_info(link, "Not connected to system bus, ignoring timezone.");
@@ -991,7 +991,7 @@ int link_set_timezone(Link *link, const char *timezone) {
set_timezone_handler,
link,
"sb",
- timezone,
+ tz,
false);
if (r < 0)
return log_link_error_errno(link, r, "Could not set timezone: %m");
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 2a77242013..ee14401982 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -786,7 +786,7 @@ int config_parse_timezone(
void *data,
void *userdata) {
- char **timezone = data, *tz = NULL;
+ char **datap = data, *tz = NULL;
int r;
assert(filename);
@@ -803,8 +803,8 @@ int config_parse_timezone(
return 0;
}
- free(*timezone);
- *timezone = tz;
+ free(*datap);
+ *datap = tz;
return 0;
}
diff --git a/src/run/run.c b/src/run/run.c
index 3dd97022de..a69560208c 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -36,7 +36,9 @@
#include "ptyfwd.h"
#include "formats-util.h"
#include "signal-util.h"
+#include "spawn-polkit-agent.h"
+static bool arg_ask_password = true;
static bool arg_scope = false;
static bool arg_remain_after_exit = false;
static bool arg_no_block = false;
@@ -64,6 +66,18 @@ static char *arg_on_calendar = NULL;
static char **arg_timer_property = NULL;
static bool arg_quiet = false;
+static void polkit_agent_open_if_enabled(void) {
+
+ /* Open the polkit agent as a child process if necessary */
+ if (!arg_ask_password)
+ return;
+
+ if (arg_transport != BUS_TRANSPORT_LOCAL)
+ return;
+
+ polkit_agent_open();
+}
+
static void help(void) {
printf("%s [OPTIONS...] {COMMAND} [ARGS...]\n\n"
"Run the specified command in a transient scope or service or timer\n"
@@ -71,6 +85,7 @@ static void help(void) {
"specified with --unit option then command can be omitted.\n\n"
" -h --help Show this help\n"
" --version Show package version\n"
+ " --no-ask-password Do not prompt for password\n"
" --user Run as user unit\n"
" -H --host=[USER@]HOST Operate on remote host\n"
" -M --machine=CONTAINER Operate on local container\n"
@@ -108,6 +123,7 @@ static int parse_argv(int argc, char *argv[]) {
enum {
ARG_VERSION = 0x100,
+ ARG_NO_ASK_PASSWORD,
ARG_USER,
ARG_SYSTEM,
ARG_SCOPE,
@@ -160,6 +176,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "on-calendar", required_argument, NULL, ARG_ON_CALENDAR },
{ "timer-property", required_argument, NULL, ARG_TIMER_PROPERTY },
{ "no-block", no_argument, NULL, ARG_NO_BLOCK },
+ { "no-ask-password", no_argument, NULL, ARG_NO_ASK_PASSWORD },
{},
};
@@ -177,6 +194,10 @@ static int parse_argv(int argc, char *argv[]) {
help();
return 0;
+ case ARG_NO_ASK_PASSWORD:
+ arg_ask_password = false;
+ break;
+
case ARG_VERSION:
puts(PACKAGE_STRING);
puts(SYSTEMD_FEATURES);
@@ -745,6 +766,10 @@ static int start_transient_service(
if (r < 0)
return bus_log_create_error(r);
+ r = sd_bus_message_set_allow_interactive_authorization(m, arg_ask_password);
+ if (r < 0)
+ return bus_log_create_error(r);
+
/* Name and mode */
r = sd_bus_message_append(m, "ss", service, "fail");
if (r < 0)
@@ -768,6 +793,8 @@ static int start_transient_service(
if (r < 0)
return bus_log_create_error(r);
+ polkit_agent_open_if_enabled();
+
r = sd_bus_call(bus, m, 0, &error, &reply);
if (r < 0) {
log_error("Failed to start transient service unit: %s", bus_error_message(&error, -r));
@@ -860,6 +887,10 @@ static int start_transient_scope(
if (r < 0)
return bus_log_create_error(r);
+ r = sd_bus_message_set_allow_interactive_authorization(m, arg_ask_password);
+ if (r < 0)
+ return bus_log_create_error(r);
+
/* Name and Mode */
r = sd_bus_message_append(m, "ss", scope, "fail");
if (r < 0)
@@ -883,6 +914,8 @@ static int start_transient_scope(
if (r < 0)
return bus_log_create_error(r);
+ polkit_agent_open_if_enabled();
+
r = sd_bus_call(bus, m, 0, &error, &reply);
if (r < 0) {
log_error("Failed to start transient scope unit: %s", bus_error_message(&error, -r));
@@ -1025,6 +1058,10 @@ static int start_transient_timer(
if (r < 0)
return bus_log_create_error(r);
+ r = sd_bus_message_set_allow_interactive_authorization(m, arg_ask_password);
+ if (r < 0)
+ return bus_log_create_error(r);
+
/* Name and Mode */
r = sd_bus_message_append(m, "ss", timer, "fail");
if (r < 0)
@@ -1077,6 +1114,8 @@ static int start_transient_timer(
if (r < 0)
return bus_log_create_error(r);
+ polkit_agent_open_if_enabled();
+
r = sd_bus_call(bus, m, 0, &error, &reply);
if (r < 0) {
log_error("Failed to start transient timer unit: %s", bus_error_message(&error, -r));