#include <selinux/selinux.h>
#endif
-#include "../src/guestfs_protocol.h"
+#include "guestfs_protocol.h"
#include "daemon.h"
#include "actions.h"
+#include "optgroups.h"
-#ifdef HAVE_LIBSELINUX
+#if defined(HAVE_LIBSELINUX)
+int
+optgroup_selinux_available (void)
+{
+ return 1;
+}
+#else /* !HAVE_LIBSELINUX */
+int
+optgroup_selinux_available (void)
+{
+ return 0;
+}
+#endif /* !HAVE_LIBSELINUX */
/* setcon is only valid under the following circumstances:
* - single threaded
int
do_setcon (const char *context)
{
-#ifdef HAVE_SETCON
+#if defined(HAVE_LIBSELINUX) && defined(HAVE_SETCON)
if (setcon ((char *) context) == -1) {
reply_with_perror ("setcon");
return -1;
return 0;
#else
- reply_with_error ("%s is not available", __func__);
- return -1;
+ NOT_AVAILABLE (-1);
#endif
}
char *
do_getcon (void)
{
-#ifdef HAVE_GETCON
+#if defined(HAVE_LIBSELINUX) && defined(HAVE_GETCON)
security_context_t context;
char *r;
return r; /* caller frees */
#else
- reply_with_error ("%s is not available", __func__);
- return -1;
+ NOT_AVAILABLE (NULL);
#endif
}
-
-#endif /* HAVE_LIBSELINUX */