mirror of
https://github.com/systemd/systemd.git
synced 2025-03-19 22:50:17 +03:00
commit
64cd0029fd
@ -614,8 +614,7 @@ static int parse_timestamp_impl(const char *t, usec_t *usec, bool with_tz) {
|
||||
int r, weekday = -1, dst = -1;
|
||||
size_t i;
|
||||
|
||||
/*
|
||||
* Allowed syntaxes:
|
||||
/* Allowed syntaxes:
|
||||
*
|
||||
* 2012-09-22 16:34:22
|
||||
* 2012-09-22 16:34 (seconds will be set to 0)
|
||||
@ -629,7 +628,6 @@ static int parse_timestamp_impl(const char *t, usec_t *usec, bool with_tz) {
|
||||
* +5min
|
||||
* -5days
|
||||
* @2147483647 (seconds since epoch)
|
||||
*
|
||||
*/
|
||||
|
||||
assert(t);
|
||||
@ -688,10 +686,10 @@ static int parse_timestamp_impl(const char *t, usec_t *usec, bool with_tz) {
|
||||
tzset();
|
||||
|
||||
/* See if the timestamp is suffixed by either the DST or non-DST local timezone. Note that we only
|
||||
* support the local timezones here, nothing else. Not because we wouldn't want to, but simply because
|
||||
* there are no nice APIs available to cover this. By accepting the local time zone strings, we make
|
||||
* sure that all timestamps written by format_timestamp() can be parsed correctly, even though we don't
|
||||
* support arbitrary timezone specifications. */
|
||||
* support the local timezones here, nothing else. Not because we wouldn't want to, but simply because
|
||||
* there are no nice APIs available to cover this. By accepting the local time zone strings, we make
|
||||
* sure that all timestamps written by format_timestamp() can be parsed correctly, even though we don't
|
||||
* support arbitrary timezone specifications. */
|
||||
|
||||
for (j = 0; j <= 1; j++) {
|
||||
|
||||
@ -903,10 +901,10 @@ int parse_timestamp(const char *t, usec_t *usec) {
|
||||
tzset();
|
||||
|
||||
/* If there is a timezone that matches the tzname fields, leave the parsing to the implementation.
|
||||
* Otherwise just cut it off */
|
||||
* Otherwise just cut it off. */
|
||||
with_tz = !STR_IN_SET(tz, tzname[0], tzname[1]);
|
||||
|
||||
/*cut off the timezone if we dont need it*/
|
||||
/* Cut off the timezone if we dont need it. */
|
||||
if (with_tz)
|
||||
t = strndupa(t, last_space - t);
|
||||
|
||||
|
@ -2023,9 +2023,7 @@ int bus_exec_context_set_transient_property(
|
||||
if (!e)
|
||||
return -ENOMEM;
|
||||
|
||||
strv_free(c->environment);
|
||||
c->environment = e;
|
||||
|
||||
strv_free_and_replace(c->environment, e);
|
||||
unit_write_settingf(u, flags, name, "Environment=%s", joined);
|
||||
}
|
||||
}
|
||||
@ -2059,9 +2057,7 @@ int bus_exec_context_set_transient_property(
|
||||
if (!e)
|
||||
return -ENOMEM;
|
||||
|
||||
strv_free(c->unset_environment);
|
||||
c->unset_environment = e;
|
||||
|
||||
strv_free_and_replace(c->unset_environment, e);
|
||||
unit_write_settingf(u, flags, name, "UnsetEnvironment=%s", joined);
|
||||
}
|
||||
}
|
||||
|
@ -1287,10 +1287,7 @@ static int setup_pam(
|
||||
if (!barrier_place_and_sync(&barrier))
|
||||
log_error("PAM initialization failed");
|
||||
|
||||
strv_free(*env);
|
||||
*env = e;
|
||||
|
||||
return 0;
|
||||
return strv_free_and_replace(*env, e);
|
||||
|
||||
fail:
|
||||
if (pam_code != PAM_SUCCESS) {
|
||||
@ -3379,8 +3376,7 @@ static int exec_child(
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
strv_free(accum_env);
|
||||
accum_env = ee;
|
||||
strv_free_and_replace(accum_env, ee);
|
||||
}
|
||||
|
||||
final_argv = replace_env_argv(argv, accum_env);
|
||||
@ -4492,10 +4488,7 @@ int exec_command_set(ExecCommand *c, const char *path, ...) {
|
||||
free(c->path);
|
||||
c->path = p;
|
||||
|
||||
strv_free(c->argv);
|
||||
c->argv = l;
|
||||
|
||||
return 0;
|
||||
return strv_free_and_replace(c->argv, l);
|
||||
}
|
||||
|
||||
int exec_command_append(ExecCommand *c, const char *path, ...) {
|
||||
|
@ -97,8 +97,7 @@ int locale_setup(char ***environment) {
|
||||
goto finish;
|
||||
}
|
||||
|
||||
strv_free(*environment);
|
||||
*environment = e;
|
||||
strv_free_and_replace(*environment, e);
|
||||
}
|
||||
|
||||
r = 0;
|
||||
|
@ -338,8 +338,7 @@ static int context_write_data_machine_info(Context *c) {
|
||||
if (!u)
|
||||
return -ENOMEM;
|
||||
|
||||
strv_free(l);
|
||||
l = u;
|
||||
strv_free_and_replace(l, u);
|
||||
}
|
||||
|
||||
if (strv_isempty(l)) {
|
||||
|
@ -248,8 +248,7 @@ int dhcp6_lease_set_domains(sd_dhcp6_lease *lease, uint8_t *optval,
|
||||
if (r < 0)
|
||||
return 0;
|
||||
|
||||
strv_free(lease->domains);
|
||||
lease->domains = domains;
|
||||
strv_free_and_replace(lease->domains, domains);
|
||||
lease->domains_count = r;
|
||||
|
||||
return r;
|
||||
@ -308,8 +307,7 @@ int dhcp6_lease_set_ntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen) {
|
||||
if (r < 0)
|
||||
return 0;
|
||||
|
||||
lease->ntp_fqdn = strv_free(lease->ntp_fqdn);
|
||||
lease->ntp_fqdn = servers;
|
||||
strv_free_and_replace(lease->ntp_fqdn, servers);
|
||||
lease->ntp_fqdn_count = r;
|
||||
|
||||
break;
|
||||
|
@ -310,10 +310,7 @@ _public_ int sd_bus_set_exec(sd_bus *bus, const char *path, char *const argv[])
|
||||
return -ENOMEM;
|
||||
|
||||
free_and_replace(bus->exec_path, p);
|
||||
|
||||
strv_free(bus->exec_argv);
|
||||
bus->exec_argv = a;
|
||||
|
||||
strv_free_and_replace(bus->exec_argv, a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -250,8 +250,7 @@ int locale_write_data(Context *c, char ***settings) {
|
||||
if (!u)
|
||||
return -ENOMEM;
|
||||
|
||||
strv_free(l);
|
||||
l = u;
|
||||
strv_free_and_replace(l, u);
|
||||
}
|
||||
|
||||
if (strv_isempty(l)) {
|
||||
@ -291,8 +290,7 @@ int vconsole_write_data(Context *c) {
|
||||
if (!u)
|
||||
return -ENOMEM;
|
||||
|
||||
strv_free(l);
|
||||
l = u;
|
||||
strv_free_and_replace(l, u);
|
||||
}
|
||||
|
||||
if (isempty(c->vc_keymap_toggle))
|
||||
@ -309,8 +307,7 @@ int vconsole_write_data(Context *c) {
|
||||
if (!u)
|
||||
return -ENOMEM;
|
||||
|
||||
strv_free(l);
|
||||
l = u;
|
||||
strv_free_and_replace(l, u);
|
||||
}
|
||||
|
||||
if (strv_isempty(l)) {
|
||||
|
@ -818,9 +818,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
if (!n)
|
||||
return log_oom();
|
||||
|
||||
strv_free(arg_setenv);
|
||||
arg_setenv = n;
|
||||
|
||||
strv_free_and_replace(arg_setenv, n);
|
||||
arg_settings_mask |= SETTING_ENVIRONMENT;
|
||||
break;
|
||||
}
|
||||
@ -3120,9 +3118,7 @@ static int load_settings(void) {
|
||||
if ((arg_settings_mask & SETTING_START_MODE) == 0 &&
|
||||
settings->start_mode >= 0) {
|
||||
arg_start_mode = settings->start_mode;
|
||||
|
||||
strv_free(arg_parameters);
|
||||
arg_parameters = TAKE_PTR(settings->parameters);
|
||||
strv_free_and_replace(arg_parameters, settings->parameters);
|
||||
}
|
||||
|
||||
if ((arg_settings_mask & SETTING_PIVOT_ROOT) == 0 &&
|
||||
@ -3136,10 +3132,8 @@ static int load_settings(void) {
|
||||
free_and_replace(arg_chdir, settings->working_directory);
|
||||
|
||||
if ((arg_settings_mask & SETTING_ENVIRONMENT) == 0 &&
|
||||
settings->environment) {
|
||||
strv_free(arg_setenv);
|
||||
arg_setenv = TAKE_PTR(settings->environment);
|
||||
}
|
||||
settings->environment)
|
||||
strv_free_and_replace(arg_setenv, settings->environment);
|
||||
|
||||
if ((arg_settings_mask & SETTING_USER) == 0 &&
|
||||
settings->user)
|
||||
@ -3215,17 +3209,10 @@ static int load_settings(void) {
|
||||
arg_network_veth = settings_network_veth(settings);
|
||||
arg_private_network = settings_private_network(settings);
|
||||
|
||||
strv_free(arg_network_interfaces);
|
||||
arg_network_interfaces = TAKE_PTR(settings->network_interfaces);
|
||||
|
||||
strv_free(arg_network_macvlan);
|
||||
arg_network_macvlan = TAKE_PTR(settings->network_macvlan);
|
||||
|
||||
strv_free(arg_network_ipvlan);
|
||||
arg_network_ipvlan = TAKE_PTR(settings->network_ipvlan);
|
||||
|
||||
strv_free(arg_network_veth_extra);
|
||||
arg_network_veth_extra = TAKE_PTR(settings->network_veth_extra);
|
||||
strv_free_and_replace(arg_network_interfaces, settings->network_interfaces);
|
||||
strv_free_and_replace(arg_network_macvlan, settings->network_macvlan);
|
||||
strv_free_and_replace(arg_network_ipvlan, settings->network_ipvlan);
|
||||
strv_free_and_replace(arg_network_veth_extra, settings->network_veth_extra);
|
||||
|
||||
free_and_replace(arg_network_bridge, settings->network_bridge);
|
||||
free_and_replace(arg_network_zone, settings->network_zone);
|
||||
@ -3264,11 +3251,8 @@ static int load_settings(void) {
|
||||
if (!arg_settings_trusted && !strv_isempty(arg_syscall_whitelist))
|
||||
log_warning("Ignoring SystemCallFilter= settings, file %s is not trusted.", p);
|
||||
else {
|
||||
strv_free(arg_syscall_whitelist);
|
||||
strv_free(arg_syscall_blacklist);
|
||||
|
||||
arg_syscall_whitelist = TAKE_PTR(settings->syscall_whitelist);
|
||||
arg_syscall_blacklist = TAKE_PTR(settings->syscall_blacklist);
|
||||
strv_free_and_replace(arg_syscall_whitelist, settings->syscall_whitelist);
|
||||
strv_free_and_replace(arg_syscall_blacklist, settings->syscall_blacklist);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1078,9 +1078,7 @@ static int map_basic(sd_bus *bus, const char *member, sd_bus_message *m, unsigne
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
strv_free(*p);
|
||||
*p = TAKE_PTR(l);
|
||||
return 0;
|
||||
return strv_free_and_replace(*p, l);
|
||||
}
|
||||
|
||||
case SD_BUS_TYPE_BOOLEAN: {
|
||||
|
@ -532,10 +532,8 @@ static int property_get_ntp(
|
||||
|
||||
static int method_set_timezone(sd_bus_message *m, void *userdata, sd_bus_error *error) {
|
||||
Context *c = userdata;
|
||||
int interactive, r;
|
||||
const char *z;
|
||||
int interactive;
|
||||
char *t;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
assert(c);
|
||||
@ -547,7 +545,10 @@ static int method_set_timezone(sd_bus_message *m, void *userdata, sd_bus_error *
|
||||
if (!timezone_is_valid(z))
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid time zone '%s'", z);
|
||||
|
||||
if (streq_ptr(z, c->zone))
|
||||
r = free_and_strdup(&c->zone, z);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
return sd_bus_reply_method_return(m, NULL);
|
||||
|
||||
r = bus_verify_polkit_async(
|
||||
@ -564,13 +565,6 @@ static int method_set_timezone(sd_bus_message *m, void *userdata, sd_bus_error *
|
||||
if (r == 0)
|
||||
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
|
||||
|
||||
t = strdup(z);
|
||||
if (!t)
|
||||
return -ENOMEM;
|
||||
|
||||
free(c->zone);
|
||||
c->zone = t;
|
||||
|
||||
/* 1. Write new configuration file */
|
||||
r = context_write_data_timezone(c);
|
||||
if (r < 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user