1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 10:51:20 +03:00

Revert "bus-proxyd: make policy checks optional"

This reverts commit 5bb24cccbc.

It does not even compile (unbalanced {)
This commit is contained in:
Michal Schmidt 2014-11-11 15:36:00 +01:00
parent 5bb24cccbc
commit 15e9297ebf

View File

@ -475,9 +475,6 @@ static int process_policy(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
assert(b); assert(b);
assert(m); assert(m);
if (!policy)
return 0;
if (b->is_kernel) { if (b->is_kernel) {
/* The message came from the kernel, and is sent to our legacy client. */ /* The message came from the kernel, and is sent to our legacy client. */
@ -852,7 +849,7 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
if (r < 0) if (r < 0)
return synthetic_reply_method_errno(m, r, NULL); return synthetic_reply_method_errno(m, r, NULL);
if (policy && !policy_check_own(policy, ucred, name)) if (!policy_check_own(policy, ucred, name))
return synthetic_reply_method_errno(m, -EPERM, NULL); return synthetic_reply_method_errno(m, -EPERM, NULL);
if (!service_name_is_valid(name)) if (!service_name_is_valid(name))
@ -1025,7 +1022,7 @@ static int process_hello(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *policy
return -EIO; return -EIO;
} }
if (policy && !policy_check_hello(policy, ucred)) { if (!policy_check_hello(policy, ucred)) {
log_error("Policy denied HELLO"); log_error("Policy denied HELLO");
return -EPERM; return -EPERM;
} }
@ -1136,7 +1133,6 @@ static int patch_sender(sd_bus *a, sd_bus_message *m) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
_cleanup_bus_creds_unref_ sd_bus_creds *bus_creds = NULL;
_cleanup_bus_close_unref_ sd_bus *a = NULL, *b = NULL; _cleanup_bus_close_unref_ sd_bus *a = NULL, *b = NULL;
sd_id128_t server_id; sd_id128_t server_id;
int r, in_fd, out_fd; int r, in_fd, out_fd;
@ -1255,12 +1251,6 @@ int main(int argc, char *argv[]) {
goto finish; goto finish;
} }
r = sd_bus_get_owner_creds(a, SD_BUS_CREDS_UID, &bus_creds);
if (r < 0) {
log_error("Failed to get bus creds: %s", strerror(-r));
goto finish;
}
r = sd_bus_new(&b); r = sd_bus_new(&b);
if (r < 0) { if (r < 0) {
log_error("Failed to allocate bus: %s", strerror(-r)); log_error("Failed to allocate bus: %s", strerror(-r));
@ -1420,21 +1410,13 @@ int main(int argc, char *argv[]) {
} }
if (m) { if (m) {
Policy *p = NULL;
uid_t uid;
assert_se(sd_bus_creds_get_uid(bus_creds, &uid) == 0);
if (uid == 0 || uid != ucred.uid)
p = &policy;
/* We officially got EOF, let's quit */ /* We officially got EOF, let's quit */
if (sd_bus_message_is_signal(m, "org.freedesktop.DBus.Local", "Disconnected")) { if (sd_bus_message_is_signal(m, "org.freedesktop.DBus.Local", "Disconnected")) {
r = 0; r = 0;
goto finish; goto finish;
} }
k = process_hello(a, b, m, p, &ucred, &got_hello); k = process_hello(a, b, m, &policy, &ucred, &got_hello);
if (k < 0) { if (k < 0) {
r = k; r = k;
log_error("Failed to process HELLO: %s", strerror(-r)); log_error("Failed to process HELLO: %s", strerror(-r));
@ -1444,7 +1426,7 @@ int main(int argc, char *argv[]) {
if (k > 0) if (k > 0)
r = k; r = k;
else { else {
k = process_driver(a, b, m, p, &ucred); k = process_driver(a, b, m, &policy, &ucred);
if (k < 0) { if (k < 0) {
r = k; r = k;
log_error("Failed to process driver calls: %s", strerror(-r)); log_error("Failed to process driver calls: %s", strerror(-r));
@ -1466,9 +1448,6 @@ int main(int argc, char *argv[]) {
if (k == -ECONNRESET) if (k == -ECONNRESET)
r = 0; r = 0;
else { else {
k = process_policy(a, b, m, p, &ucred);
if (k < 0) {
r = k; r = k;
log_error("Failed to send message: %s", strerror(-r)); log_error("Failed to send message: %s", strerror(-r));
} }