]> err.no Git - systemd/commitdiff
Merge branch 'master' into journal
authorLennart Poettering <lennart@poettering.net>
Wed, 12 Oct 2011 02:29:11 +0000 (04:29 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 12 Oct 2011 02:29:11 +0000 (04:29 +0200)
1  2 
Makefile.am
src/util.c
src/util.h

diff --cc Makefile.am
Simple merge
diff --cc src/util.c
index a3cfe864b6e44c5cf38e04c7c0a18386be0364e4,e93e6f6cf5c962e90ac7b8a4a29cc8cfe00a80ce..26c2f22ff0c77c5f6416fac0c51b8f41d2065743
@@@ -5883,20 -5704,35 +5886,52 @@@ int strdup_or_null(const char *a, char 
          return 0;
  }
  
 +int prot_from_flags(int flags) {
 +
 +        switch (flags & O_ACCMODE) {
 +
 +        case O_RDONLY:
 +                return PROT_READ;
 +
 +        case O_WRONLY:
 +                return PROT_WRITE;
 +
 +        case O_RDWR:
 +                return PROT_READ|PROT_WRITE;
 +
 +        default:
 +                return -EINVAL;
 +        }
++
+ unsigned long cap_last_cap(void) {
+         static __thread unsigned long saved;
+         static __thread bool valid = false;
+         unsigned long p;
+         if (valid)
+                 return saved;
+         p = (unsigned long) CAP_LAST_CAP;
+         if (prctl(PR_CAPBSET_READ, p) < 0) {
+                 /* Hmm, look downwards, until we find one that
+                  * works */
+                 for (p--; p > 0; p --)
+                         if (prctl(PR_CAPBSET_READ, p) >= 0)
+                                 break;
+         } else {
+                 /* Hmm, look upwards, until we find one that doesn't
+                  * work */
+                 for (;; p++)
+                         if (prctl(PR_CAPBSET_READ, p+1) < 0)
+                                 break;
+         }
+         saved = p;
+         valid = true;
+         return p;
  }
diff --cc src/util.h
index 89a7bec61280c89171ab9eda0a5b9e145c0190db,a71a297eab6b56740efe070d3473dd3118b183f3..1db82f83e0a4ba7d2b2588d1c996507dbc99ed83
@@@ -513,6 -506,6 +513,8 @@@ extern char **saved_argv
  
  bool kexec_loaded(void);
  
 +int prot_from_flags(int flags);
 +
+ unsigned long cap_last_cap(void);
  #endif