mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Write custom SWIG typemap for pid_t
Surprisingly, SWIG did not pick up the "typedef int pid_t" from the C headers. As such, we need to provide our own wrapper. We don't just replicate the typdef because we still support systems that have 16-bit PIDs. Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
This commit is contained in:
parent
2ce217b873
commit
d199c2ae33
1 changed files with 22 additions and 0 deletions
|
@ -276,6 +276,28 @@ extern int aa_stack_onexec(const char *profile);
|
|||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We can't use "typedef int pid_t" because we still support systems
|
||||
* with 16-bit PIDs and SWIG can't find sys/types.h
|
||||
*
|
||||
* Capture the passed-in value as an intmax_t because pid_t is guaranteed
|
||||
* to be a signed integer
|
||||
*/
|
||||
%typemap(in,noblock=1,fragment="SWIG_AsVal_long") pid_t (int conv_pid, intmax_t pid_large) {
|
||||
conv_pid = SWIG_AsVal_long($input, &pid_large);
|
||||
if (!SWIG_IsOK(conv_pid)) {
|
||||
%argument_fail(conv_pid, "pid_t", $symname, $argnum);
|
||||
}
|
||||
/*
|
||||
* Cast the long to a pid_t and then cast back to check for overflow
|
||||
* Technically this is implementation-defined behaviour but we should be fine
|
||||
*/
|
||||
$1 = (pid_t) pid_large;
|
||||
if ((intmax_t) $1 != pid_large) {
|
||||
SWIG_exception_fail(SWIG_OverflowError, "pid_t is too large");
|
||||
}
|
||||
}
|
||||
|
||||
extern int aa_find_mountpoint(char **mnt);
|
||||
extern int aa_getprocattr(pid_t tid, const char *attr, char **label, char **mode);
|
||||
extern int aa_gettaskcon(pid_t target, char **label, char **mode);
|
||||
|
|
Loading…
Add table
Reference in a new issue