}
#endif // _di_f_capability_clear_flag_
+ #ifndef _di_f_capability_compare_
+ f_status_t f_capability_compare(const f_capability_t capability1, const f_capability_t capability2, int *flags) {
+ return F_status_set_error(F_implemented_not);
+ }
+ #endif // _di_f_capability_compare_
+
#ifndef _di_f_capability_copy_
f_status_t f_capability_copy(const f_capability_t source, f_capability_t *destination) {
#ifndef _di_level_0_parameter_checking_
}
#endif // _di_f_capability_copy_
- #ifndef _di_f_capability_compare_
- f_status_t f_capability_compare(const f_capability_t capability1, const f_capability_t capability2, int *flags) {
- #ifndef _di_level_0_parameter_checking_
- if (!flags) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return F_status_set_error(F_implemented_not);
- }
- #endif // _di_f_capability_compare_
-
#ifndef _di_f_capability_copy_external_
f_status_t f_capability_copy_external(const f_capability_t capability, const ssize_t max, void *external, ssize_t *size) {
#ifndef _di_level_0_parameter_checking_
f_status_t f_capability_ambient_reset(void) {
if (cap_reset_ambient() == -1) {
+
// The documentation doesn't explicitly describe this for "reset" but it can be implicitly inferred because they say "..all of the setting functions..".
if (errno == EINVAL) return F_status_set_error(F_parameter);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
#ifndef _di_f_capability_ambient_set_
f_status_t f_capability_ambient_set(const f_capability_value_t value, const f_capability_flag_value_t value_flag) {
- #ifndef _di_level_0_parameter_checking_
- if (!value_flag) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
if (cap_set_ambient(value, value_flag) == -1) {
if (errno == EINVAL) return F_status_set_error(F_parameter);
}
#endif // _di_f_capability_clear_flag_
- #ifndef _di_f_capability_copy_
- f_status_t f_capability_copy(const f_capability_t source, f_capability_t *destination) {
- #ifndef _di_level_0_parameter_checking_
- if (!destination) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- *destination = cap_dup(source);
-
- if (*destination) {
- return F_none;
- }
-
- if (errno == EINVAL) return F_status_set_error(F_parameter);
- if (errno == ENOMEM) return F_status_set_error(F_memory_not);
-
- return F_status_set_error(F_failure);
- }
- #endif // _di_f_capability_copy_
-
#ifndef _di_f_capability_compare_
f_status_t f_capability_compare(const f_capability_t capability1, const f_capability_t capability2, int *flags) {
- if (*flags) {
+
+ if (flags) {
*flags = 0;
}
}
if (result) {
- if (*flags) {
+ if (flags) {
*flags = result;
}
}
#endif // _di_f_capability_compare_
+ #ifndef _di_f_capability_copy_
+ f_status_t f_capability_copy(const f_capability_t source, f_capability_t *destination) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!destination) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ *destination = cap_dup(source);
+
+ if (*destination) {
+ return F_none;
+ }
+
+ if (errno == EINVAL) return F_status_set_error(F_parameter);
+ if (errno == ENOMEM) return F_status_set_error(F_memory_not);
+
+ return F_status_set_error(F_failure);
+ }
+ #endif // _di_f_capability_copy_
+
#ifndef _di_f_capability_copy_external_
f_status_t f_capability_copy_external(const f_capability_t capability, const ssize_t max, void *external, ssize_t *size) {
#ifndef _di_level_0_parameter_checking_
if (!capability) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (cap_free(*capability) == -1) {
+ if (cap_free((void *) *capability) == -1) {
if (errno == EINVAL) return F_status_set_error(F_parameter);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
#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) {
+ f_status_t f_capability_process_bound_drop(f_capability_value_t value, int *bound) {
#ifndef _di_level_0_parameter_checking_
if (!bound) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- *bound = cap_drop_bound(code);
+ *bound = cap_drop_bound(value);
if (*bound == -1) {
if (errno == EINVAL) return F_status_set_error(F_parameter);
#endif // _di_f_capability_process_bound_drop_
#ifndef _di_f_capability_process_bound_get_
- f_status_t f_capability_process_bound_get(f_capability_value_t code, int *bound) {
+ f_status_t f_capability_process_bound_get(f_capability_value_t value, int *bound) {
#ifndef _di_level_0_parameter_checking_
if (!bound) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- *bound = cap_get_bound(code);
+ *bound = cap_get_bound(value);
if (*bound == -1) {
return F_status_set_error(F_known_not);
#ifndef _di_f_capability_supported_ambient_
bool f_capability_supported_ambient(void) {
- return CAP_AMBIENT_SUPPORTED();
+
+ if (CAP_AMBIENT_SUPPORTED()) {
+ return F_true;
+ }
+
+ return F_false;
}
#endif // _di_f_capability_supported_ambient_
#ifndef _di_f_capability_supported_code_
bool f_capability_supported_code(const f_capability_value_t code) {
- return CAP_IS_SUPPORTED(code);
+
+ if (CAP_IS_SUPPORTED(code)) {
+ return F_true;
+ }
+
+ return F_false;
}
#endif // _di_f_capability_supported_code_
#endif // _di_f_capability_clear_flag_
/**
- * Copy the capability structure.
- *
- * @param source
- * The capability to copy from.
- * @param destination
- * The capability to copy to.
- * This must be freed via f_capability_delete() when finished with.
- *
- * @return
- * F_none on success.
- *
- * F_implemented_not (with error bit) if this function is not available (due to not having libcap support compiled in).
- * F_memory_not (with error bit) if a out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * F_failure (with error bit) on any other failure.
- *
- * @see cap_dup()
- */
-#ifndef _di_f_capability_copy_
- extern f_status_t f_capability_copy(const f_capability_t source, f_capability_t *destination);
-#endif // _di_f_capability_copy_
-
-/**
* Compare two capability structures.
*
* @param capability1
#endif // _di_f_capability_compare_
/**
+ * Copy the capability structure.
+ *
+ * @param source
+ * The capability to copy from.
+ * @param destination
+ * The capability to copy to.
+ * This must be freed via f_capability_delete() when finished with.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_implemented_not (with error bit) if this function is not available (due to not having libcap support compiled in).
+ * F_memory_not (with error bit) if a out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * F_failure (with error bit) on any other failure.
+ *
+ * @see cap_dup()
+ */
+#ifndef _di_f_capability_copy_
+ extern f_status_t f_capability_copy(const f_capability_t source, f_capability_t *destination);
+#endif // _di_f_capability_copy_
+
+/**
* Copy an internally represented capability into an externally represented capability.
*
* @param capability
*
* @param capability
* The capability to delete.
+ * Pointer address is set to 0 on success.
*
* @return
* F_none on success.
*
* This will lower the specified bounding set capability if appropriate permission exist (the prevailing effective capability set must have a raised CAP_SETPCAP).
*
- * @param code
+ * @param value
* The capability code to get the bound for.
* @param bound
* The determined bound value.
* @see cap_drop_bound()
*/
#ifndef _di_f_capability_process_bound_drop_
- extern f_status_t f_capability_process_bound_drop(f_capability_value_t code, int *bound);
+ extern f_status_t f_capability_process_bound_drop(f_capability_value_t value, int *bound);
#endif // _di_f_capability_process_bound_drop_
/**
* Get the bound for the process.
*
- * @param code
+ * @param value
* The capability code to get the bound for.
* @param bound
* The determined bound value.
* @see cap_get_bound()
*/
#ifndef _di_f_capability_process_bound_get_
- extern f_status_t f_capability_process_bound_get(f_capability_value_t code, int *bound);
+ extern f_status_t f_capability_process_bound_get(f_capability_value_t value, int *bound);
#endif // _di_f_capability_process_bound_get_
/**
#endif
/**
- * Compiler-specific attribute visibility features.
+ * Compiler-specific attribute features.
*
* Use these macros for visibility-specific tweaks so that if these are not supported by any given compiler, then they can be easily disabled.
*
- * F_attribute_visibility_internal_d provides a way to make some functions effectively private.
+ * F_attribute_*:
+ * - visibility_hidden: Visibility is hidden.
+ * - visibility_internal: Visibility is private.
+ * - visibility_protected: Visibility is protected.
+ * - visibility_public: Visibility is public.
+ * - weak: Designate symbol is weak rather than global.
*/
-#ifndef _di_f_attribute_visibility_
+#ifndef _di_compiler_attributes_
#define F_attribute_visibility_hidden_d __attribute__((visibility("hidden")))
#define F_attribute_visibility_internal_d __attribute__((visibility("internal")))
#define F_attribute_visibility_protected_d __attribute__((visibility("protected")))
#define F_attribute_visibility_public_d __attribute__((visibility("default")))
-#endif // _di_f_attribute_visibility_
+
+ #define F_attribute_weak_d __attribute__((weak))
+#endif // _di_compiler_attributes_
/**
* A status intended to be used as the return value status of some function or operation.