chiark / gitweb /
util: restore get_process_capeff behaviour
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 17 Sep 2013 23:34:47 +0000 (18:34 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 17 Sep 2013 23:37:32 +0000 (18:37 -0500)
69ab8088 unified parsing of status files and removed the logic of
skipping extra '0's when getting the effective capabilities. Restore
that logic, so that the same capabilities are always mapped to the
same strings in the journal.

src/shared/fileio.c

index 4e2b4442db1fb8756ff52cd8cdbf0e2098da848d..23bc742e75ad71c0674d3345cf580aa0fb693331 100644 (file)
@@ -650,9 +650,9 @@ int executable_is_script(const char *path, char **interpreter) {
 }
 
 /**
 }
 
 /**
- * Retrieve one field from a file like /proc/self/status.
- * pattern should start with '\n' and end with ':'. Whitespace
- * after ':' will be skipped. field must be freed afterwards.
+ * Retrieve one field from a file like /proc/self/status.  pattern
+ * should start with '\n' and end with a ':'. Whitespace and zeros
+ * after the ':' will be skipped. field must be freed afterwards.
  */
 int get_status_field(const char *filename, const char *pattern, char **field) {
         _cleanup_free_ char *status = NULL;
  */
 int get_status_field(const char *filename, const char *pattern, char **field) {
         _cleanup_free_ char *status = NULL;
@@ -672,7 +672,12 @@ int get_status_field(const char *filename, const char *pattern, char **field) {
                 return -ENOENT;
 
         t += strlen(pattern);
                 return -ENOENT;
 
         t += strlen(pattern);
-        t += strspn(t, WHITESPACE);
+        /* Also skip zeros, because when this is used for capabilities,
+         * we don't want the zeros. This way the same cabality set
+         * 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");
 
         len = strcspn(t, WHITESPACE);
 
 
         len = strcspn(t, WHITESPACE);