selinux/libselinux/src/selinuxswig_ruby.i
Nicolas Iooss 581dde735a libselinux: remove rpm_execcon from SWIG wrappers
The Python wrapper of rpm_execcon() has several flaws:
* An invalid call like selinux.rpm_execcon() triggers a segmentation
  fault.
* The size of the buffer which is allocated to copy argv and envp is
  too small to hold all the values.
* This allocated memory is leaked if one argument of rpm_execon() is not
  a sequence of bytes.

The Ruby wrapper has no such flaws but can not be used as it is because
it misses some glue code to convert argv and envp arguments to char
*const [] values (even though the destructor is present!).

As it is not possible to remove rpm_execcon() without changing
libselinux soname (it would be an ABI break) like b67fefd991
("libselinux: set DISABLE_RPM default to y.") tried to do, disable this
interface locally in the SWIG wrappers.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2016-11-07 15:55:08 -05:00

49 lines
968 B
OpenEdge ABL

/* Author: Dan Walsh
Based on selinuxswig_python.i by James Athey
*/
/* Never build rpm_execcon interface */
#ifndef DISABLE_RPM
#define DISABLE_RPM
#endif
%module selinux
%{
#include "selinux/selinux.h"
%}
/* return a sid along with the result */
%typemap(argout) (security_id_t * sid) {
if (*$1) {
%append_output(SWIG_NewPointerObj(*$1, $descriptor(security_id_t), 0));
}
}
%typemap(in,numinputs=0) security_id_t *(security_id_t temp) {
$1 = &temp;
}
%typemap(in,noblock=1,numinputs=0) char ** (char * temp = 0) {
$1 = &temp;
}
%typemap(freearg,match="in") char ** "";
%typemap(argout,noblock=1) char ** {
if (*$1) {
%append_output(SWIG_FromCharPtr(*$1));
freecon(*$1);
}
}
%typemap(in,noblock=1,numinputs=0) char ** (char * temp = 0) {
$1 = &temp;
}
%typemap(freearg,match="in") char ** "";
%typemap(argout,noblock=1) char ** {
if (*$1) {
%append_output(SWIG_FromCharPtr(*$1));
free(*$1);
}
}
%include "selinuxswig.i"