X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Fselinux.c;h=2db05ee8ecb513f0eb6c43e634885ea509f91d22;hp=ad5eaa15fb1f4f9d27f14a2ae4f88c4c0b3c7f85;hb=9ba779ea367b2ea7077da7bdd75e813cd06c7eea;hpb=84fc760439e82e6b3616abd0d1f9bd7d7eb01ec0 diff --git a/daemon/selinux.c b/daemon/selinux.c index ad5eaa1..2db05ee 100644 --- a/daemon/selinux.c +++ b/daemon/selinux.c @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include @@ -26,11 +26,24 @@ #include #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 @@ -39,7 +52,7 @@ 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; @@ -47,15 +60,14 @@ do_setcon (const char *context) 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; @@ -73,9 +85,6 @@ do_getcon (void) return r; /* caller frees */ #else - reply_with_error ("%s is not available", __func__); - return -1; + NOT_AVAILABLE (NULL); #endif } - -#endif /* HAVE_LIBSELINUX */