[systemd-commits] 3 commits - src/shared
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Wed Sep 18 09:46:22 PDT 2013
src/shared/fileio.c | 8 +++++++-
src/shared/logs-show.c | 2 +-
src/shared/polkit.c | 31 +++++--------------------------
3 files changed, 13 insertions(+), 28 deletions(-)
New commits:
commit 4ec29144ddc311d78baa6875631ed6968fd90817
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Wed Sep 18 11:39:32 2013 -0500
Fix capability logging when effective caps are 0
Shawn Landen> Doesn't this also skip the last '0' when it is all '0's?
You need to keep the last one.
diff --git a/src/shared/fileio.c b/src/shared/fileio.c
index 23bc742..8aa4cdb 100644
--- a/src/shared/fileio.c
+++ b/src/shared/fileio.c
@@ -677,7 +677,13 @@ int get_status_field(const char *filename, const char *pattern, char **field) {
* always maps to the same string, irrespective of the total
* capability set size. For other numbers it shouldn't matter.
*/
- t += strspn(t, WHITESPACE "0");
+ if (*t) {
+ t += strspn(t, WHITESPACE "0");
+ /* Back off one char if there's nothing but whitespace
+ and zeros */
+ if (!*t)
+ t --;
+ }
len = strcspn(t, WHITESPACE);
commit 72fd713962ca2c2450e23b01d9e22017a7e28fd4
Author: Colin Walters <walters at verbum.org>
Date: Thu Aug 22 13:55:21 2013 -0400
polkit: Avoid race condition in scraping /proc
If a calling process execve()s a setuid program, it can appear to be
uid 0. Since we're receiving requests over DBus, avoid this by simply
passing system-bus-name as a subject.
diff --git a/src/shared/polkit.c b/src/shared/polkit.c
index cea7074..1c5e9e3 100644
--- a/src/shared/polkit.c
+++ b/src/shared/polkit.c
@@ -38,12 +38,8 @@ int verify_polkit(
#ifdef ENABLE_POLKIT
DBusMessage *m = NULL, *reply = NULL;
- const char *unix_process = "unix-process", *pid = "pid", *starttime = "start-time", *cancel_id = "";
+ const char *system_bus_name = "system-bus-name", *name = "name", *cancel_id = "";
uint32_t flags = interactive ? 1 : 0;
- pid_t pid_raw;
- uint32_t pid_u32;
- unsigned long long starttime_raw;
- uint64_t starttime_u64;
DBusMessageIter iter_msg, iter_struct, iter_array, iter_dict, iter_variant;
int r;
dbus_bool_t authorized = FALSE, challenge = FALSE;
@@ -68,14 +64,6 @@ int verify_polkit(
#ifdef ENABLE_POLKIT
- pid_raw = bus_get_unix_process_id(c, sender, error);
- if (pid_raw == 0)
- return -EINVAL;
-
- r = get_starttime_of_pid(pid_raw, &starttime_raw);
- if (r < 0)
- return r;
-
m = dbus_message_new_method_call(
"org.freedesktop.PolicyKit1",
"/org/freedesktop/PolicyKit1/Authority",
@@ -86,22 +74,13 @@ int verify_polkit(
dbus_message_iter_init_append(m, &iter_msg);
- pid_u32 = (uint32_t) pid_raw;
- starttime_u64 = (uint64_t) starttime_raw;
-
if (!dbus_message_iter_open_container(&iter_msg, DBUS_TYPE_STRUCT, NULL, &iter_struct) ||
- !dbus_message_iter_append_basic(&iter_struct, DBUS_TYPE_STRING, &unix_process) ||
+ !dbus_message_iter_append_basic(&iter_struct, DBUS_TYPE_STRING, &system_bus_name) ||
!dbus_message_iter_open_container(&iter_struct, DBUS_TYPE_ARRAY, "{sv}", &iter_array) ||
!dbus_message_iter_open_container(&iter_array, DBUS_TYPE_DICT_ENTRY, NULL, &iter_dict) ||
- !dbus_message_iter_append_basic(&iter_dict, DBUS_TYPE_STRING, &pid) ||
- !dbus_message_iter_open_container(&iter_dict, DBUS_TYPE_VARIANT, "u", &iter_variant) ||
- !dbus_message_iter_append_basic(&iter_variant, DBUS_TYPE_UINT32, &pid_u32) ||
- !dbus_message_iter_close_container(&iter_dict, &iter_variant) ||
- !dbus_message_iter_close_container(&iter_array, &iter_dict) ||
- !dbus_message_iter_open_container(&iter_array, DBUS_TYPE_DICT_ENTRY, NULL, &iter_dict) ||
- !dbus_message_iter_append_basic(&iter_dict, DBUS_TYPE_STRING, &starttime) ||
- !dbus_message_iter_open_container(&iter_dict, DBUS_TYPE_VARIANT, "t", &iter_variant) ||
- !dbus_message_iter_append_basic(&iter_variant, DBUS_TYPE_UINT64, &starttime_u64) ||
+ !dbus_message_iter_append_basic(&iter_dict, DBUS_TYPE_STRING, &name) ||
+ !dbus_message_iter_open_container(&iter_dict, DBUS_TYPE_VARIANT, "s", &iter_variant) ||
+ !dbus_message_iter_append_basic(&iter_variant, DBUS_TYPE_STRING, &sender) ||
!dbus_message_iter_close_container(&iter_dict, &iter_variant) ||
!dbus_message_iter_close_container(&iter_array, &iter_dict) ||
!dbus_message_iter_close_container(&iter_struct, &iter_array) ||
commit 00f117a59973f9c4e1a966252d668949f62a9265
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Wed Sep 18 08:36:27 2013 -0500
logs-show.c: fix enum type in function declaration
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index f50777c..2dd5025 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -105,7 +105,7 @@ static bool shall_print(const char *p, size_t l, OutputFlags flags) {
return true;
}
-static bool print_multiline(FILE *f, unsigned prefix, unsigned n_columns, OutputMode flags, int priority, const char* message, size_t message_len) {
+static bool print_multiline(FILE *f, unsigned prefix, unsigned n_columns, OutputFlags flags, int priority, const char* message, size_t message_len) {
const char *color_on = "", *color_off = "";
const char *pos, *end;
bool ellipsized = false;
More information about the systemd-commits
mailing list