]> Kevux Git Server - fll/commitdiff
Bugfix: recently added capability functions are from newer version.
authorKevin Day <thekevinday@gmail.com>
Thu, 18 Mar 2021 23:43:12 +0000 (18:43 -0500)
committerKevin Day <thekevinday@gmail.com>
Thu, 18 Mar 2021 23:43:12 +0000 (18:43 -0500)
The libcap project hasn't been updated in a long time.
Apparently, somebody relatively recently picked up the project and started maintaining it.
This introduced newer functions.

For some reason, my system has a hybrid of this.
The headers show the newer functions but the libraries lack them.

Add a new define "_libcap_legacy_only_".
Enable this by default given how long libcap has exist unchanged.

I also noticed and inconsistency with the function names for users and groups (which are newer functions).
Rename them to not include the "_id".
Remove a duplicate function that didn't even have a reference in the header (oops!).

build/level_0/settings
build/monolithic/settings
level_0/f_capability/c/capability.c
level_0/f_capability/c/capability.h
level_0/f_capability/data/build/defines
level_0/f_capability/data/build/settings

index d07decb1bfee35836ec7a4f5ca2a340819d1d791..b5e93a642b01e5757bab40d0e191eec67128fa3d 100644 (file)
@@ -46,7 +46,7 @@ search_shared yes
 search_static yes
 
 #defines_all -D_di_libcap_
-defines_all
+defines_all -D_libcap_legacy_only_
 defines_all-level_threadless -D_di_pthread_support_
 defines_static
 defines_shared
index 0dfe06208730b3103f79c40b39ace2005fb223e3..3ddf554365371b41c8e9c0a7de2fdbdfaafc115b 100644 (file)
@@ -46,7 +46,7 @@ search_shared yes
 search_static yes
 
 #defines_all -D_di_libcap_
-defines_all
+defines_all -D_libcap_legacy_only_
 defines_all-monolithic_threadless -D_di_pthread_support_
 defines_static
 defines_shared
