xref: /freebsd-src/sys/compat/linuxkpi/common/include/linux/capability.h (revision 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
1f9c8b588SVladimir Kondratyev /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3f9c8b588SVladimir Kondratyev  *
4f9c8b588SVladimir Kondratyev  * Copyright (c) 2015 Rimvydas Jasinskas
5f9c8b588SVladimir Kondratyev  * All rights reserved.
6f9c8b588SVladimir Kondratyev  *
7f9c8b588SVladimir Kondratyev  * Redistribution and use in source and binary forms, with or without
8f9c8b588SVladimir Kondratyev  * modification, are permitted provided that the following conditions
9f9c8b588SVladimir Kondratyev  * are met:
10f9c8b588SVladimir Kondratyev  * 1. Redistributions of source code must retain the above copyright
11f9c8b588SVladimir Kondratyev  *    notice unmodified, this list of conditions, and the following
12f9c8b588SVladimir Kondratyev  *    disclaimer.
13f9c8b588SVladimir Kondratyev  * 2. Redistributions in binary form must reproduce the above copyright
14f9c8b588SVladimir Kondratyev  *    notice, this list of conditions and the following disclaimer in the
15f9c8b588SVladimir Kondratyev  *    documentation and/or other materials provided with the distribution.
16f9c8b588SVladimir Kondratyev  *
17f9c8b588SVladimir Kondratyev  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18f9c8b588SVladimir Kondratyev  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19f9c8b588SVladimir Kondratyev  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20f9c8b588SVladimir Kondratyev  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21f9c8b588SVladimir Kondratyev  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22f9c8b588SVladimir Kondratyev  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23f9c8b588SVladimir Kondratyev  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24f9c8b588SVladimir Kondratyev  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25f9c8b588SVladimir Kondratyev  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26f9c8b588SVladimir Kondratyev  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27f9c8b588SVladimir Kondratyev  */
28f9c8b588SVladimir Kondratyev 
29f9c8b588SVladimir Kondratyev /*
30f9c8b588SVladimir Kondratyev  * linux/capability.h
31f9c8b588SVladimir Kondratyev  *
32f9c8b588SVladimir Kondratyev  * Simple capable() priv_check helper
33f9c8b588SVladimir Kondratyev  */
34f9c8b588SVladimir Kondratyev 
35307f78f3SVladimir Kondratyev #ifndef _LINUXKPI_LINUX_CAPABILITY_H
36307f78f3SVladimir Kondratyev #define	_LINUXKPI_LINUX_CAPABILITY_H
37f9c8b588SVladimir Kondratyev 
38f9c8b588SVladimir Kondratyev #include <sys/types.h>
39f9c8b588SVladimir Kondratyev #include <sys/proc.h>
40f9c8b588SVladimir Kondratyev #include <sys/priv.h>
41f9c8b588SVladimir Kondratyev 
42f9c8b588SVladimir Kondratyev #define	CAP_SYS_ADMIN		PRIV_DRIVER
43f9c8b588SVladimir Kondratyev #define	CAP_SYS_NICE		PRIV_SCHED_SETPRIORITY
44f9c8b588SVladimir Kondratyev 
45f9c8b588SVladimir Kondratyev static inline bool
capable(const int tryme)46f9c8b588SVladimir Kondratyev capable(const int tryme)
47f9c8b588SVladimir Kondratyev {
48f9c8b588SVladimir Kondratyev 	return (priv_check(curthread, tryme) == 0);
49f9c8b588SVladimir Kondratyev }
50f9c8b588SVladimir Kondratyev 
51307f78f3SVladimir Kondratyev #endif /* _LINUXKPI_LINUX_CAPABILITY_H */
52