mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
Merge pull request #27874 from keszybz/test-bus-server-shortening
Simplify the code in test-bus-server
This commit is contained in:
@@ -3263,7 +3263,7 @@ static int setup_credentials_internal(
|
||||
/* Determine if we should actually install the prepared mount in the final location by bind
|
||||
* mounting it there. We do so only if the mount is not established there already, and if the
|
||||
* mount is actually non-empty (i.e. carries at least one credential). Not that in the best
|
||||
* case we are doing all this in a mount namespace, thus noone else will see that we
|
||||
* case we are doing all this in a mount namespace, thus no one else will see that we
|
||||
* allocated a file system we are getting rid of again here. */
|
||||
if (final_mounted)
|
||||
install = false; /* already installed */
|
||||
|
||||
@@ -21,9 +21,8 @@ struct context {
|
||||
bool server_anonymous_auth;
|
||||
};
|
||||
|
||||
static void *server(void *p) {
|
||||
static int _server(struct context *c) {
|
||||
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
|
||||
struct context *c = p;
|
||||
sd_id128_t id;
|
||||
bool quit = false;
|
||||
int r;
|
||||
@@ -41,18 +40,13 @@ static void *server(void *p) {
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *reply = NULL;
|
||||
|
||||
r = sd_bus_process(bus, &m);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to process requests: %m");
|
||||
goto fail;
|
||||
}
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to process requests: %m");
|
||||
|
||||
if (r == 0) {
|
||||
r = sd_bus_wait(bus, UINT64_MAX);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to wait: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to wait: %m");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -67,10 +61,8 @@ static void *server(void *p) {
|
||||
(c->server_negotiate_unix_fds && c->client_negotiate_unix_fds));
|
||||
|
||||
r = sd_bus_message_new_method_return(m, &reply);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to allocate return: %m");
|
||||
goto fail;
|
||||
}
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to allocate return: %m");
|
||||
|
||||
quit = true;
|
||||
|
||||
@@ -79,25 +71,22 @@ static void *server(void *p) {
|
||||
m,
|
||||
&reply,
|
||||
&SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_UNKNOWN_METHOD, "Unknown method."));
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to allocate return: %m");
|
||||
goto fail;
|
||||
}
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to allocate return: %m");
|
||||
}
|
||||
|
||||
if (reply) {
|
||||
r = sd_bus_send(bus, reply, NULL);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to send reply: %m");
|
||||
goto fail;
|
||||
}
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to send reply: %m");
|
||||
}
|
||||
}
|
||||
|
||||
r = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
fail:
|
||||
return INT_TO_PTR(r);
|
||||
static void* server(void *p) {
|
||||
return INT_TO_PTR(_server(p));
|
||||
}
|
||||
|
||||
static int client(struct context *c) {
|
||||
|
||||
@@ -43,7 +43,7 @@ static const BaseFilesystem table[] = {
|
||||
{ "run", 0555, NULL, NULL, true },
|
||||
/* We don't add /tmp/ here for now (even though it's necessary for regular operation), because we
|
||||
* want to support both cases where /tmp/ is a mount of its own (in which case we probably should set
|
||||
* the mode to 1555, to indicate that noone should write to it, not even root) and when it's part of
|
||||
* the mode to 1555, to indicate that no one should write to it, not even root) and when it's part of
|
||||
* the rootfs (in which case we should set mode 1777), and we simply don't know what's right. */
|
||||
|
||||
/* Various architecture ABIs define the path to the dynamic loader via the /lib64/ subdirectory of
|
||||
|
||||
Reference in New Issue
Block a user