[systemd-devel] [PATCH 2/2] Run with a custom SMACK domain (label).
Lennart Poettering
lennart at poettering.net
Tue Oct 1 16:42:19 PDT 2013
On Tue, 01.10.13 16:11, Auke Kok (auke-jan.h.kok at intel.com) wrote:
> index 1434dea..d7b8dce 100644
> --- a/src/core/smack-setup.c
> +++ b/src/core/smack-setup.c
> @@ -36,6 +36,7 @@
> #include "macro.h"
> #include "smack-setup.h"
> #include "util.h"
> +#include "fileio.h"
> #include "log.h"
> #include "label.h"
>
> @@ -138,6 +139,12 @@ int smack_setup(void) {
> return 0;
> }
>
> +#ifdef SMACK_RUN_LABEL
> + if (write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL))
> + log_warning("Failed to set SMACK label \"%s\" on self: %s",
> + SMACK_RUN_LABEL, strerror(abs(r)));
> +#endif
Looks got in principle, but error handling is borked. You need to assign
r first before you print it. Also, write_string_file returns negative
errno, so you should just strerror(-r) instead of strerror(abs(r)).
Lennart
--
Lennart Poettering - Red Hat, Inc.
More information about the systemd-devel
mailing list