[systemd-devel] [PATCH] util: preserve get_process_capeff behavior

Shawn Landden shawn at churchofgit.com
Tue Sep 17 15:48:46 PDT 2013


69ab80881552d5f79ca95f6b3be48ad122ab1ec2 tried to unify
parsing of status files, but removed the logic of skipping
extra '0's when getting the effective capabilities. Restore
that logic.
---
 src/shared/util.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/shared/util.c b/src/shared/util.c
index bf31511..b68f15c 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -694,7 +694,8 @@ int is_kernel_thread(pid_t pid) {
 }
 
 int get_process_capeff(pid_t pid, char **capeff) {
-        const char *p;
+        const char *p, *t;
+        int r;
 
         assert(capeff);
         assert(pid >= 0);
@@ -704,7 +705,18 @@ int get_process_capeff(pid_t pid, char **capeff) {
         else
                 p = procfs_file_alloca(pid, "status");
 
-        return get_status_field(p, "\nCapEff:", capeff);
+        r = get_status_field(p, "\nCapEff:", capeff);
+
+        for (t = *capeff; t[0] == '0'; t++)
+                continue;
+
+        if (t[0] == '\0')
+                t--;
+
+        if (t != *capeff)
+                memmove(*capeff, t, strlen(t) + 1);
+
+        return r;
 }
 
 int get_process_exe(pid_t pid, char **name) {
-- 
1.8.4.rc3



More information about the systemd-devel mailing list