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