mirror of
https://github.com/systemd/systemd.git
synced 2025-01-04 09:18:12 +03:00
Merge 275f747924
into 37c2be73e7
This commit is contained in:
commit
8e104f2257
@ -192,9 +192,9 @@ shared_sources = files(
|
||||
'varlink-io.systemd.PCRLock.c',
|
||||
'varlink-io.systemd.Resolve.c',
|
||||
'varlink-io.systemd.Resolve.Monitor.c',
|
||||
'varlink-io.systemd.Service.c',
|
||||
'varlink-io.systemd.UserDatabase.c',
|
||||
'varlink-io.systemd.oom.c',
|
||||
'varlink-io.systemd.service.c',
|
||||
'varlink-io.systemd.sysext.c',
|
||||
'varlink-serialize.c',
|
||||
'verb-log-control.c',
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "macro.h"
|
||||
#include "varlink-io.systemd.service.h"
|
||||
#include "varlink-io.systemd.Service.h"
|
||||
|
||||
static SD_VARLINK_DEFINE_METHOD(Ping);
|
||||
|
||||
@ -14,8 +14,8 @@ static SD_VARLINK_DEFINE_METHOD(
|
||||
SD_VARLINK_DEFINE_INPUT(level, SD_VARLINK_INT, 0));
|
||||
|
||||
SD_VARLINK_DEFINE_INTERFACE(
|
||||
io_systemd_service,
|
||||
"io.systemd.service",
|
||||
io_systemd_Service,
|
||||
"io.systemd.Service",
|
||||
&vl_method_Ping,
|
||||
&vl_method_Reload,
|
||||
&vl_method_SetLogLevel);
|
||||
@ -26,23 +26,21 @@ int varlink_method_ping(sd_varlink *link, sd_json_variant *parameters, sd_varlin
|
||||
if (sd_json_variant_elements(parameters) > 0)
|
||||
return sd_varlink_error_invalid_parameter(link, parameters);
|
||||
|
||||
log_debug("Received io.systemd.service.Ping");
|
||||
log_debug("Received io.systemd.Service.Ping");
|
||||
|
||||
return sd_varlink_reply(link, NULL);
|
||||
}
|
||||
|
||||
int varlink_method_set_log_level(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
|
||||
int varlink_dispatch_set_log_level(sd_varlink *link, sd_json_variant *parameters, int *ret_log_level) {
|
||||
static const sd_json_dispatch_field dispatch_table[] = {
|
||||
{ "level", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_int64, 0, SD_JSON_MANDATORY },
|
||||
{ "level", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_int, 0, SD_JSON_MANDATORY },
|
||||
{}
|
||||
};
|
||||
|
||||
int64_t level;
|
||||
uid_t uid;
|
||||
int r;
|
||||
int r, level;
|
||||
|
||||
assert(link);
|
||||
assert(parameters);
|
||||
assert(ret_log_level);
|
||||
|
||||
/* NOTE: The method does have 1 parameter, but we must compare to 2 here, because
|
||||
* sd_json_variant_elements() breaks abstraction and exposes internal structure of JsonObject. */
|
||||
@ -56,14 +54,28 @@ int varlink_method_set_log_level(sd_varlink *link, sd_json_variant *parameters,
|
||||
if (LOG_PRI(level) != level)
|
||||
return sd_varlink_error_invalid_parameter(link, parameters);
|
||||
|
||||
*ret_log_level = level;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int varlink_method_set_log_level(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
|
||||
int r, level;
|
||||
uid_t uid;
|
||||
|
||||
assert(link);
|
||||
|
||||
r = varlink_dispatch_set_log_level(link, parameters, &level);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_varlink_get_peer_uid(link, &uid);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (uid != getuid() && uid != 0)
|
||||
if (uid != 0 && uid != getuid())
|
||||
return sd_varlink_error(link, SD_VARLINK_ERROR_PERMISSION_DENIED, parameters);
|
||||
|
||||
log_debug("Received io.systemd.service.SetLogLevel(%" PRIi64 ")", level);
|
||||
log_debug("Received io.systemd.Service.SetLogLevel(%i)", level);
|
||||
|
||||
log_set_max_level(level);
|
||||
|
@ -4,7 +4,8 @@
|
||||
#include "sd-varlink.h"
|
||||
#include "sd-varlink-idl.h"
|
||||
|
||||
extern const sd_varlink_interface vl_interface_io_systemd_service;
|
||||
extern const sd_varlink_interface vl_interface_io_systemd_Service;
|
||||
|
||||
int varlink_method_ping(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata);
|
||||
int varlink_dispatch_set_log_level(sd_varlink *link, sd_json_variant *parameters, int *ret_log_level);
|
||||
int varlink_method_set_log_level(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata);
|
@ -24,9 +24,9 @@
|
||||
#include "varlink-io.systemd.PCRLock.h"
|
||||
#include "varlink-io.systemd.Resolve.h"
|
||||
#include "varlink-io.systemd.Resolve.Monitor.h"
|
||||
#include "varlink-io.systemd.Service.h"
|
||||
#include "varlink-io.systemd.UserDatabase.h"
|
||||
#include "varlink-io.systemd.oom.h"
|
||||
#include "varlink-io.systemd.service.h"
|
||||
#include "varlink-io.systemd.sysext.h"
|
||||
#include "varlink-org.varlink.service.h"
|
||||
#include "varlink-util.h"
|
||||
@ -180,7 +180,7 @@ TEST(parse_format) {
|
||||
print_separator();
|
||||
test_parse_format_one(&vl_interface_io_systemd_PCRLock);
|
||||
print_separator();
|
||||
test_parse_format_one(&vl_interface_io_systemd_service);
|
||||
test_parse_format_one(&vl_interface_io_systemd_Service);
|
||||
print_separator();
|
||||
test_parse_format_one(&vl_interface_io_systemd_sysext);
|
||||
print_separator();
|
||||
|
Loading…
Reference in New Issue
Block a user