mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-10-27 01:55:32 +03:00
tree-wide: assorted coccinelle fixes
This commit is contained in:
parent
44e66de0f2
commit
d7a0f1f4f9
@ -2185,10 +2185,10 @@ int analyze_security(sd_bus *bus, char **units, AnalyzeSecurityFlags flags) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to mangle unit name '%s': %m", *i);
|
||||
|
||||
if (!endswith(mangled, ".service")) {
|
||||
log_error("Unit %s is not a service unit, refusing.", *i);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!endswith(mangled, ".service"))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Unit %s is not a service unit, refusing.",
|
||||
*i);
|
||||
|
||||
if (unit_name_is_valid(mangled, UNIT_NAME_TEMPLATE)) {
|
||||
r = unit_name_replace_instance(mangled, "test-instance", &instance);
|
||||
|
@ -1248,8 +1248,7 @@ static int expand_patterns(sd_bus *bus, char **patterns, char ***ret) {
|
||||
}
|
||||
}
|
||||
|
||||
*ret = expanded_patterns;
|
||||
expanded_patterns = NULL; /* do not free */
|
||||
*ret = TAKE_PTR(expanded_patterns); /* do not free */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -160,8 +160,7 @@ int khash_new_with_key(khash **ret, const char *algorithm, const void *key, size
|
||||
/* Temporary fix for rc kernel bug: https://bugzilla.redhat.com/show_bug.cgi?id=1395896 */
|
||||
(void) send(h->fd, NULL, 0, 0);
|
||||
|
||||
*ret = h;
|
||||
h = NULL;
|
||||
*ret = TAKE_PTR(h);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -129,8 +129,5 @@ int socket_address_listen(
|
||||
if (p)
|
||||
(void) touch(p);
|
||||
|
||||
r = fd;
|
||||
fd = -1;
|
||||
|
||||
return r;
|
||||
return TAKE_FD(fd);
|
||||
}
|
||||
|
@ -1130,14 +1130,13 @@ static int introspect(int argc, char **argv, void *userdata) {
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
|
||||
if (arg_legend) {
|
||||
if (arg_legend)
|
||||
printf("%-*s %-*s %-*s %-*s %s\n",
|
||||
(int) name_width, "NAME",
|
||||
(int) type_width, "TYPE",
|
||||
(int) signature_width, "SIGNATURE",
|
||||
(int) result_width, "RESULT/VALUE",
|
||||
"FLAGS");
|
||||
}
|
||||
|
||||
for (j = 0; j < k; j++) {
|
||||
_cleanup_free_ char *ellipsized = NULL;
|
||||
|
@ -1500,9 +1500,9 @@ int bus_cgroup_set_property(
|
||||
LIST_PREPEND(device_allow, c->device_allow, a);
|
||||
}
|
||||
|
||||
a->r = !!strchr(rwm, 'r');
|
||||
a->w = !!strchr(rwm, 'w');
|
||||
a->m = !!strchr(rwm, 'm');
|
||||
a->r = strchr(rwm, 'r');
|
||||
a->w = strchr(rwm, 'w');
|
||||
a->m = strchr(rwm, 'm');
|
||||
}
|
||||
|
||||
n++;
|
||||
|
@ -1064,13 +1064,11 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
assert_not_reached("Unhandled option code.");
|
||||
}
|
||||
|
||||
if (optind < argc && getpid_cached() != 1) {
|
||||
if (optind < argc && getpid_cached() != 1)
|
||||
/* Hmm, when we aren't run as init system
|
||||
* let's complain about excess arguments */
|
||||
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Excess arguments.");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -96,10 +96,9 @@ int mac_selinux_setup(bool *loaded_policy) {
|
||||
log_open();
|
||||
|
||||
if (enforce > 0) {
|
||||
if (!initialized) {
|
||||
log_emergency("Failed to load SELinux policy.");
|
||||
return -EIO;
|
||||
}
|
||||
if (!initialized)
|
||||
return log_emergency_errno(SYNTHETIC_ERRNO(EIO),
|
||||
"Failed to load SELinux policy.");
|
||||
|
||||
log_warning("Failed to load new SELinux policy. Continuing with old policy.");
|
||||
} else
|
||||
|
@ -4201,7 +4201,7 @@ static void service_bus_name_owner_change(Unit *u, const char *new_owner) {
|
||||
else
|
||||
log_unit_debug(u, "D-Bus name %s now not owned by anyone.", s->bus_name);
|
||||
|
||||
s->bus_name_good = !!new_owner;
|
||||
s->bus_name_good = new_owner;
|
||||
|
||||
/* Track the current owner, so we can reconstruct changes after a daemon reload */
|
||||
r = free_and_strdup(&s->bus_name_owner, new_owner);
|
||||
|
@ -353,7 +353,7 @@ static int save_external_coredump(
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to parse resource limit '%s': %m",
|
||||
context->meta[META_ARGV_RLIMIT]);
|
||||
if (rlimit < page_size()) {
|
||||
if (rlimit < page_size())
|
||||
/* Is coredumping disabled? Then don't bother saving/processing the
|
||||
* coredump. Anything below PAGE_SIZE cannot give a readable coredump
|
||||
* (the kernel uses ELF_EXEC_PAGESIZE which is not easily accessible, but
|
||||
@ -361,7 +361,6 @@ static int save_external_coredump(
|
||||
return log_info_errno(SYNTHETIC_ERRNO(EBADSLT),
|
||||
"Resource limits disable core dumping for process %s (%s).",
|
||||
context->meta[META_ARGV_PID], context->meta[META_COMM]);
|
||||
}
|
||||
|
||||
process_limit = MAX(arg_process_size_max, storage_size_max());
|
||||
if (process_limit == 0)
|
||||
|
@ -888,10 +888,9 @@ static int dump_core(int argc, char **argv, void *userdata) {
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
int r;
|
||||
|
||||
if (arg_field) {
|
||||
log_error("Option --field/-F only makes sense with list");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (arg_field)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Option --field/-F only makes sense with list");
|
||||
|
||||
r = acquire_journal(&j, argv + 1);
|
||||
if (r < 0)
|
||||
@ -943,10 +942,9 @@ static int run_debug(int argc, char **argv, void *userdata) {
|
||||
if (!debugger)
|
||||
return -ENOMEM;
|
||||
|
||||
if (arg_field) {
|
||||
log_error("Option --field/-F only makes sense with list");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (arg_field)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Option --field/-F only makes sense with list");
|
||||
|
||||
r = acquire_journal(&j, argv + 1);
|
||||
if (r < 0)
|
||||
@ -971,15 +969,13 @@ static int run_debug(int argc, char **argv, void *userdata) {
|
||||
if (!exe)
|
||||
return log_oom();
|
||||
|
||||
if (endswith(exe, " (deleted)")) {
|
||||
log_error("Binary already deleted.");
|
||||
return -ENOENT;
|
||||
}
|
||||
if (endswith(exe, " (deleted)"))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENOENT),
|
||||
"Binary already deleted.");
|
||||
|
||||
if (!path_is_absolute(exe)) {
|
||||
log_error("Binary is not an absolute path.");
|
||||
return -ENOENT;
|
||||
}
|
||||
if (!path_is_absolute(exe))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENOENT),
|
||||
"Binary is not an absolute path.");
|
||||
|
||||
r = save_core(j, NULL, &path, &unlink_path);
|
||||
if (r < 0)
|
||||
|
@ -378,14 +378,13 @@ static int create_disk(
|
||||
else
|
||||
fprintf(f, "Requires=%s\n", unit);
|
||||
|
||||
if (umount_unit) {
|
||||
if (umount_unit)
|
||||
fprintf(f,
|
||||
"Wants=%s\n"
|
||||
"Before=%s\n",
|
||||
umount_unit,
|
||||
umount_unit
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!nofail)
|
||||
|
@ -832,10 +832,9 @@ static int run(int argc, char *argv[]) {
|
||||
if (argc <= 1)
|
||||
return help();
|
||||
|
||||
if (argc < 3) {
|
||||
log_error("This program requires at least two arguments.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (argc < 3)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"This program requires at least two arguments.");
|
||||
|
||||
log_setup_service();
|
||||
|
||||
|
@ -258,10 +258,9 @@ static int run(int argc, char *argv[]) {
|
||||
|
||||
log_setup_service();
|
||||
|
||||
if (argc > 2) {
|
||||
log_error("This program expects one or no arguments.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (argc > 2)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"This program expects one or no arguments.");
|
||||
|
||||
umask(0022);
|
||||
|
||||
@ -284,10 +283,10 @@ static int run(int argc, char *argv[]) {
|
||||
if (stat(device, &st) < 0)
|
||||
return log_error_errno(errno, "Failed to stat %s: %m", device);
|
||||
|
||||
if (!S_ISBLK(st.st_mode)) {
|
||||
log_error("%s is not a block device.", device);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!S_ISBLK(st.st_mode))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"%s is not a block device.",
|
||||
device);
|
||||
|
||||
r = sd_device_new_from_devnum(&dev, 'b', st.st_rdev);
|
||||
if (r < 0)
|
||||
|
@ -401,7 +401,8 @@ int identity_add_fido2_parameters(
|
||||
|
||||
return 0;
|
||||
#else
|
||||
return log_error_errno(EOPNOTSUPP, "FIDO2 tokens not supported on this build.");
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"FIDO2 tokens not supported on this build.");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -467,7 +468,8 @@ finish:
|
||||
fido_dev_info_free(&di, allocated);
|
||||
return r;
|
||||
#else
|
||||
return log_error_errno(EOPNOTSUPP, "FIDO2 tokens not supported on this build.");
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"FIDO2 tokens not supported on this build.");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,9 @@ static int acquire_pkcs11_certificate(
|
||||
|
||||
r = pkcs11_find_token(uri, pkcs11_callback, &data);
|
||||
if (r == -EAGAIN) /* pkcs11_find_token() doesn't log about this error, but all others */
|
||||
return log_error_errno(ENXIO, "Specified PKCS#11 token with URI '%s' not found.", uri);
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENXIO),
|
||||
"Specified PKCS#11 token with URI '%s' not found.",
|
||||
uri);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -86,7 +88,8 @@ static int acquire_pkcs11_certificate(
|
||||
|
||||
return 0;
|
||||
#else
|
||||
return log_error_errno(EOPNOTSUPP, "PKCS#11 tokens not supported on this build.");
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"PKCS#11 tokens not supported on this build.");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -415,7 +418,8 @@ int list_pkcs11_tokens(void) {
|
||||
|
||||
return 0;
|
||||
#else
|
||||
return log_error_errno(EOPNOTSUPP, "PKCS#11 tokens not supported on this build.");
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"PKCS#11 tokens not supported on this build.");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -910,7 +910,8 @@ static int user_record_compile_effective_passwords(
|
||||
* the old literal password only (and do not care for the old PKCS#11 token) */
|
||||
|
||||
if (strv_isempty(h->hashed_password))
|
||||
return log_error_errno(EINVAL, "User record has no hashed passwords, refusing.");
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"User record has no hashed passwords, refusing.");
|
||||
|
||||
/* Generates the list of plaintext passwords to propagate to LUKS/fscrypt devices, and checks whether
|
||||
* we have a plaintext password for each hashed one. If we are missing one we'll fail, since we
|
||||
|
@ -194,10 +194,9 @@ static int show_status(int argc, char **argv, void *userdata) {
|
||||
if (arg_pretty || arg_static || arg_transient) {
|
||||
const char *attr;
|
||||
|
||||
if (!!arg_static + !!arg_pretty + !!arg_transient > 1) {
|
||||
log_error("Cannot query more than one name type at a time");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!!arg_static + !!arg_pretty + !!arg_transient > 1)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Cannot query more than one name type at a time");
|
||||
|
||||
attr = arg_pretty ? "PrettyHostname" :
|
||||
arg_static ? "StaticHostname" : "Hostname";
|
||||
|
@ -126,10 +126,10 @@ static int import_fs(int argc, char *argv[], void *userdata) {
|
||||
local = empty_or_dash_to_null(local);
|
||||
|
||||
if (local) {
|
||||
if (!machine_name_is_valid(local)) {
|
||||
log_error("Local image name '%s' is not valid.", local);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!machine_name_is_valid(local))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Local image name '%s' is not valid.",
|
||||
local);
|
||||
|
||||
if (!arg_force) {
|
||||
r = image_find(IMAGE_MACHINE, local, NULL);
|
||||
@ -137,8 +137,9 @@ static int import_fs(int argc, char *argv[], void *userdata) {
|
||||
if (r != -ENOENT)
|
||||
return log_error_errno(r, "Failed to check whether image '%s' exists: %m", local);
|
||||
} else {
|
||||
log_error("Image '%s' already exists.", local);
|
||||
return -EEXIST;
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EEXIST),
|
||||
"Image '%s' already exists.",
|
||||
local);
|
||||
}
|
||||
}
|
||||
} else
|
||||
|
@ -64,10 +64,10 @@ static int import_tar(int argc, char *argv[], void *userdata) {
|
||||
|
||||
local = ll;
|
||||
|
||||
if (!machine_name_is_valid(local)) {
|
||||
log_error("Local image name '%s' is not valid.", local);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!machine_name_is_valid(local))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Local image name '%s' is not valid.",
|
||||
local);
|
||||
|
||||
if (!arg_force) {
|
||||
r = image_find(IMAGE_MACHINE, local, NULL);
|
||||
@ -75,8 +75,9 @@ static int import_tar(int argc, char *argv[], void *userdata) {
|
||||
if (r != -ENOENT)
|
||||
return log_error_errno(r, "Failed to check whether image '%s' exists: %m", local);
|
||||
} else {
|
||||
log_error("Image '%s' already exists.", local);
|
||||
return -EEXIST;
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EEXIST),
|
||||
"Image '%s' already exists.",
|
||||
local);
|
||||
}
|
||||
}
|
||||
} else
|
||||
@ -158,10 +159,10 @@ static int import_raw(int argc, char *argv[], void *userdata) {
|
||||
|
||||
local = ll;
|
||||
|
||||
if (!machine_name_is_valid(local)) {
|
||||
log_error("Local image name '%s' is not valid.", local);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!machine_name_is_valid(local))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Local image name '%s' is not valid.",
|
||||
local);
|
||||
|
||||
if (!arg_force) {
|
||||
r = image_find(IMAGE_MACHINE, local, NULL);
|
||||
@ -169,8 +170,9 @@ static int import_raw(int argc, char *argv[], void *userdata) {
|
||||
if (r != -ENOENT)
|
||||
return log_error_errno(r, "Failed to check whether image '%s' exists: %m", local);
|
||||
} else {
|
||||
log_error("Image '%s' already exists.", local);
|
||||
return -EEXIST;
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EEXIST),
|
||||
"Image '%s' already exists.",
|
||||
local);
|
||||
}
|
||||
}
|
||||
} else
|
||||
|
@ -389,10 +389,9 @@ int pull_verify(PullJob *main_job,
|
||||
|
||||
assert(checksum_job->state == PULL_JOB_DONE);
|
||||
|
||||
if (!checksum_job->payload || checksum_job->payload_size <= 0) {
|
||||
log_error("Checksum is empty, cannot verify.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (!checksum_job->payload || checksum_job->payload_size <= 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Checksum is empty, cannot verify.");
|
||||
|
||||
r = verify_one(checksum_job, main_job);
|
||||
if (r < 0)
|
||||
@ -414,10 +413,9 @@ int pull_verify(PullJob *main_job,
|
||||
|
||||
assert(signature_job->state == PULL_JOB_DONE);
|
||||
|
||||
if (!signature_job->payload || signature_job->payload_size <= 0) {
|
||||
log_error("Signature is empty, cannot verify.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (!signature_job->payload || signature_job->payload_size <= 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Signature is empty, cannot verify.");
|
||||
|
||||
r = pipe2(gpg_pipe, O_CLOEXEC);
|
||||
if (r < 0)
|
||||
|
@ -49,10 +49,9 @@ static int pull_tar(int argc, char *argv[], void *userdata) {
|
||||
int r;
|
||||
|
||||
url = argv[1];
|
||||
if (!http_url_is_valid(url)) {
|
||||
log_error("URL '%s' is not valid.", url);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!http_url_is_valid(url))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"URL '%s' is not valid.", url);
|
||||
|
||||
if (argc >= 3)
|
||||
local = argv[2];
|
||||
@ -73,10 +72,10 @@ static int pull_tar(int argc, char *argv[], void *userdata) {
|
||||
|
||||
local = ll;
|
||||
|
||||
if (!machine_name_is_valid(local)) {
|
||||
log_error("Local image name '%s' is not valid.", local);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!machine_name_is_valid(local))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Local image name '%s' is not valid.",
|
||||
local);
|
||||
|
||||
if (!arg_force) {
|
||||
r = image_find(IMAGE_MACHINE, local, NULL);
|
||||
@ -84,8 +83,9 @@ static int pull_tar(int argc, char *argv[], void *userdata) {
|
||||
if (r != -ENOENT)
|
||||
return log_error_errno(r, "Failed to check whether image '%s' exists: %m", local);
|
||||
} else {
|
||||
log_error("Image '%s' already exists.", local);
|
||||
return -EEXIST;
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EEXIST),
|
||||
"Image '%s' already exists.",
|
||||
local);
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,10 +135,9 @@ static int pull_raw(int argc, char *argv[], void *userdata) {
|
||||
int r;
|
||||
|
||||
url = argv[1];
|
||||
if (!http_url_is_valid(url)) {
|
||||
log_error("URL '%s' is not valid.", url);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!http_url_is_valid(url))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"URL '%s' is not valid.", url);
|
||||
|
||||
if (argc >= 3)
|
||||
local = argv[2];
|
||||
@ -159,10 +158,10 @@ static int pull_raw(int argc, char *argv[], void *userdata) {
|
||||
|
||||
local = ll;
|
||||
|
||||
if (!machine_name_is_valid(local)) {
|
||||
log_error("Local image name '%s' is not valid.", local);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!machine_name_is_valid(local))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Local image name '%s' is not valid.",
|
||||
local);
|
||||
|
||||
if (!arg_force) {
|
||||
r = image_find(IMAGE_MACHINE, local, NULL);
|
||||
@ -170,8 +169,9 @@ static int pull_raw(int argc, char *argv[], void *userdata) {
|
||||
if (r != -ENOENT)
|
||||
return log_error_errno(r, "Failed to check whether image '%s' exists: %m", local);
|
||||
} else {
|
||||
log_error("Image '%s' already exists.", local);
|
||||
return -EEXIST;
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EEXIST),
|
||||
"Image '%s' already exists.",
|
||||
local);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -544,10 +544,10 @@ int compress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
|
||||
assert(fdt >= 0);
|
||||
|
||||
ret = lzma_easy_encoder(&s, LZMA_PRESET_DEFAULT, LZMA_CHECK_CRC64);
|
||||
if (ret != LZMA_OK) {
|
||||
log_error("Failed to initialize XZ encoder: code %u", ret);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (ret != LZMA_OK)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Failed to initialize XZ encoder: code %u",
|
||||
ret);
|
||||
|
||||
for (;;) {
|
||||
if (s.avail_in == 0 && action == LZMA_RUN) {
|
||||
@ -579,10 +579,10 @@ int compress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
|
||||
}
|
||||
|
||||
ret = lzma_code(&s, action);
|
||||
if (!IN_SET(ret, LZMA_OK, LZMA_STREAM_END)) {
|
||||
log_error("Compression failed: code %u", ret);
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (!IN_SET(ret, LZMA_OK, LZMA_STREAM_END))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Compression failed: code %u",
|
||||
ret);
|
||||
|
||||
if (s.avail_out == 0 || ret == LZMA_STREAM_END) {
|
||||
ssize_t n, k;
|
||||
@ -664,10 +664,10 @@ int compress_stream_lz4(int fdf, int fdt, uint64_t max_bytes) {
|
||||
offset += n;
|
||||
total_out += n;
|
||||
|
||||
if (max_bytes != (uint64_t) -1 && total_out > (size_t) max_bytes) {
|
||||
log_debug("Compressed stream longer than %"PRIu64" bytes", max_bytes);
|
||||
return -EFBIG;
|
||||
}
|
||||
if (max_bytes != (uint64_t) -1 && total_out > (size_t) max_bytes)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EFBIG),
|
||||
"Compressed stream longer than %" PRIu64 " bytes",
|
||||
max_bytes);
|
||||
|
||||
if (size - offset < frame_size + 4) {
|
||||
k = loop_write(fdt, buf, offset, false);
|
||||
@ -715,10 +715,10 @@ int decompress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
|
||||
assert(fdt >= 0);
|
||||
|
||||
ret = lzma_stream_decoder(&s, UINT64_MAX, 0);
|
||||
if (ret != LZMA_OK) {
|
||||
log_debug("Failed to initialize XZ decoder: code %u", ret);
|
||||
return -ENOMEM;
|
||||
}
|
||||
if (ret != LZMA_OK)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(ENOMEM),
|
||||
"Failed to initialize XZ decoder: code %u",
|
||||
ret);
|
||||
|
||||
for (;;) {
|
||||
if (s.avail_in == 0 && action == LZMA_RUN) {
|
||||
@ -741,10 +741,10 @@ int decompress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
|
||||
}
|
||||
|
||||
ret = lzma_code(&s, action);
|
||||
if (!IN_SET(ret, LZMA_OK, LZMA_STREAM_END)) {
|
||||
log_debug("Decompression failed: code %u", ret);
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (!IN_SET(ret, LZMA_OK, LZMA_STREAM_END))
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Decompression failed: code %u",
|
||||
ret);
|
||||
|
||||
if (s.avail_out == 0 || ret == LZMA_STREAM_END) {
|
||||
ssize_t n, k;
|
||||
@ -772,8 +772,8 @@ int decompress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
|
||||
}
|
||||
}
|
||||
#else
|
||||
log_debug("Cannot decompress file. Compiled without XZ support.");
|
||||
return -EPROTONOSUPPORT;
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EPROTONOSUPPORT),
|
||||
"Cannot decompress file. Compiled without XZ support.");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -833,8 +833,8 @@ int decompress_stream_lz4(int in, int out, uint64_t max_bytes) {
|
||||
munmap(src, st.st_size);
|
||||
return r;
|
||||
#else
|
||||
log_debug("Cannot decompress file. Compiled without LZ4 support.");
|
||||
return -EPROTONOSUPPORT;
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EPROTONOSUPPORT),
|
||||
"Cannot decompress file. Compiled without LZ4 support.");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1043,8 +1043,8 @@ int decompress_stream_zstd(int fdf, int fdt, uint64_t max_bytes) {
|
||||
(double) (max_bytes - left) / in_bytes * 100);
|
||||
return 0;
|
||||
#else
|
||||
log_debug("Cannot decompress file. Compiled without ZSTD support.");
|
||||
return -EPROTONOSUPPORT;
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EPROTONOSUPPORT),
|
||||
"Cannot decompress file. Compiled without ZSTD support.");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ _printf_(1, 0) static int fill_iovec_sprintf(const char *format, va_list ap, int
|
||||
|
||||
if (i >= n) {
|
||||
n = MAX(i*2, 4);
|
||||
c = realloc(iov, n * sizeof(struct iovec));
|
||||
c = reallocarray(iov, n, sizeof(struct iovec));
|
||||
if (!c) {
|
||||
r = -ENOMEM;
|
||||
goto fail;
|
||||
|
@ -199,10 +199,9 @@ static int add_matches_for_device(sd_journal *j, const char *devpath) {
|
||||
assert(j);
|
||||
assert(devpath);
|
||||
|
||||
if (!path_startswith(devpath, "/dev/")) {
|
||||
log_error("Devpath does not start with /dev/");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!path_startswith(devpath, "/dev/"))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Devpath does not start with /dev/");
|
||||
|
||||
if (stat(devpath, &st) < 0)
|
||||
return log_error_errno(errno, "Couldn't stat file: %m");
|
||||
@ -1055,35 +1054,30 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
if (arg_follow && !arg_no_tail && !arg_since && arg_lines == ARG_LINES_DEFAULT)
|
||||
arg_lines = 10;
|
||||
|
||||
if (!!arg_directory + !!arg_file + !!arg_machine + !!arg_root + !!arg_image > 1) {
|
||||
log_error("Please specify at most one of -D/--directory=, --file=, -M/--machine=, --root=, --image=.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!!arg_directory + !!arg_file + !!arg_machine + !!arg_root + !!arg_image > 1)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Please specify at most one of -D/--directory=, --file=, -M/--machine=, --root=, --image=.");
|
||||
|
||||
if (arg_since_set && arg_until_set && arg_since > arg_until) {
|
||||
log_error("--since= must be before --until=.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (arg_since_set && arg_until_set && arg_since > arg_until)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"--since= must be before --until=.");
|
||||
|
||||
if (!!arg_cursor + !!arg_after_cursor + !!arg_since_set > 1) {
|
||||
log_error("Please specify only one of --since=, --cursor=, and --after-cursor.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!!arg_cursor + !!arg_after_cursor + !!arg_since_set > 1)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Please specify only one of --since=, --cursor=, and --after-cursor.");
|
||||
|
||||
if (arg_follow && arg_reverse) {
|
||||
log_error("Please specify either --reverse= or --follow=, not both.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (arg_follow && arg_reverse)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Please specify either --reverse= or --follow=, not both.");
|
||||
|
||||
if (!IN_SET(arg_action, ACTION_SHOW, ACTION_DUMP_CATALOG, ACTION_LIST_CATALOG) && optind < argc) {
|
||||
log_error("Extraneous arguments starting with '%s'", argv[optind]);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!IN_SET(arg_action, ACTION_SHOW, ACTION_DUMP_CATALOG, ACTION_LIST_CATALOG) && optind < argc)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Extraneous arguments starting with '%s'",
|
||||
argv[optind]);
|
||||
|
||||
if ((arg_boot || arg_action == ACTION_LIST_BOOTS) && arg_merge) {
|
||||
log_error("Using --boot or --list-boots with --merge is not supported.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if ((arg_boot || arg_action == ACTION_LIST_BOOTS) && arg_merge)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Using --boot or --list-boots with --merge is not supported.");
|
||||
|
||||
if (!strv_isempty(arg_system_units) && arg_journal_type == SD_JOURNAL_CURRENT_USER) {
|
||||
/* Specifying --user and --unit= at the same time makes no sense (as the former excludes the user
|
||||
@ -1921,7 +1915,8 @@ static int setup_keys(void) {
|
||||
"Please write down the following %ssecret verification key%s. It should be stored\n"
|
||||
"in a safe location and should not be saved locally on disk.\n"
|
||||
"\n\t%s",
|
||||
hn ?: "", hn ? "/" : "", SD_ID128_FORMAT_VAL(machine),
|
||||
strempty(hn), hn ? "/" : "",
|
||||
SD_ID128_FORMAT_VAL(machine),
|
||||
ansi_highlight(), ansi_normal(),
|
||||
p,
|
||||
format_timespan(tsb, sizeof(tsb), arg_interval, 0),
|
||||
@ -2476,7 +2471,7 @@ int main(int argc, char *argv[]) {
|
||||
after_cursor = true;
|
||||
}
|
||||
} else
|
||||
after_cursor = !!arg_after_cursor;
|
||||
after_cursor = arg_after_cursor;
|
||||
|
||||
if (cursor) {
|
||||
r = sd_journal_seek_cursor(j, cursor);
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "chattr-util.h"
|
||||
#include "io-util.h"
|
||||
#include "journal-file.h"
|
||||
#include "journal-internal.h"
|
||||
#include "log.h"
|
||||
@ -92,13 +93,11 @@ static void run_test(void) {
|
||||
previous_ts = ts;
|
||||
|
||||
assert_se(asprintf(&p, "NUMBER=%u", i) >= 0);
|
||||
iovec[0].iov_base = p;
|
||||
iovec[0].iov_len = strlen(p);
|
||||
iovec[0] = IOVEC_MAKE(p, strlen(p));
|
||||
|
||||
assert_se(asprintf(&q, "MAGIC=%s", i % 5 == 0 ? "quux" : "waldo") >= 0);
|
||||
|
||||
iovec[1].iov_base = q;
|
||||
iovec[1].iov_len = strlen(q);
|
||||
iovec[1] = IOVEC_MAKE(q, strlen(q));
|
||||
|
||||
if (i % 10 == 0)
|
||||
assert_se(journal_file_append_entry(three, &ts, NULL, iovec, 2, NULL, NULL, NULL) == 0);
|
||||
|
@ -1234,8 +1234,7 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
|
||||
return -ENOMEM;
|
||||
|
||||
if (!strv_isempty(a)) {
|
||||
lease->search_domains = a;
|
||||
a = NULL;
|
||||
lease->search_domains = TAKE_PTR(a);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,10 +23,10 @@ static void test_pool(struct in_addr *address, unsigned size, int ret) {
|
||||
static int test_basic(sd_event *event) {
|
||||
_cleanup_(sd_dhcp_server_unrefp) sd_dhcp_server *server = NULL;
|
||||
struct in_addr address_lo = {
|
||||
.s_addr = htonl(INADDR_LOOPBACK),
|
||||
.s_addr = htobe32(INADDR_LOOPBACK),
|
||||
};
|
||||
struct in_addr address_any = {
|
||||
.s_addr = htonl(INADDR_ANY),
|
||||
.s_addr = htobe32(INADDR_ANY),
|
||||
};
|
||||
int r;
|
||||
|
||||
@ -105,7 +105,7 @@ static void test_message_handler(void) {
|
||||
.end = SD_DHCP_OPTION_END,
|
||||
};
|
||||
struct in_addr address_lo = {
|
||||
.s_addr = htonl(INADDR_LOOPBACK),
|
||||
.s_addr = htobe32(INADDR_LOOPBACK),
|
||||
};
|
||||
|
||||
assert_se(sd_dhcp_server_new(&server, 1) >= 0);
|
||||
|
@ -285,8 +285,7 @@ static void* client1(void *p) {
|
||||
assert_se(streq(hello, "hello"));
|
||||
|
||||
if (pipe2(pp, O_CLOEXEC|O_NONBLOCK) < 0) {
|
||||
log_error_errno(errno, "Failed to allocate pipe: %m");
|
||||
r = -errno;
|
||||
r = log_error_errno(errno, "Failed to allocate pipe: %m");
|
||||
goto finish;
|
||||
}
|
||||
|
||||
|
@ -548,10 +548,9 @@ static void test_pidfd(void) {
|
||||
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, -1) >= 0);
|
||||
|
||||
pid = fork();
|
||||
if (pid == 0) {
|
||||
if (pid == 0)
|
||||
/* child */
|
||||
_exit(66);
|
||||
}
|
||||
|
||||
assert_se(pid > 1);
|
||||
|
||||
|
@ -343,10 +343,10 @@ _public_ int sd_hwdb_new(sd_hwdb **ret) {
|
||||
return log_debug_errno(errno, "Failed to map %s: %m", hwdb_bin_path);
|
||||
|
||||
if (memcmp(hwdb->map, sig, sizeof(hwdb->head->signature)) != 0 ||
|
||||
(size_t) hwdb->st.st_size != le64toh(hwdb->head->file_size)) {
|
||||
log_debug("Failed to recognize the format of %s", hwdb_bin_path);
|
||||
return -EINVAL;
|
||||
}
|
||||
(size_t) hwdb->st.st_size != le64toh(hwdb->head->file_size))
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Failed to recognize the format of %s",
|
||||
hwdb_bin_path);
|
||||
|
||||
log_debug("=== trie on-disk ===");
|
||||
log_debug("tool version: %"PRIu64, le64toh(hwdb->head->tool_version));
|
||||
|
@ -139,7 +139,7 @@ static void test_route(sd_netlink *rtnl) {
|
||||
return;
|
||||
}
|
||||
|
||||
addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
addr.s_addr = htobe32(INADDR_LOOPBACK);
|
||||
|
||||
r = sd_netlink_message_append_in_addr(req, RTA_GATEWAY, &addr);
|
||||
if (r < 0) {
|
||||
|
@ -63,7 +63,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
struct sockaddr_in sa = {
|
||||
.sin_family = AF_INET,
|
||||
.sin_port = htons(80)
|
||||
.sin_port = htobe16(80)
|
||||
};
|
||||
|
||||
assert_se(sd_resolve_default(&resolve) >= 0);
|
||||
|
@ -545,8 +545,7 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li
|
||||
printf("\t Unit: %s\n", i.scope);
|
||||
show_unit_cgroup(bus, "org.freedesktop.systemd1.Scope", i.scope, i.leader);
|
||||
|
||||
if (arg_transport == BUS_TRANSPORT_LOCAL) {
|
||||
|
||||
if (arg_transport == BUS_TRANSPORT_LOCAL)
|
||||
show_journal_by_unit(
|
||||
stdout,
|
||||
i.scope,
|
||||
@ -560,7 +559,6 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li
|
||||
SD_JOURNAL_LOCAL_ONLY,
|
||||
true,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "process-util.h"
|
||||
#include "stdio-util.h"
|
||||
#include "strv.h"
|
||||
#include "terminal-util.h"
|
||||
#include "udev-util.h"
|
||||
@ -533,7 +534,7 @@ int manager_spawn_autovt(Manager *m, unsigned vtnr) {
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
snprintf(name, sizeof(name), "autovt@tty%u.service", vtnr);
|
||||
xsprintf(name, "autovt@tty%u.service", vtnr);
|
||||
r = sd_bus_call_method(
|
||||
m->bus,
|
||||
"org.freedesktop.systemd1",
|
||||
|
@ -1312,15 +1312,13 @@ static int login_machine(int argc, char *argv[], void *userdata) {
|
||||
|
||||
assert(bus);
|
||||
|
||||
if (!strv_isempty(arg_setenv) || arg_uid) {
|
||||
log_error("--setenv= and --uid= are not supported for 'login'. Use 'shell' instead.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!strv_isempty(arg_setenv) || arg_uid)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"--setenv= and --uid= are not supported for 'login'. Use 'shell' instead.");
|
||||
|
||||
if (!IN_SET(arg_transport, BUS_TRANSPORT_LOCAL, BUS_TRANSPORT_MACHINE)) {
|
||||
log_error("Login only supported on local machines.");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
if (!IN_SET(arg_transport, BUS_TRANSPORT_LOCAL, BUS_TRANSPORT_MACHINE))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"Login only supported on local machines.");
|
||||
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
@ -1369,10 +1367,9 @@ static int shell_machine(int argc, char *argv[], void *userdata) {
|
||||
|
||||
assert(bus);
|
||||
|
||||
if (!IN_SET(arg_transport, BUS_TRANSPORT_LOCAL, BUS_TRANSPORT_MACHINE)) {
|
||||
log_error("Shell only supported on local machines.");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
if (!IN_SET(arg_transport, BUS_TRANSPORT_LOCAL, BUS_TRANSPORT_MACHINE))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"Shell only supported on local machines.");
|
||||
|
||||
/* Pass $TERM to shell session, if not explicitly specified. */
|
||||
if (!strv_find_prefix(arg_setenv, "TERM=")) {
|
||||
@ -1525,10 +1522,10 @@ static int read_only_image(int argc, char *argv[], void *userdata) {
|
||||
|
||||
if (argc > 2) {
|
||||
b = parse_boolean(argv[2]);
|
||||
if (b < 0) {
|
||||
log_error("Failed to parse boolean argument: %s", argv[2]);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (b < 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Failed to parse boolean argument: %s",
|
||||
argv[2]);
|
||||
}
|
||||
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
@ -1602,10 +1599,10 @@ static int start_machine(int argc, char *argv[], void *userdata) {
|
||||
r = image_exists(bus, argv[i]);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0) {
|
||||
log_error("Machine image '%s' does not exist.", argv[i]);
|
||||
return -ENXIO;
|
||||
}
|
||||
if (r == 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENXIO),
|
||||
"Machine image '%s' does not exist.",
|
||||
argv[i]);
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
@ -1674,10 +1671,10 @@ static int enable_machine(int argc, char *argv[], void *userdata) {
|
||||
r = image_exists(bus, argv[i]);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0) {
|
||||
log_error("Machine image '%s' does not exist.", argv[i]);
|
||||
return -ENXIO;
|
||||
}
|
||||
if (r == 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENXIO),
|
||||
"Machine image '%s' does not exist.",
|
||||
argv[i]);
|
||||
|
||||
r = sd_bus_message_append(m, "s", unit);
|
||||
if (r < 0)
|
||||
@ -1874,10 +1871,9 @@ static int import_tar(int argc, char *argv[], void *userdata) {
|
||||
|
||||
local = fn;
|
||||
}
|
||||
if (!local) {
|
||||
log_error("Need either path or local name.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!local)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Need either path or local name.");
|
||||
|
||||
r = tar_strip_suffixes(local, &ll);
|
||||
if (r < 0)
|
||||
@ -1885,10 +1881,10 @@ static int import_tar(int argc, char *argv[], void *userdata) {
|
||||
|
||||
local = ll;
|
||||
|
||||
if (!machine_name_is_valid(local)) {
|
||||
log_error("Local name %s is not a suitable machine name.", local);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!machine_name_is_valid(local))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Local name %s is not a suitable machine name.",
|
||||
local);
|
||||
|
||||
if (path) {
|
||||
fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY);
|
||||
@ -1935,10 +1931,9 @@ static int import_raw(int argc, char *argv[], void *userdata) {
|
||||
|
||||
local = fn;
|
||||
}
|
||||
if (!local) {
|
||||
log_error("Need either path or local name.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!local)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Need either path or local name.");
|
||||
|
||||
r = raw_strip_suffixes(local, &ll);
|
||||
if (r < 0)
|
||||
@ -1946,10 +1941,10 @@ static int import_raw(int argc, char *argv[], void *userdata) {
|
||||
|
||||
local = ll;
|
||||
|
||||
if (!machine_name_is_valid(local)) {
|
||||
log_error("Local name %s is not a suitable machine name.", local);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!machine_name_is_valid(local))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Local name %s is not a suitable machine name.",
|
||||
local);
|
||||
|
||||
if (path) {
|
||||
fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY);
|
||||
@ -1996,15 +1991,14 @@ static int import_fs(int argc, char *argv[], void *userdata) {
|
||||
|
||||
local = fn;
|
||||
}
|
||||
if (!local) {
|
||||
log_error("Need either path or local name.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!local)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Need either path or local name.");
|
||||
|
||||
if (!machine_name_is_valid(local)) {
|
||||
log_error("Local name %s is not a suitable machine name.", local);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!machine_name_is_valid(local))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Local name %s is not a suitable machine name.",
|
||||
local);
|
||||
|
||||
if (path) {
|
||||
fd = open(path, O_DIRECTORY|O_RDONLY|O_CLOEXEC);
|
||||
@ -2054,10 +2048,9 @@ static int export_tar(int argc, char *argv[], void *userdata) {
|
||||
assert(bus);
|
||||
|
||||
local = argv[1];
|
||||
if (!machine_name_is_valid(local)) {
|
||||
log_error("Machine name %s is not valid.", local);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!machine_name_is_valid(local))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Machine name %s is not valid.", local);
|
||||
|
||||
if (argc >= 3)
|
||||
path = argv[2];
|
||||
@ -2097,10 +2090,9 @@ static int export_raw(int argc, char *argv[], void *userdata) {
|
||||
assert(bus);
|
||||
|
||||
local = argv[1];
|
||||
if (!machine_name_is_valid(local)) {
|
||||
log_error("Machine name %s is not valid.", local);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!machine_name_is_valid(local))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Machine name %s is not valid.", local);
|
||||
|
||||
if (argc >= 3)
|
||||
path = argv[2];
|
||||
@ -2140,10 +2132,9 @@ static int pull_tar(int argc, char *argv[], void *userdata) {
|
||||
assert(bus);
|
||||
|
||||
remote = argv[1];
|
||||
if (!http_url_is_valid(remote)) {
|
||||
log_error("URL '%s' is not valid.", remote);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!http_url_is_valid(remote))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"URL '%s' is not valid.", remote);
|
||||
|
||||
if (argc >= 3)
|
||||
local = argv[2];
|
||||
@ -2164,10 +2155,10 @@ static int pull_tar(int argc, char *argv[], void *userdata) {
|
||||
|
||||
local = ll;
|
||||
|
||||
if (!machine_name_is_valid(local)) {
|
||||
log_error("Local name %s is not a suitable machine name.", local);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!machine_name_is_valid(local))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Local name %s is not a suitable machine name.",
|
||||
local);
|
||||
}
|
||||
|
||||
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "PullTar");
|
||||
@ -2197,10 +2188,9 @@ static int pull_raw(int argc, char *argv[], void *userdata) {
|
||||
assert(bus);
|
||||
|
||||
remote = argv[1];
|
||||
if (!http_url_is_valid(remote)) {
|
||||
log_error("URL '%s' is not valid.", remote);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!http_url_is_valid(remote))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"URL '%s' is not valid.", remote);
|
||||
|
||||
if (argc >= 3)
|
||||
local = argv[2];
|
||||
@ -2221,10 +2211,10 @@ static int pull_raw(int argc, char *argv[], void *userdata) {
|
||||
|
||||
local = ll;
|
||||
|
||||
if (!machine_name_is_valid(local)) {
|
||||
log_error("Local name %s is not a suitable machine name.", local);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!machine_name_is_valid(local))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Local name %s is not a suitable machine name.",
|
||||
local);
|
||||
}
|
||||
|
||||
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "PullRaw");
|
||||
|
@ -923,10 +923,9 @@ static int umount_by_device(sd_bus *bus, const char *what) {
|
||||
if (stat(what, &st) < 0)
|
||||
return log_error_errno(errno, "Can't stat %s: %m", what);
|
||||
|
||||
if (!S_ISBLK(st.st_mode)) {
|
||||
log_error("Not a block device: %s", what);
|
||||
return -ENOTBLK;
|
||||
}
|
||||
if (!S_ISBLK(st.st_mode))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENOTBLK),
|
||||
"Not a block device: %s", what);
|
||||
|
||||
r = sd_device_new_from_devnum(&d, 'b', st.st_rdev);
|
||||
if (r < 0)
|
||||
@ -1249,10 +1248,10 @@ static int discover_loop_backing_file(void) {
|
||||
escaped = xescape(basename(arg_mount_what), "\\");
|
||||
if (!escaped)
|
||||
return log_oom();
|
||||
if (!filename_is_valid(escaped)) {
|
||||
log_error("Escaped name %s is not a valid filename.", escaped);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!filename_is_valid(escaped))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Escaped name %s is not a valid filename.",
|
||||
escaped);
|
||||
|
||||
arg_mount_where = path_join("/run/media/system", escaped);
|
||||
if (!arg_mount_where)
|
||||
@ -1265,10 +1264,9 @@ static int discover_loop_backing_file(void) {
|
||||
if (stat(loop_dev, &st) < 0)
|
||||
return log_error_errno(errno, "Can't stat %s: %m", loop_dev);
|
||||
|
||||
if (!S_ISBLK(st.st_mode)) {
|
||||
log_error("Invalid file type: %s", loop_dev);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!S_ISBLK(st.st_mode))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Invalid file type: %s", loop_dev);
|
||||
|
||||
r = sd_device_new_from_devnum(&d, 'b', st.st_rdev);
|
||||
if (r < 0)
|
||||
@ -1309,19 +1307,19 @@ static int discover_device(void) {
|
||||
if (S_ISREG(st.st_mode))
|
||||
return discover_loop_backing_file();
|
||||
|
||||
if (!S_ISBLK(st.st_mode)) {
|
||||
log_error("Invalid file type: %s", arg_mount_what);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!S_ISBLK(st.st_mode))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Invalid file type: %s",
|
||||
arg_mount_what);
|
||||
|
||||
r = sd_device_new_from_devnum(&d, 'b', st.st_rdev);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to get device from device number: %m");
|
||||
|
||||
if (sd_device_get_property_value(d, "ID_FS_USAGE", &v) < 0 || !streq(v, "filesystem")) {
|
||||
log_error("%s does not contain a known file system.", arg_mount_what);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (sd_device_get_property_value(d, "ID_FS_USAGE", &v) < 0 || !streq(v, "filesystem"))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"%s does not contain a known file system.",
|
||||
arg_mount_what);
|
||||
|
||||
r = acquire_mount_type(d);
|
||||
if (r < 0)
|
||||
@ -1462,10 +1460,10 @@ static int run(int argc, char* argv[]) {
|
||||
return action_umount(bus, argc, argv);
|
||||
|
||||
if ((!arg_mount_type || fstype_is_blockdev_backed(arg_mount_type))
|
||||
&& !path_is_normalized(arg_mount_what)) {
|
||||
log_error("Path contains non-normalized components: %s", arg_mount_what);
|
||||
return -EINVAL;
|
||||
}
|
||||
&& !path_is_normalized(arg_mount_what))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Path contains non-normalized components: %s",
|
||||
arg_mount_what);
|
||||
|
||||
if (arg_discover) {
|
||||
r = discover_device();
|
||||
@ -1473,20 +1471,19 @@ static int run(int argc, char* argv[]) {
|
||||
return r;
|
||||
}
|
||||
|
||||
if (!arg_mount_where) {
|
||||
log_error("Can't figure out where to mount %s.", arg_mount_what);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!arg_mount_where)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Can't figure out where to mount %s.",
|
||||
arg_mount_what);
|
||||
|
||||
if (path_equal(arg_mount_where, "/")) {
|
||||
log_error("Refusing to operate on root directory.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (path_equal(arg_mount_where, "/"))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Refusing to operate on root directory.");
|
||||
|
||||
if (!path_is_normalized(arg_mount_where)) {
|
||||
log_error("Path contains non-normalized components: %s", arg_mount_where);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!path_is_normalized(arg_mount_where))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Path contains non-normalized components: %s",
|
||||
arg_mount_where);
|
||||
|
||||
if (streq_ptr(arg_mount_type, "auto"))
|
||||
arg_mount_type = mfree(arg_mount_type);
|
||||
@ -1516,11 +1513,10 @@ static int run(int argc, char* argv[]) {
|
||||
if (arg_mount_type &&
|
||||
!streq(arg_mount_type, "auto") &&
|
||||
arg_uid != UID_INVALID &&
|
||||
!fstype_can_uid_gid(arg_mount_type)) {
|
||||
log_error("File system type %s is not known to support uid=/gid=, refusing.",
|
||||
arg_mount_type);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
!fstype_can_uid_gid(arg_mount_type))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"File system type %s is not known to support uid=/gid=, refusing.",
|
||||
arg_mount_type);
|
||||
|
||||
switch (arg_action) {
|
||||
|
||||
|
@ -762,10 +762,9 @@ int config_parse_dhcp_send_option(
|
||||
}
|
||||
case DHCP_OPTION_DATA_STRING:
|
||||
sz = cunescape(p, UNESCAPE_ACCEPT_NUL, &q);
|
||||
if (sz < 0) {
|
||||
if (sz < 0)
|
||||
log_syntax(unit, LOG_WARNING, filename, line, sz,
|
||||
"Failed to decode DHCP option data, ignoring assignment: %s", p);
|
||||
}
|
||||
|
||||
udata = q;
|
||||
break;
|
||||
|
@ -123,11 +123,10 @@ int config_parse_generic_random_early_detection_u32(
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (v > MAX_DPs) {
|
||||
if (v > MAX_DPs)
|
||||
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||
"Invalid '%s=', ignoring assignment: %s",
|
||||
lvalue, rvalue);
|
||||
}
|
||||
|
||||
*p = v;
|
||||
qdisc = NULL;
|
||||
|
@ -79,11 +79,10 @@ int config_parse_trivial_link_equalizer_id(
|
||||
lvalue, rvalue);
|
||||
return 0;
|
||||
}
|
||||
if (id > INT_MAX) {
|
||||
if (id > INT_MAX)
|
||||
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||
"'%s=' is too large, ignoring assignment: %s",
|
||||
lvalue, rvalue);
|
||||
}
|
||||
|
||||
teql->id = id;
|
||||
|
||||
|
@ -660,10 +660,9 @@ static int oci_namespaces(const char *name, JsonVariant *v, JsonDispatchFlags fl
|
||||
s->network_namespace_path = data.path;
|
||||
}
|
||||
|
||||
if (FLAGS_SET(n, data.type)) {
|
||||
if (FLAGS_SET(n, data.type))
|
||||
return json_log(e, flags, SYNTHETIC_ERRNO(EINVAL),
|
||||
"Duplicate namespace specification, refusing.");
|
||||
}
|
||||
|
||||
n |= data.type;
|
||||
}
|
||||
@ -2216,14 +2215,14 @@ int oci_load(FILE *f, const char *bundle, Settings **ret) {
|
||||
}
|
||||
|
||||
v = json_variant_by_key(oci, "ociVersion");
|
||||
if (!v) {
|
||||
log_error("JSON file '%s' is not an OCI bundle configuration file. Refusing.", path);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!streq_ptr(json_variant_string(v), "1.0.0")) {
|
||||
log_error("OCI bundle version not supported: %s", strna(json_variant_string(v)));
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!v)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"JSON file '%s' is not an OCI bundle configuration file. Refusing.",
|
||||
path);
|
||||
if (!streq_ptr(json_variant_string(v), "1.0.0"))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"OCI bundle version not supported: %s",
|
||||
strna(json_variant_string(v)));
|
||||
|
||||
// {
|
||||
// _cleanup_free_ char *formatted = NULL;
|
||||
|
@ -4342,7 +4342,7 @@ static int load_settings(void) {
|
||||
|
||||
/* If all settings are masked, there's no point in looking for
|
||||
* the settings file */
|
||||
if ((arg_settings_mask & _SETTINGS_MASK_ALL) == _SETTINGS_MASK_ALL)
|
||||
if (FLAGS_SET(arg_settings_mask, _SETTINGS_MASK_ALL))
|
||||
return 0;
|
||||
|
||||
fn = strjoina(arg_machine, ".nspawn");
|
||||
|
@ -595,7 +595,7 @@ enum nss_status _nss_systemd_initgroups_dyn(
|
||||
new_size = limit;
|
||||
|
||||
/* Enlarge buffer */
|
||||
new_groups = realloc(*groupsp, new_size * sizeof(**groupsp));
|
||||
new_groups = reallocarray(*groupsp, new_size, sizeof(**groupsp));
|
||||
if (!new_groups) {
|
||||
UNPROTECT_ERRNO;
|
||||
*errnop = ENOMEM;
|
||||
|
@ -434,10 +434,9 @@ static int portable_extract_by_path(
|
||||
if (isempty(name) && fd < 0)
|
||||
break;
|
||||
|
||||
if (isempty(name) || fd < 0) {
|
||||
log_debug("Invalid item sent from child.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (isempty(name) || fd < 0)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Invalid item sent from child.");
|
||||
|
||||
add = portable_metadata_new(name, fd);
|
||||
if (!add)
|
||||
|
@ -261,10 +261,9 @@ static int resolve_host(sd_bus *bus, const char *name) {
|
||||
(int) strlen(name), c == 0 ? name : "", c == 0 ? ":" : " ",
|
||||
canonical);
|
||||
|
||||
if (c == 0) {
|
||||
log_error("%s: no addresses found", name);
|
||||
return -ESRCH;
|
||||
}
|
||||
if (c == 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ESRCH),
|
||||
"%s: no addresses found", name);
|
||||
|
||||
print_source(flags, ts);
|
||||
|
||||
@ -356,10 +355,9 @@ static int resolve_address(sd_bus *bus, int family, const union in_addr_union *a
|
||||
if (r < 0)
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
if (c == 0) {
|
||||
log_error("%s: no names found", pretty);
|
||||
return -ESRCH;
|
||||
}
|
||||
if (c == 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ESRCH),
|
||||
"%s: no names found", pretty);
|
||||
|
||||
print_source(flags, ts);
|
||||
|
||||
@ -2050,10 +2048,10 @@ static int call_domain(sd_bus *bus, char **domain, const BusLocator *locator, sd
|
||||
r = dns_name_is_valid(n);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to validate specified domain %s: %m", n);
|
||||
if (r == 0) {
|
||||
log_error("Domain not valid: %s", n);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (r == 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Domain not valid: %s",
|
||||
n);
|
||||
|
||||
r = sd_bus_message_append(req, "(sb)", n, **p == '~');
|
||||
if (r < 0)
|
||||
@ -2348,10 +2346,10 @@ static int verb_nta(int argc, char **argv, void *userdata) {
|
||||
r = dns_name_is_valid(*p);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to validate specified domain %s: %m", *p);
|
||||
if (r == 0) {
|
||||
log_error("Domain not valid: %s", *p);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (r == 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Domain not valid: %s",
|
||||
*p);
|
||||
}
|
||||
|
||||
r = call_nta(bus, clear ? NULL : argv + 2, bus_resolve_mgr, &error);
|
||||
|
@ -1426,7 +1426,7 @@ int dns_packet_read_name(
|
||||
|
||||
n += r;
|
||||
continue;
|
||||
} else if (allow_compression && (c & 0xc0) == 0xc0) {
|
||||
} else if (allow_compression && FLAGS_SET(c, 0xc0)) {
|
||||
uint16_t ptr;
|
||||
|
||||
/* Pointer */
|
||||
@ -2241,12 +2241,11 @@ static int dns_packet_extract_answer(DnsPacket *p, DnsAnswer **ret_answer) {
|
||||
if (DNS_PACKET_QR(p)) {
|
||||
/* Additional checks for responses */
|
||||
|
||||
if (!DNS_RESOURCE_RECORD_OPT_VERSION_SUPPORTED(rr)) {
|
||||
if (!DNS_RESOURCE_RECORD_OPT_VERSION_SUPPORTED(rr))
|
||||
/* If this is a reply and we don't know the EDNS version
|
||||
* then something is weird... */
|
||||
log_debug("EDNS version newer that our request, bad server.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),
|
||||
"EDNS version newer that our request, bad server.");
|
||||
|
||||
if (has_rfc6975) {
|
||||
/* If the OPT RR contains RFC6975 algorithm data, then this
|
||||
|
@ -97,15 +97,15 @@ static int dnssd_service_load(Manager *manager, const char *filename) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!service->name_template) {
|
||||
log_error("%s doesn't define service instance name", service->name);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!service->name_template)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"%s doesn't define service instance name",
|
||||
service->name);
|
||||
|
||||
if (!service->type) {
|
||||
log_error("%s doesn't define service type", service->name);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!service->type)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"%s doesn't define service type",
|
||||
service->name);
|
||||
|
||||
if (LIST_IS_EMPTY(service->txt_data_items)) {
|
||||
txt_data = new0(DnssdTxtData, 1);
|
||||
|
@ -780,10 +780,8 @@ int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) {
|
||||
l = recvmsg_safe(fd, &mh, 0);
|
||||
if (IN_SET(l, -EAGAIN, -EINTR))
|
||||
return 0;
|
||||
if (l < 0)
|
||||
if (l <= 0)
|
||||
return l;
|
||||
if (l == 0)
|
||||
return 0;
|
||||
|
||||
assert(!(mh.msg_flags & MSG_TRUNC));
|
||||
|
||||
|
@ -1336,7 +1336,7 @@ static int start_transient_service(
|
||||
if (c.cpu_usage_nsec != NSEC_INFINITY) {
|
||||
char ts[FORMAT_TIMESPAN_MAX];
|
||||
log_info("CPU time consumed: %s",
|
||||
format_timespan(ts, sizeof ts, (c.cpu_usage_nsec + NSEC_PER_USEC - 1) / NSEC_PER_USEC, USEC_PER_MSEC));
|
||||
format_timespan(ts, sizeof ts, DIV_ROUND_UP(c.cpu_usage_nsec, NSEC_PER_USEC), USEC_PER_MSEC));
|
||||
}
|
||||
|
||||
if (c.ip_ingress_bytes != UINT64_MAX) {
|
||||
|
@ -266,12 +266,10 @@ int bus_connect_transport(BusTransport transport, const char *host, bool user, s
|
||||
if (user)
|
||||
r = sd_bus_default_user(&bus);
|
||||
else {
|
||||
if (sd_booted() <= 0) {
|
||||
if (sd_booted() <= 0)
|
||||
/* Print a friendly message when the local system is actually not running systemd as PID 1. */
|
||||
log_error("System has not been booted with systemd as init system (PID 1). Can't operate.");
|
||||
|
||||
return -EHOSTDOWN;
|
||||
}
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EHOSTDOWN),
|
||||
"System has not been booted with systemd as init system (PID 1). Can't operate.");
|
||||
r = sd_bus_default_system(&bus);
|
||||
}
|
||||
break;
|
||||
|
@ -224,7 +224,7 @@ static int wait_for_partitions_to_appear(
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
return log_debug_errno(EPROTONOSUPPORT,
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EPROTONOSUPPORT),
|
||||
"Device is a loop device and partition scanning is off!");
|
||||
|
||||
return -EINVAL; /* original error */
|
||||
|
@ -791,8 +791,8 @@ static int slot_process(
|
||||
|
||||
rv = m->C_GetTokenInfo(slotid, &token_info);
|
||||
if (rv == CKR_TOKEN_NOT_PRESENT) {
|
||||
log_debug("Token not present in slot, ignoring.");
|
||||
return -EAGAIN;
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EAGAIN),
|
||||
"Token not present in slot, ignoring.");
|
||||
} else if (rv != CKR_OK) {
|
||||
log_warning("Failed to acquire token info for slot %lu, ignoring slot: %s", slotid, p11_kit_strerror(rv));
|
||||
return -EAGAIN;
|
||||
@ -808,10 +808,10 @@ static int slot_process(
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
if (search_uri && !p11_kit_uri_match_token_info(search_uri, &token_info)) {
|
||||
log_debug("Found non-matching token with URI %s.", token_uri_string);
|
||||
return -EAGAIN;
|
||||
}
|
||||
if (search_uri && !p11_kit_uri_match_token_info(search_uri, &token_info))
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EAGAIN),
|
||||
"Found non-matching token with URI %s.",
|
||||
token_uri_string);
|
||||
|
||||
log_debug("Found matching token with URI %s.", token_uri_string);
|
||||
|
||||
@ -876,10 +876,9 @@ static int module_process(
|
||||
log_warning("Failed to get slot list, ignoring module: %s", p11_kit_strerror(rv));
|
||||
return -EAGAIN;
|
||||
}
|
||||
if (n_slotids == 0) {
|
||||
log_debug("This module has no slots? Ignoring module.");
|
||||
return -EAGAIN;
|
||||
}
|
||||
if (n_slotids == 0)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EAGAIN),
|
||||
"This module has no slots? Ignoring module.");
|
||||
|
||||
for (k = 0; k < n_slotids; k++) {
|
||||
r = slot_process(
|
||||
|
@ -1190,7 +1190,7 @@ int seccomp_restrict_namespaces(unsigned long retain) {
|
||||
}
|
||||
|
||||
/* NOOP? */
|
||||
if ((retain & NAMESPACE_FLAGS_ALL) == NAMESPACE_FLAGS_ALL)
|
||||
if (FLAGS_SET(retain, NAMESPACE_FLAGS_ALL))
|
||||
return 0;
|
||||
|
||||
SECCOMP_FOREACH_LOCAL_ARCH(arch) {
|
||||
@ -1228,7 +1228,7 @@ int seccomp_restrict_namespaces(unsigned long retain) {
|
||||
unsigned long f;
|
||||
|
||||
f = namespace_flag_map[i].flag;
|
||||
if ((retain & f) == f) {
|
||||
if (FLAGS_SET(retain, f)) {
|
||||
log_debug("Permitting %s.", namespace_flag_map[i].name);
|
||||
continue;
|
||||
}
|
||||
|
@ -187,11 +187,10 @@ int logind_check_inhibitors(enum action a) {
|
||||
if (c <= 0)
|
||||
return 0;
|
||||
|
||||
log_error("Please retry operation after closing inhibitors and logging out other users.\n"
|
||||
"Alternatively, ignore inhibitors and users with 'systemctl %s -i'.",
|
||||
action_table[a].verb);
|
||||
|
||||
return -EPERM;
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EPERM),
|
||||
"Please retry operation after closing inhibitors and logging out other users.\n"
|
||||
"Alternatively, ignore inhibitors and users with 'systemctl %s -i'.",
|
||||
action_table[a].verb);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -106,7 +106,7 @@ static void test_device_parents(struct udev *udev, const char *syspath) {
|
||||
|
||||
log_info("/* %s, device %s */", __func__, syspath);
|
||||
device = udev_device_new_from_syspath(udev, syspath);
|
||||
if (device == NULL)
|
||||
if (!device)
|
||||
return;
|
||||
|
||||
log_info("looking at parents");
|
||||
@ -142,7 +142,7 @@ static void test_device_subsys_name(struct udev *udev, const char *subsys, const
|
||||
|
||||
log_info("looking up device: '%s:%s'", subsys, dev);
|
||||
device = udev_device_new_from_subsystem_sysname(udev, subsys, dev);
|
||||
if (device == NULL)
|
||||
if (!device)
|
||||
log_warning_errno(errno, "udev_device_new_from_subsystem_sysname: %m");
|
||||
else
|
||||
print_device(device);
|
||||
@ -213,7 +213,7 @@ static void test_monitor(struct udev *udev) {
|
||||
for (i = 0; i < fdcount; i++) {
|
||||
if (ev[i].data.fd == fd_udev && ev[i].events & EPOLLIN) {
|
||||
device = udev_monitor_receive_device(udev_monitor);
|
||||
if (device == NULL) {
|
||||
if (!device) {
|
||||
printf("no device from socket\n");
|
||||
continue;
|
||||
}
|
||||
|
@ -1417,10 +1417,10 @@ static int create_file(Item *i, const char *path) {
|
||||
if (fstat(fd, &stbuf) < 0)
|
||||
return log_error_errno(errno, "stat(%s) failed: %m", path);
|
||||
|
||||
if (!S_ISREG(stbuf.st_mode)) {
|
||||
log_error("%s exists and is not a regular file.", path);
|
||||
return -EEXIST;
|
||||
}
|
||||
if (!S_ISREG(stbuf.st_mode))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EEXIST),
|
||||
"%s exists and is not a regular file.",
|
||||
path);
|
||||
|
||||
st = &stbuf;
|
||||
} else {
|
||||
@ -1481,10 +1481,10 @@ static int truncate_file(Item *i, const char *path) {
|
||||
|
||||
fd = openat(dir_fd, bn, O_NOFOLLOW|O_CLOEXEC|O_PATH, i->mode);
|
||||
if (fd < 0) {
|
||||
if (errno == ENOENT) {
|
||||
log_error("Cannot create file %s on a read-only file system.", path);
|
||||
return -EROFS;
|
||||
}
|
||||
if (errno == ENOENT)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EROFS),
|
||||
"Cannot create file %s on a read-only file system.",
|
||||
path);
|
||||
|
||||
return log_error_errno(errno, "Failed to re-open file %s: %m", path);
|
||||
}
|
||||
@ -1495,10 +1495,10 @@ static int truncate_file(Item *i, const char *path) {
|
||||
if (fstat(fd, &stbuf) < 0)
|
||||
return log_error_errno(errno, "stat(%s) failed: %m", path);
|
||||
|
||||
if (!S_ISREG(stbuf.st_mode)) {
|
||||
log_error("%s exists and is not a regular file.", path);
|
||||
return -EEXIST;
|
||||
}
|
||||
if (!S_ISREG(stbuf.st_mode))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EEXIST),
|
||||
"%s exists and is not a regular file.",
|
||||
path);
|
||||
|
||||
if (stbuf.st_size > 0) {
|
||||
if (ftruncate(fd, 0) < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user