index ca95b0693419ca5b7a59b94c8e08f0a343e6670e..271637eaa5456c318fa8036e75a156b91031d8ce 100644 (file)
@@ -4,7 +4,7 @@
 extern "C" {
 #endif
 
-#ifdef _di_libcap_
+#if defined(_di_libcap_) || defined(_libcap_legacy_only_)
 
   #ifndef _di_f_capability_ambient_get_
     f_status_t f_capability_ambient_get(const f_capability_value_t value, int *ambient) {
@@ -28,11 +28,9 @@ extern "C" {
     }
   #endif // _di_f_capability_ambient_set_
 
-  #ifndef _di_f_capability_groups_set_
-    f_status_t f_capability_groups_set(const gid_t id_group, const size_t total, const gid_t id_groups[]) {
-      return F_status_set_error(F_implemented_not);
-    }
-  #endif // _di_f_capability_groups_set_
+#endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+#ifdef _di_libcap_
 
   #ifndef _di_f_capability_clear_
     f_status_t f_capability_clear(f_capability_t *capability) {
@@ -177,11 +175,19 @@ extern "C" {
     }
   #endif // _di_f_capability_from_text_
 
-  #ifndef f_capability_groups_id_set
-    f_status_t f_capability_groups_id_set(const gid_t id_group, const size_t total, const gid_t id_groups[]) {
+#endif // _di_libcap_
+
+#if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+  #ifndef _di_f_capability_groups_set_
+    f_status_t f_capability_groups_set(const gid_t id_group, const size_t total, const gid_t id_groups[]) {
       return F_status_set_error(F_implemented_not);
     }
-  #endif // f_capability_groups_id_set
+  #endif // _di_f_capability_groups_set_
+
+#endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+#ifdef _di_libcap_
 
   #ifndef _di_f_capability_initialize_
     f_status_t f_capability_initialize(f_capability_t *capability) {
@@ -193,6 +199,10 @@ extern "C" {
     }
   #endif // _di_f_capability_initialize_
 
+#endif // _di_libcap_
+
+#if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
   #ifndef _di_f_capability_mode_get_
     f_status_t f_capability_mode_get(f_capability_mode_t *mode) {
       #ifndef _di_level_0_parameter_checking_
@@ -235,6 +245,10 @@ extern "C" {
     }
   #endif // _di_f_capability_owner_set_
 
+#endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+#ifdef _di_libcap_
+
   #ifndef _di_f_capability_process_bound_drop_
     f_status_t f_capability_process_bound_drop(f_capability_value_t code, int *bound) {
       #ifndef _di_level_0_parameter_checking_
@@ -281,6 +295,10 @@ extern "C" {
     }
   #endif // _di_f_capability_process_set_
 
+#endif // _di_libcap_
+
+#if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
   #ifndef _di_f_capability_security_bits_get_
     f_status_t f_capability_security_bits_get(f_capability_bits_t *bits) {
       #ifndef _di_level_0_parameter_checking_
@@ -297,6 +315,10 @@ extern "C" {
     }
   #endif // _di_f_capability_security_bits_set_
 
+#endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+#ifdef _di_libcap_
+
   #ifndef _di_f_capability_size_
     f_status_t f_capability_size(const f_capability_t capability, ssize_t *size) {
       #ifndef _di_level_0_parameter_checking_
@@ -313,12 +335,20 @@ extern "C" {
     }
   #endif // _di_f_capability_supported_
 
+#endif // _di_libcap_
+
+#if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
   #ifndef _di_f_capability_supported_ambient_
     bool f_capability_supported_ambient() {
       return F_false;
     }
   #endif // _di_f_capability_supported_ambient_
 
+#endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+#ifdef _di_libcap_
+
   #ifndef _di_f_capability_supported_code_
     bool f_capability_supported_code(const f_capability_value_t code) {
       return F_false;
@@ -345,13 +375,19 @@ extern "C" {
     }
   #endif // _di_f_capability_to_text_
 
-  #ifndef f_capability_user_id_set
-    f_status_t f_capability_user_id_set(const uid_t id_user) {
+#endif // _di_libcap_
+
+#if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+  #ifndef f_capability_user_set
+    f_status_t f_capability_user_set(const uid_t id_user) {
       return F_status_set_error(F_implemented_not);
     }
-  #endif // f_capability_user_id_set
+  #endif // f_capability_user_set
+
+#endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
 
-#else // _di_libcap_
+#if !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
 
   #ifndef _di_f_capability_ambient_get_
     f_status_t f_capability_ambient_get(const f_capability_value_t value, int *ambient) {
@@ -403,20 +439,9 @@ extern "C" {
     }
   #endif // _di_f_capability_ambient_set_
 
-  #ifndef _di_f_capability_groups_set_
-    f_status_t f_capability_groups_set(const gid_t id_group, const size_t total, const gid_t id_groups[]) {
+#endif // !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
 
-      if (cap_setgroups(id_group, total, id_groups) == -1) {
-        if (errno == EINVAL) return F_status_set_error(F_parameter);
-        if (errno == ENOMEM) return F_status_set_error(F_memory_not);
-        if (errno == ERANGE) return F_status_set_error(F_range_not);
-
-        return F_status_set_error(F_failure);
-      }
-
-      return F_none;
-    }
-  #endif // _di_f_capability_groups_set_
+#ifndef _di_libcap_
 
   #ifndef _di_f_capability_clear_
     f_status_t f_capability_clear(f_capability_t *capability) {
@@ -721,20 +746,28 @@ extern "C" {
     }
   #endif // _di_f_capability_from_text_
 
-  #ifndef f_capability_groups_id_set
-    f_status_t f_capability_groups_id_set(const gid_t id_group, const size_t total, const gid_t id_groups[]) {
+#endif // _di_libcap_
+
+#if !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+
+  #ifndef _di_f_capability_groups_set_
+    f_status_t f_capability_groups_set(const gid_t id_group, const size_t total, const gid_t id_groups[]) {
 
       if (cap_setgroups(id_group, total, id_groups) == -1) {
         if (errno == EINVAL) return F_status_set_error(F_parameter);
         if (errno == ENOMEM) return F_status_set_error(F_memory_not);
-        if (errno == EPERM) return F_status_set_error(F_prohibited);
+        if (errno == ERANGE) return F_status_set_error(F_range_not);
 
         return F_status_set_error(F_failure);
       }
 
       return F_none;
     }
-  #endif // f_capability_groups_id_set
+  #endif // _di_f_capability_groups_set_
+
+#endif // !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+
+#ifndef _di_libcap_
 
   #ifndef _di_f_capability_initialize_
     f_status_t f_capability_initialize(f_capability_t *capability) {
@@ -755,6 +788,10 @@ extern "C" {
     }
   #endif // _di_f_capability_initialize_
 
+#endif // _di_libcap_
+
+#if !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+
   #ifndef _di_f_capability_mode_get_
     f_status_t f_capability_mode_get(f_capability_mode_t *mode) {
       #ifndef _di_level_0_parameter_checking_
@@ -827,6 +864,10 @@ extern "C" {
     }
   #endif // _di_f_capability_owner_set_
 
+#endif // !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+
+#ifndef _di_libcap_
+
   #ifndef _di_f_capability_process_bound_drop_
     f_status_t f_capability_process_bound_drop(f_capability_value_t code, int *bound) {
       #ifndef _di_level_0_parameter_checking_
@@ -913,6 +954,10 @@ extern "C" {
     }
   #endif // _di_f_capability_process_set_
 
+#endif // _di_libcap_
+
+#if !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+
   #ifndef _di_f_capability_security_bits_get_
     f_status_t f_capability_security_bits_get(f_capability_bits_t *bits) {
       #ifndef _di_level_0_parameter_checking_
@@ -940,6 +985,10 @@ extern "C" {
     }
   #endif // _di_f_capability_security_bits_set_
 
+#endif // !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+
+#ifndef _di_libcap_
+
   #ifndef _di_f_capability_size_
     f_status_t f_capability_size(const f_capability_t capability, ssize_t *size) {
       #ifndef _di_level_0_parameter_checking_
@@ -966,12 +1015,20 @@ extern "C" {
     }
   #endif // _di_f_capability_supported_
 
+#endif // _di_libcap_
+
+#if !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+
   #ifndef _di_f_capability_supported_ambient_
     bool f_capability_supported_ambient() {
       return CAP_AMBIENT_SUPPORTED();
     }
   #endif // _di_f_capability_supported_ambient_
 
+#endif // !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+
+#ifndef _di_libcap_
+
   #ifndef _di_f_capability_supported_code_
     bool f_capability_supported_code(const f_capability_value_t code) {
       return CAP_IS_SUPPORTED(code);
@@ -1060,8 +1117,12 @@ extern "C" {
     }
   #endif // _di_f_capability_to_text_
 
-  #ifndef _di_f_capability_user_id_set_
-    f_status_t f_capability_user_id_set(const uid_t id_user) {
+#endif // _di_libcap_
+
+#if !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+
+  #ifndef _di_f_capability_user_set_
+    f_status_t f_capability_user_set(const uid_t id_user) {
 
       if (cap_setuid(id_user) == -1) {
         if (errno == EINVAL) return F_status_set_error(F_parameter);
@@ -1073,9 +1134,9 @@ extern "C" {
 
       return F_none;
     }
-  #endif // _di_f_capability_user_id_set_
+  #endif // _di_f_capability_user_set_
 
-#endif // _di_libcap_
+#endif // !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
 
 #ifdef __cplusplus
 } // extern "C"
index 57581a2c423fbb1deab50724de29c4f94a3ba2a6..dbf10ff6fa17f81f4890158cb4bbc7e371c3f38a 100644 (file)
@@ -990,9 +990,9 @@ extern "C" {
  * @see cap_setuid()
  * @see setuid()
  */
-#ifndef _di_f_capability_user_id_set_
-  extern f_status_t f_capability_user_id_set(const uid_t id_user);
-#endif // _di_f_capability_user_id_set_
+#ifndef _di_f_capability_user_set_
+  extern f_status_t f_capability_user_set(const uid_t id_user);
+#endif // _di_f_capability_user_set_
 
 #ifdef __cplusplus
 } // extern "C"
index 0d51e58b11d0524b41652c03ac29f8aeb171233e..8be394feb895daf9c8c805ee8f6719562de9f123 100644 (file)
@@ -1,3 +1,3 @@
 # fss-0000
 _di_libcap_ Disable libcap support, allow for compiling and linking without libcap (-lcap).
-
+_libcap_legacy_only_ Disable functionality provided by later versions of libcap (2.43 and later).
index 045068224ead66a194ac6effdd2671b1ec834bd3..6a6fb175e763febef1bf6b0ac9c1fddc48f4a0b7 100644 (file)
@@ -45,7 +45,7 @@ search_shared yes
 search_static yes
 
 #defines_all -D_di_libcap_
-defines_all
+defines_all -D_libcap_legacy_only_
 defines_static
 defines_shared