smack-team/smack — pull request #99 by rafal-krypa (2014-03-13 17:43:06+00:00)
Title: Libsmack doesn't provide system policy loading functions

Systemd currently itself handles mounting of smackfs and loading of the policy. If the systemd developers wished to use libsmack functions instead, the wouldn't have appropriate API exported. I suggest exporting of some functionality from `utils/common.c` as libsmack interface to make it usable from programs like systemd.

To compare, for SELinux policy loading systemd uses the following function from libselinux:

```C
/*.
* Perform the initial policy load.
* This function determines the desired enforcing mode, sets the
* the *enforce argument accordingly for the caller to use, sets the.
* SELinux kernel enforcing status to match it, and loads the policy.
* It also internally handles the initial selinuxfs mount required to
* perform these actions.
*
* The function returns 0 if everything including the policy load succeeds.
* In this case, init is expected to re-exec itself in order to transition
* to the proper security context.
* Otherwise, the function returns -1, and init must check *enforce to
* determine how to proceed. If enforcing (*enforce > 0), then init should
* halt the system. Otherwise, init may proceed normally without a re-exec.
*/
extern int selinux_init_load_policy(int *enforce);
```