[systemd-commits] src/shared
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Tue Sep 17 16:38:02 PDT 2013
src/shared/fileio.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
New commits:
commit 0a7b53bdd2bb36c9543830c087954f184cd06535
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Tue Sep 17 18:34:47 2013 -0500
util: restore get_process_capeff behaviour
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.
diff --git a/src/shared/fileio.c b/src/shared/fileio.c
index 4e2b444..23bc742 100644
--- a/src/shared/fileio.c
+++ b/src/shared/fileio.c
@@ -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;
@@ -672,7 +672,12 @@ int get_status_field(const char *filename, const char *pattern, char **field) {
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);
More information about the systemd-commits
mailing list