mirror of
https://github.com/systemd/systemd
synced 2026-04-12 18:14:51 +02:00
Compare commits
13 Commits
7185af6234
...
5f74fcd41c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f74fcd41c | ||
|
|
c790632cab | ||
|
|
73dfeb0c6e | ||
|
|
633c3e8aa2 | ||
|
|
80b241f2ec | ||
|
|
fe8fdc4760 | ||
|
|
d090049c01 | ||
|
|
3876cfafd0 | ||
|
|
e794bcaf1c | ||
|
|
e97a300148 | ||
|
|
8fb16fee96 | ||
|
|
9383fa08bd | ||
|
|
d8d6b2275f |
@ -46,8 +46,7 @@ int gethostname_full(GetHostnameFlags flags, char **ret) {
|
|||||||
assert_se(uname(&u) >= 0);
|
assert_se(uname(&u) >= 0);
|
||||||
|
|
||||||
s = u.nodename;
|
s = u.nodename;
|
||||||
if (isempty(s) ||
|
if (isempty(s) || streq(s, "(none)") ||
|
||||||
(!FLAGS_SET(flags, GET_HOSTNAME_ALLOW_NONE) && streq(s, "(none)")) ||
|
|
||||||
(!FLAGS_SET(flags, GET_HOSTNAME_ALLOW_LOCALHOST) && is_localhost(s)) ||
|
(!FLAGS_SET(flags, GET_HOSTNAME_ALLOW_LOCALHOST) && is_localhost(s)) ||
|
||||||
(FLAGS_SET(flags, GET_HOSTNAME_SHORT) && s[0] == '.')) {
|
(FLAGS_SET(flags, GET_HOSTNAME_SHORT) && s[0] == '.')) {
|
||||||
if (!FLAGS_SET(flags, GET_HOSTNAME_FALLBACK_DEFAULT))
|
if (!FLAGS_SET(flags, GET_HOSTNAME_FALLBACK_DEFAULT))
|
||||||
|
|||||||
@ -9,10 +9,9 @@
|
|||||||
#include "strv.h"
|
#include "strv.h"
|
||||||
|
|
||||||
typedef enum GetHostnameFlags {
|
typedef enum GetHostnameFlags {
|
||||||
GET_HOSTNAME_ALLOW_NONE = 1 << 0, /* accepts "(none)". */
|
GET_HOSTNAME_ALLOW_LOCALHOST = 1 << 0, /* accepts "localhost" or friends. */
|
||||||
GET_HOSTNAME_ALLOW_LOCALHOST = 1 << 1, /* accepts "localhost" or friends. */
|
GET_HOSTNAME_FALLBACK_DEFAULT = 1 << 1, /* use default hostname if no hostname is set. */
|
||||||
GET_HOSTNAME_FALLBACK_DEFAULT = 1 << 2, /* use default hostname if no hostname is set. */
|
GET_HOSTNAME_SHORT = 1 << 2, /* kills the FQDN part if present. */
|
||||||
GET_HOSTNAME_SHORT = 1 << 3, /* kills the FQDN part if present. */
|
|
||||||
} GetHostnameFlags;
|
} GetHostnameFlags;
|
||||||
|
|
||||||
int gethostname_full(GetHostnameFlags flags, char **ret);
|
int gethostname_full(GetHostnameFlags flags, char **ret);
|
||||||
|
|||||||
@ -31,10 +31,10 @@ typedef enum LogTarget{
|
|||||||
* used a regular log level. */
|
* used a regular log level. */
|
||||||
#define LOG_NULL (LOG_EMERG - 1)
|
#define LOG_NULL (LOG_EMERG - 1)
|
||||||
|
|
||||||
/* Note to readers: << and >> have lower precedence than & and | */
|
/* Note to readers: << and >> have lower precedence (are evaluated earlier) than & and | */
|
||||||
#define SYNTHETIC_ERRNO(num) (1 << 30 | (num))
|
#define SYNTHETIC_ERRNO(num) (1 << 30 | (num))
|
||||||
#define IS_SYNTHETIC_ERRNO(val) ((val) >> 30 & 1)
|
#define IS_SYNTHETIC_ERRNO(val) ((val) >> 30 & 1)
|
||||||
#define ERRNO_VALUE(val) (abs(val) & 255)
|
#define ERRNO_VALUE(val) (abs(val) & ~(1 << 30))
|
||||||
|
|
||||||
/* The callback function to be invoked when syntax warnings are seen
|
/* The callback function to be invoked when syntax warnings are seen
|
||||||
* in the unit files. */
|
* in the unit files. */
|
||||||
|
|||||||
@ -43,8 +43,13 @@ static EFI_STATUS load_one_driver(
|
|||||||
return log_error_status_stall(EFI_INVALID_PARAMETER, L"Image %s is not a driver, refusing: %r", fname);
|
return log_error_status_stall(EFI_INVALID_PARAMETER, L"Image %s is not a driver, refusing: %r", fname);
|
||||||
|
|
||||||
err = BS->StartImage(image, NULL, NULL);
|
err = BS->StartImage(image, NULL, NULL);
|
||||||
if (EFI_ERROR(err))
|
if (EFI_ERROR(err)) {
|
||||||
return log_error_status_stall(err, L"Failed to start image %s: %r", fname, err);
|
/* EFI_ABORTED signals an initializing driver. It uses this error code on success
|
||||||
|
* so that it is unloaded after. */
|
||||||
|
if (err != EFI_ABORTED)
|
||||||
|
log_error_stall(L"Failed to start image %s: %r", fname, err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
TAKE_PTR(image);
|
TAKE_PTR(image);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
|||||||
@ -793,10 +793,9 @@ static int submit_coredump(
|
|||||||
r = maybe_remove_external_coredump(filename, coredump_node_fd >= 0 ? coredump_compressed_size : coredump_size);
|
r = maybe_remove_external_coredump(filename, coredump_node_fd >= 0 ? coredump_compressed_size : coredump_size);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
if (r == 0) {
|
if (r == 0)
|
||||||
(void) iovw_put_string_field(iovw, "COREDUMP_FILENAME=", filename);
|
(void) iovw_put_string_field(iovw, "COREDUMP_FILENAME=", filename);
|
||||||
|
else if (arg_storage == COREDUMP_STORAGE_EXTERNAL)
|
||||||
} else if (arg_storage == COREDUMP_STORAGE_EXTERNAL)
|
|
||||||
log_info("The core will not be stored: size %"PRIu64" is greater than %"PRIu64" (the configured maximum)",
|
log_info("The core will not be stored: size %"PRIu64" is greater than %"PRIu64" (the configured maximum)",
|
||||||
coredump_node_fd >= 0 ? coredump_compressed_size : coredump_size, arg_external_size_max);
|
coredump_node_fd >= 0 ? coredump_compressed_size : coredump_size, arg_external_size_max);
|
||||||
|
|
||||||
@ -813,16 +812,19 @@ static int submit_coredump(
|
|||||||
return log_error_errno(r, "Failed to drop privileges: %m");
|
return log_error_errno(r, "Failed to drop privileges: %m");
|
||||||
|
|
||||||
/* Try to get a stack trace if we can */
|
/* Try to get a stack trace if we can */
|
||||||
if (coredump_size > arg_process_size_max) {
|
if (coredump_size > arg_process_size_max)
|
||||||
log_debug("Not generating stack trace: core size %"PRIu64" is greater "
|
log_debug("Not generating stack trace: core size %"PRIu64" is greater "
|
||||||
"than %"PRIu64" (the configured maximum)",
|
"than %"PRIu64" (the configured maximum)",
|
||||||
coredump_size, arg_process_size_max);
|
coredump_size, arg_process_size_max);
|
||||||
} else if (coredump_fd >= 0)
|
else if (coredump_fd >= 0) {
|
||||||
|
bool skip = startswith(context->meta[META_COMM], "systemd-coredum"); /* COMM is 16 bytes usually */
|
||||||
|
|
||||||
(void) parse_elf_object(coredump_fd,
|
(void) parse_elf_object(coredump_fd,
|
||||||
context->meta[META_EXE],
|
context->meta[META_EXE],
|
||||||
/* fork_disable_dump= */endswith(context->meta[META_EXE], "systemd-coredump"), /* avoid loops */
|
/* fork_disable_dump= */ skip, /* avoid loops */
|
||||||
&stacktrace,
|
&stacktrace,
|
||||||
&json_metadata);
|
&json_metadata);
|
||||||
|
}
|
||||||
|
|
||||||
log:
|
log:
|
||||||
core_message = strjoina("Process ", context->meta[META_ARGV_PID],
|
core_message = strjoina("Process ", context->meta[META_ARGV_PID],
|
||||||
@ -857,20 +859,23 @@ log:
|
|||||||
(void) iovw_put_string_field(iovw, "COREDUMP_PACKAGE_JSON=", formatted_json);
|
(void) iovw_put_string_field(iovw, "COREDUMP_PACKAGE_JSON=", formatted_json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* In the unlikely scenario that context->meta[META_EXE] is not available,
|
||||||
|
* let's avoid guessing the module name and skip the loop. */
|
||||||
|
if (context->meta[META_EXE])
|
||||||
JSON_VARIANT_OBJECT_FOREACH(module_name, module_json, json_metadata) {
|
JSON_VARIANT_OBJECT_FOREACH(module_name, module_json, json_metadata) {
|
||||||
JsonVariant *package_name, *package_version;
|
JsonVariant *t;
|
||||||
|
|
||||||
/* We only add structured fields for the 'main' ELF module */
|
/* We only add structured fields for the 'main' ELF module, and only if we can identify it. */
|
||||||
if (!path_equal_filename(module_name, context->meta[META_EXE]))
|
if (!path_equal_filename(module_name, context->meta[META_EXE]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
package_name = json_variant_by_key(module_json, "name");
|
t = json_variant_by_key(module_json, "name");
|
||||||
if (package_name)
|
if (t)
|
||||||
(void) iovw_put_string_field(iovw, "COREDUMP_PACKAGE_NAME=", json_variant_string(package_name));
|
(void) iovw_put_string_field(iovw, "COREDUMP_PACKAGE_NAME=", json_variant_string(t));
|
||||||
|
|
||||||
package_version = json_variant_by_key(module_json, "version");
|
t = json_variant_by_key(module_json, "version");
|
||||||
if (package_version)
|
if (t)
|
||||||
(void) iovw_put_string_field(iovw, "COREDUMP_PACKAGE_VERSION=", json_variant_string(package_version));
|
(void) iovw_put_string_field(iovw, "COREDUMP_PACKAGE_VERSION=", json_variant_string(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Optionally store the entire coredump in the journal */
|
/* Optionally store the entire coredump in the journal */
|
||||||
@ -1181,7 +1186,7 @@ static int gather_pid_metadata(struct iovec_wrapper *iovw, Context *context) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
/* The following are optional but we used them if present */
|
/* The following are optional, but we use them if present. */
|
||||||
r = get_process_exe(pid, &t);
|
r = get_process_exe(pid, &t);
|
||||||
if (r >= 0)
|
if (r >= 0)
|
||||||
r = iovw_put_string_field_free(iovw, "COREDUMP_EXE=", t);
|
r = iovw_put_string_field_free(iovw, "COREDUMP_EXE=", t);
|
||||||
@ -1191,7 +1196,6 @@ static int gather_pid_metadata(struct iovec_wrapper *iovw, Context *context) {
|
|||||||
if (cg_pid_get_unit(pid, &t) >= 0)
|
if (cg_pid_get_unit(pid, &t) >= 0)
|
||||||
(void) iovw_put_string_field_free(iovw, "COREDUMP_UNIT=", t);
|
(void) iovw_put_string_field_free(iovw, "COREDUMP_UNIT=", t);
|
||||||
|
|
||||||
/* The next are optional */
|
|
||||||
if (cg_pid_get_user_unit(pid, &t) >= 0)
|
if (cg_pid_get_user_unit(pid, &t) >= 0)
|
||||||
(void) iovw_put_string_field_free(iovw, "COREDUMP_USER_UNIT=", t);
|
(void) iovw_put_string_field_free(iovw, "COREDUMP_USER_UNIT=", t);
|
||||||
|
|
||||||
|
|||||||
@ -178,8 +178,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(Elf *, sym_elf_end, NULL);
|
|||||||
|
|
||||||
static int frame_callback(Dwfl_Frame *frame, void *userdata) {
|
static int frame_callback(Dwfl_Frame *frame, void *userdata) {
|
||||||
StackContext *c = userdata;
|
StackContext *c = userdata;
|
||||||
Dwarf_Addr pc, pc_adjusted, bias = 0;
|
Dwarf_Addr pc, pc_adjusted;
|
||||||
_cleanup_free_ Dwarf_Die *scopes = NULL;
|
|
||||||
const char *fname = NULL, *symbol = NULL;
|
const char *fname = NULL, *symbol = NULL;
|
||||||
Dwfl_Module *module;
|
Dwfl_Module *module;
|
||||||
bool is_activation;
|
bool is_activation;
|
||||||
@ -198,18 +197,22 @@ static int frame_callback(Dwfl_Frame *frame, void *userdata) {
|
|||||||
|
|
||||||
module = sym_dwfl_addrmodule(c->dwfl, pc_adjusted);
|
module = sym_dwfl_addrmodule(c->dwfl, pc_adjusted);
|
||||||
if (module) {
|
if (module) {
|
||||||
Dwarf_Die *s, *cudie;
|
Dwarf_Addr start, bias = 0;
|
||||||
int n;
|
Dwarf_Die *cudie;
|
||||||
Dwarf_Addr start;
|
|
||||||
|
|
||||||
cudie = sym_dwfl_module_addrdie(module, pc_adjusted, &bias);
|
cudie = sym_dwfl_module_addrdie(module, pc_adjusted, &bias);
|
||||||
if (cudie) {
|
if (cudie) {
|
||||||
|
_cleanup_free_ Dwarf_Die *scopes = NULL;
|
||||||
|
int n;
|
||||||
|
|
||||||
n = sym_dwarf_getscopes(cudie, pc_adjusted - bias, &scopes);
|
n = sym_dwarf_getscopes(cudie, pc_adjusted - bias, &scopes);
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
for (s = scopes; s && s < scopes + n; s++) {
|
for (Dwarf_Die *s = scopes; s && s < scopes + n; s++) {
|
||||||
if (IN_SET(sym_dwarf_tag(s), DW_TAG_subprogram, DW_TAG_inlined_subroutine, DW_TAG_entry_point)) {
|
|
||||||
Dwarf_Attribute *a, space;
|
Dwarf_Attribute *a, space;
|
||||||
|
|
||||||
|
if (!IN_SET(sym_dwarf_tag(s), DW_TAG_subprogram, DW_TAG_inlined_subroutine, DW_TAG_entry_point))
|
||||||
|
continue;
|
||||||
|
|
||||||
a = sym_dwarf_attr_integrate(s, DW_AT_MIPS_linkage_name, &space);
|
a = sym_dwarf_attr_integrate(s, DW_AT_MIPS_linkage_name, &space);
|
||||||
if (!a)
|
if (!a)
|
||||||
a = sym_dwarf_attr_integrate(s, DW_AT_linkage_name, &space);
|
a = sym_dwarf_attr_integrate(s, DW_AT_linkage_name, &space);
|
||||||
@ -222,7 +225,6 @@ static int frame_callback(Dwfl_Frame *frame, void *userdata) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!symbol)
|
if (!symbol)
|
||||||
symbol = sym_dwfl_module_addrname(module, pc_adjusted);
|
symbol = sym_dwfl_module_addrname(module, pc_adjusted);
|
||||||
@ -286,7 +288,6 @@ static int parse_package_metadata(const char *name, JsonVariant *id_json, Elf *e
|
|||||||
/* Iterate over all program headers in that ELF object. These will have been copied by
|
/* Iterate over all program headers in that ELF object. These will have been copied by
|
||||||
* the kernel verbatim when the core file is generated. */
|
* the kernel verbatim when the core file is generated. */
|
||||||
for (size_t i = 0; i < n_program_headers; ++i) {
|
for (size_t i = 0; i < n_program_headers; ++i) {
|
||||||
size_t note_offset = 0, name_offset, desc_offset;
|
|
||||||
GElf_Phdr mem, *program_header;
|
GElf_Phdr mem, *program_header;
|
||||||
GElf_Nhdr note_header;
|
GElf_Nhdr note_header;
|
||||||
Elf_Data *data;
|
Elf_Data *data;
|
||||||
@ -311,8 +312,11 @@ static int parse_package_metadata(const char *name, JsonVariant *id_json, Elf *e
|
|||||||
if (!data)
|
if (!data)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
while (note_offset < data->d_size &&
|
for (size_t note_offset = 0, name_offset, desc_offset;
|
||||||
(note_offset = sym_gelf_getnote(data, note_offset, ¬e_header, &name_offset, &desc_offset)) > 0) {
|
note_offset < data->d_size &&
|
||||||
|
(note_offset = sym_gelf_getnote(data, note_offset, ¬e_header, &name_offset, &desc_offset)) > 0;) {
|
||||||
|
|
||||||
|
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *w = NULL;
|
||||||
const char *note_name = (const char *)data->d_buf + name_offset;
|
const char *note_name = (const char *)data->d_buf + name_offset;
|
||||||
const char *payload = (const char *)data->d_buf + desc_offset;
|
const char *payload = (const char *)data->d_buf + desc_offset;
|
||||||
|
|
||||||
@ -321,8 +325,8 @@ static int parse_package_metadata(const char *name, JsonVariant *id_json, Elf *e
|
|||||||
|
|
||||||
/* Package metadata might have different owners, but the
|
/* Package metadata might have different owners, but the
|
||||||
* magic ID is always the same. */
|
* magic ID is always the same. */
|
||||||
if (note_header.n_type == ELF_PACKAGE_METADATA_ID) {
|
if (note_header.n_type != ELF_PACKAGE_METADATA_ID)
|
||||||
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *w = NULL;
|
continue;
|
||||||
|
|
||||||
r = json_parse(payload, 0, &v, NULL, NULL);
|
r = json_parse(payload, 0, &v, NULL, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@ -351,6 +355,7 @@ static int parse_package_metadata(const char *name, JsonVariant *id_json, Elf *e
|
|||||||
r = json_build(&w, JSON_BUILD_OBJECT(JSON_BUILD_PAIR(name, JSON_BUILD_VARIANT(v))));
|
r = json_build(&w, JSON_BUILD_OBJECT(JSON_BUILD_PAIR(name, JSON_BUILD_VARIANT(v))));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to build JSON object: %m");
|
return log_error_errno(r, "Failed to build JSON object: %m");
|
||||||
|
|
||||||
r = json_variant_merge(c->package_metadata, w);
|
r = json_variant_merge(c->package_metadata, w);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "json_variant_merge of package meta with buildid failed: %m");
|
return log_error_errno(r, "json_variant_merge of package meta with buildid failed: %m");
|
||||||
@ -366,7 +371,6 @@ static int parse_package_metadata(const char *name, JsonVariant *id_json, Elf *e
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (ret_interpreter_found)
|
if (ret_interpreter_found)
|
||||||
*ret_interpreter_found = interpreter_found;
|
*ret_interpreter_found = interpreter_found;
|
||||||
@ -384,6 +388,7 @@ static int parse_buildid(Dwfl_Module *mod, Elf *elf, const char *name, StackCont
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(mod || elf);
|
assert(mod || elf);
|
||||||
|
assert(name);
|
||||||
assert(c);
|
assert(c);
|
||||||
|
|
||||||
if (mod)
|
if (mod)
|
||||||
@ -572,7 +577,7 @@ static int parse_elf(int fd, const char *executable, char **ret, JsonVariant **r
|
|||||||
.package_metadata = &package_metadata,
|
.package_metadata = &package_metadata,
|
||||||
.modules = &modules,
|
.modules = &modules,
|
||||||
};
|
};
|
||||||
const char *elf_architecture = NULL, *elf_type;
|
const char *elf_type;
|
||||||
GElf_Ehdr elf_header;
|
GElf_Ehdr elf_header;
|
||||||
size_t sz = 0;
|
size_t sz = 0;
|
||||||
int r;
|
int r;
|
||||||
@ -610,19 +615,20 @@ static int parse_elf(int fd, const char *executable, char **ret, JsonVariant **r
|
|||||||
elf_type = "coredump";
|
elf_type = "coredump";
|
||||||
} else {
|
} else {
|
||||||
_cleanup_(json_variant_unrefp) JsonVariant *id_json = NULL;
|
_cleanup_(json_variant_unrefp) JsonVariant *id_json = NULL;
|
||||||
|
const char *e = executable ?: "(unnamed)";
|
||||||
bool interpreter_found = false;
|
bool interpreter_found = false;
|
||||||
|
|
||||||
r = parse_buildid(NULL, c.elf, executable, &c, &id_json);
|
r = parse_buildid(NULL, c.elf, e, &c, &id_json);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_warning_errno(r, "Failed to parse build-id of ELF file: %m");
|
return log_warning_errno(r, "Failed to parse build-id of ELF file: %m");
|
||||||
|
|
||||||
r = parse_package_metadata(executable, id_json, c.elf, &interpreter_found, &c);
|
r = parse_package_metadata(e, id_json, c.elf, &interpreter_found, &c);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_warning_errno(r, "Failed to parse package metadata of ELF file: %m");
|
return log_warning_errno(r, "Failed to parse package metadata of ELF file: %m");
|
||||||
|
|
||||||
/* If we found a build-id and nothing else, return at least that. */
|
/* If we found a build-id and nothing else, return at least that. */
|
||||||
if (!package_metadata && id_json) {
|
if (!package_metadata && id_json) {
|
||||||
r = json_build(&package_metadata, JSON_BUILD_OBJECT(JSON_BUILD_PAIR(executable, JSON_BUILD_VARIANT(id_json))));
|
r = json_build(&package_metadata, JSON_BUILD_OBJECT(JSON_BUILD_PAIR(e, JSON_BUILD_VARIANT(id_json))));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_warning_errno(r, "Failed to build JSON object: %m");
|
return log_warning_errno(r, "Failed to build JSON object: %m");
|
||||||
}
|
}
|
||||||
@ -640,8 +646,7 @@ static int parse_elf(int fd, const char *executable, char **ret, JsonVariant **r
|
|||||||
return log_warning_errno(r, "Failed to build JSON object: %m");
|
return log_warning_errno(r, "Failed to build JSON object: %m");
|
||||||
|
|
||||||
#if HAVE_DWELF_ELF_E_MACHINE_STRING
|
#if HAVE_DWELF_ELF_E_MACHINE_STRING
|
||||||
elf_architecture = sym_dwelf_elf_e_machine_string(elf_header.e_machine);
|
const char *elf_architecture = sym_dwelf_elf_e_machine_string(elf_header.e_machine);
|
||||||
#endif
|
|
||||||
if (elf_architecture) {
|
if (elf_architecture) {
|
||||||
_cleanup_(json_variant_unrefp) JsonVariant *json_architecture = NULL;
|
_cleanup_(json_variant_unrefp) JsonVariant *json_architecture = NULL;
|
||||||
|
|
||||||
@ -657,6 +662,7 @@ static int parse_elf(int fd, const char *executable, char **ret, JsonVariant **r
|
|||||||
if (ret)
|
if (ret)
|
||||||
fprintf(c.f, "ELF object binary architecture: %s\n", elf_architecture);
|
fprintf(c.f, "ELF object binary architecture: %s\n", elf_architecture);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* We always at least have the ELF type, so merge that (and possibly the arch). */
|
/* We always at least have the ELF type, so merge that (and possibly the arch). */
|
||||||
r = json_variant_merge(&elf_metadata, package_metadata);
|
r = json_variant_merge(&elf_metadata, package_metadata);
|
||||||
@ -683,6 +689,8 @@ int parse_elf_object(int fd, const char *executable, bool fork_disable_dump, cha
|
|||||||
_cleanup_free_ char *buf = NULL;
|
_cleanup_free_ char *buf = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
assert(fd >= 0);
|
||||||
|
|
||||||
r = dlopen_dw();
|
r = dlopen_dw();
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|||||||
@ -20,16 +20,13 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
static int sethostname_idempotent_full(const char *s, bool really) {
|
static int sethostname_idempotent_full(const char *s, bool really) {
|
||||||
_cleanup_free_ char *buf = NULL;
|
struct utsname u;
|
||||||
int r;
|
|
||||||
|
|
||||||
assert(s);
|
assert(s);
|
||||||
|
|
||||||
r = gethostname_full(GET_HOSTNAME_ALLOW_NONE | GET_HOSTNAME_ALLOW_LOCALHOST, &buf);
|
assert_se(uname(&u) >= 0);
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
if (streq(buf, s))
|
if (streq_ptr(s, u.nodename))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (really &&
|
if (really &&
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
#include "sd-id128.h"
|
#include "sd-id128.h"
|
||||||
|
|
||||||
#include "errno-util.h"
|
#include "errno-util.h"
|
||||||
@ -38,7 +40,8 @@ TEST(sysctl_normalize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(sysctl_read) {
|
TEST(sysctl_read) {
|
||||||
_cleanup_free_ char *s = NULL, *h = NULL;
|
_cleanup_free_ char *s = NULL;
|
||||||
|
struct utsname u;
|
||||||
sd_id128_t a, b;
|
sd_id128_t a, b;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -63,8 +66,8 @@ TEST(sysctl_read) {
|
|||||||
s = mfree(s);
|
s = mfree(s);
|
||||||
|
|
||||||
assert_se(sysctl_read("kernel/hostname", &s) >= 0);
|
assert_se(sysctl_read("kernel/hostname", &s) >= 0);
|
||||||
assert_se(gethostname_full(GET_HOSTNAME_ALLOW_NONE|GET_HOSTNAME_ALLOW_LOCALHOST, &h) >= 0);
|
assert_se(uname(&u) >= 0);
|
||||||
assert_se(streq(s, h));
|
assert_se(streq_ptr(s, u.nodename));
|
||||||
|
|
||||||
r = sysctl_write("kernel/hostname", s);
|
r = sysctl_write("kernel/hostname", s);
|
||||||
assert_se(r >= 0 || ERRNO_IS_PRIVILEGE(r) || r == -EROFS);
|
assert_se(r >= 0 || ERRNO_IS_PRIVILEGE(r) || r == -EROFS);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user