chiark / gitweb /
Classify processes from sessions into cgroups
[elogind.git] / src / shared / capability.c
index 915ceb9d9b1a4749206bebb638a971f7dcac156c..8dbe4da5bbbe1280518e81bca9af166549f06bf1 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <assert.h>
-#include <string.h>
 #include <unistd.h>
 #include <errno.h>
 #include <stdio.h>
-#include <sys/types.h>
-#include <stdarg.h>
-#include <ctype.h>
 #include <sys/capability.h>
 #include <sys/prctl.h>
 #include "grp.h"
@@ -55,7 +50,7 @@ unsigned long cap_last_cap(void) {
         static thread_local unsigned long saved;
         static thread_local bool valid = false;
         _cleanup_free_ char *content = NULL;
-        unsigned long p;
+        unsigned long p = 0;
         int r;
 
         if (valid)
@@ -209,7 +204,7 @@ static int drop_from_file(const char *fn, uint64_t drop) {
         if (asprintf(&p, "%u %u", lo, hi) < 0)
                 return -ENOMEM;
 
-        r = write_string_file(fn, p);
+        r = write_string_file(fn, p, WRITE_STRING_FILE_CREATE);
         free(p);
 
         return r;