2012-09-07 00:23:11 +04:00
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2012-10-03 01:07:00 +04:00
# pragma once
2012-09-07 00:23:11 +04:00
/***
This file is part of systemd .
Copyright 2012 Dan Walsh
systemd is free software ; you can redistribute it and / or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
systemd is distributed in the hope that it will be useful , but
WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
General Public License for more details .
You should have received a copy of the GNU General Public License
along with systemd ; If not , see < http : //www.gnu.org/licenses/>.
* * */
2012-10-03 01:56:54 +04:00
# include <dbus.h>
void selinux_access_free ( void ) ;
int selinux_access_check ( DBusConnection * connection , DBusMessage * message , const char * path , const char * permission , DBusError * error ) ;
2012-10-03 01:07:00 +04:00
# ifdef HAVE_SELINUX
2012-10-03 01:56:54 +04:00
# define SELINUX_ACCESS_CHECK(connection, message, permission) \
2012-10-03 01:07:00 +04:00
do { \
DBusError _error ; \
int _r ; \
DBusConnection * _c = ( connection ) ; \
DBusMessage * _m = ( message ) ; \
dbus_error_init ( & _error ) ; \
2012-10-03 01:56:54 +04:00
_r = selinux_access_check ( _c , _m , NULL , ( permission ) , & _error ) ; \
2012-10-03 01:07:00 +04:00
if ( _r < 0 ) \
return bus_send_error_reply ( _c , _m , & _error , _r ) ; \
} while ( false )
# define SELINUX_UNIT_ACCESS_CHECK(unit, connection, message, permission) \
do { \
DBusError _error ; \
int _r ; \
DBusConnection * _c = ( connection ) ; \
DBusMessage * _m = ( message ) ; \
2012-10-03 01:56:54 +04:00
Unit * _u = ( unit ) ; \
2012-10-03 01:07:00 +04:00
dbus_error_init ( & _error ) ; \
2012-10-03 01:56:54 +04:00
_r = selinux_access_check ( _c , _m , _u - > source_path ? : _u - > fragment_path , ( permission ) , & _error ) ; \
2012-10-03 01:07:00 +04:00
if ( _r < 0 ) \
return bus_send_error_reply ( _c , _m , & _error , _r ) ; \
} while ( false )
# else
2012-10-03 01:56:54 +04:00
# define SELINUX_ACCESS_CHECK(connection, message, permission) do { } while (false)
2012-10-03 01:07:00 +04:00
# define SELINUX_UNIT_ACCESS_CHECK(unit, connection, message, permission) do { } while (false)
2012-09-07 00:23:11 +04:00
# endif