svn: /pecl/selinux/trunk/ php_selinux.h selinux.c
| From: | Remi Collet | Date: | Sun, 05 Apr 2015 13:46:35 +0000 |
| Subject: | svn: /pecl/selinux/trunk/ php_selinux.h selinux.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-22028@lists.php.net to get a copy of this message | ||
remi Sun, 05 Apr 2015 13:46:35 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=336387
Log:
WIP: php 7 compatibility
Changed paths:
U pecl/selinux/trunk/php_selinux.h
U pecl/selinux/trunk/selinux.c
Modified: pecl/selinux/trunk/php_selinux.h
===================================================================
--- pecl/selinux/trunk/php_selinux.h 2015-04-05 13:44:37 UTC (rev 336386)
+++ pecl/selinux/trunk/php_selinux.h 2015-04-05 13:46:35 UTC (rev 336387)
@@ -105,4 +105,13 @@
PHP_FUNCTION(selinux_getpolicytype);
PHP_FUNCTION(selinux_policy_root);
+
+#if PHP_MAJOR_VERSION < 7
+#define _RETVAL_STRING(s) RETVAL_STRING(s,1)
+#define _ADD_STRING(a,s) add_next_index_string(a,s,1)
+#else
+#define _RETVAL_STRING(s) RETVAL_STRING(s)
+#define _ADD_STRING(a,s) add_next_index_string(a,s)
+#endif
+
#endif /* PHP_SELINUX_H */
Modified: pecl/selinux/trunk/selinux.c
===================================================================
--- pecl/selinux/trunk/selinux.c 2015-04-05 13:44:37 UTC (rev 336386)
+++ pecl/selinux/trunk/selinux.c 2015-04-05 13:46:35 UTC (rev 336387)
@@ -1,8 +1,8 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 5, 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2009 The PHP Group |
+ | Copyright (c) 1997-2015 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -420,7 +420,7 @@
if (!context)
RETURN_EMPTY_STRING();
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
}
/* }}} */
@@ -461,7 +461,7 @@
if (!context)
RETURN_EMPTY_STRING();
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
}
/* }}} */
@@ -480,7 +480,7 @@
if (!context)
RETURN_EMPTY_STRING();
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
}
/* }}} */
@@ -499,7 +499,7 @@
if (!context)
RETURN_EMPTY_STRING();
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
}
/* }}} */
@@ -538,7 +538,7 @@
if (!context)
RETURN_EMPTY_STRING();
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
}
/* }}} */
@@ -577,7 +577,7 @@
if (!context)
RETURN_EMPTY_STRING();
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
}
/* }}} */
@@ -616,7 +616,7 @@
if (!context)
RETURN_EMPTY_STRING();
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
}
/* }}} */
@@ -656,7 +656,7 @@
if (getfilecon(filename, &context) < 0)
RETURN_FALSE;
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
}
/* }}} */
@@ -676,7 +676,7 @@
if (lgetfilecon(filename, &context) < 0)
RETURN_FALSE;
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
}
/* }}} */
@@ -705,7 +705,7 @@
if (fgetfilecon(fdesc, &context) < 0)
RETURN_FALSE;
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
}
/* }}} */
@@ -794,7 +794,7 @@
RETURN_FALSE;
if (getpeercon(sockfd, &context) < 0)
RETURN_FALSE;
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
}
/* }}} */
@@ -808,8 +808,13 @@
security_class_t tclass;
access_vector_t perm;
struct av_decision avd;
+ int permissive = 0;
+#if PHP_MAJOR_VERSION < 7
zval *allowed, *auditallow, *auditdeny;
- int permissive = 0;
+#else
+ zval zallowed, zauditallow, zauditdeny;
+ zval *allowed=&zallowed, *auditallow=&zauditallow, *auditdeny=&zauditdeny;
+#endif
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss",
&scontext, &scontext_len,
@@ -825,9 +830,11 @@
if (avd.flags & SELINUX_AVD_FLAGS_PERMISSIVE)
permissive = 1;
+#if PHP_MAJOR_VERSION < 7
MAKE_STD_ZVAL(allowed);
MAKE_STD_ZVAL(auditallow);
MAKE_STD_ZVAL(auditdeny);
+#endif
array_init(allowed);
array_init(auditallow);
array_init(auditdeny);
@@ -879,7 +886,7 @@
tclass, objname, &context) < 0)
RETURN_FALSE;
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
}
/* }}} */
@@ -902,7 +909,7 @@
tclass = string_to_security_class(tclass_name);
if (security_compute_relabel(scontext, tcontext, tclass, &context) < 0)
RETURN_FALSE;
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
}
/* }}} */
@@ -925,7 +932,7 @@
tclass = string_to_security_class(tclass_name);
if (security_compute_member(scontext, tcontext, tclass, &context) < 0)
RETURN_FALSE;
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
}
/* }}} */
@@ -950,7 +957,7 @@
array_init(return_value);
for (i=0; contexts[i]; i++)
{
- add_next_index_string(return_value, contexts[i], 1);
+ _ADD_STRING(return_value, contexts[i]);
}
freeconary(contexts);
}
@@ -971,7 +978,7 @@
if (security_get_initial_context(name, &context) < 0)
RETURN_FALSE;
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
}
/* }}} */
@@ -1008,8 +1015,8 @@
if (security_canonicalize_context(context, &canonicalized) < 0)
RETURN_FALSE;
- RETVAL_STRING(canonicalized, 1);
- freecon(canonicalized);
+ _RETVAL_STRING(canonicalized);
+ freecon(canonicalized);
}
/* }}} */
@@ -1028,7 +1035,7 @@
array_init(return_value);
for (i=0; i < length; i++) {
- add_next_index_string(return_value, bool_names[i], 1);
+ _ADD_STRING(return_value, bool_names[i]);
free(bool_names[i]);
}
free(bool_names);
@@ -1114,7 +1121,7 @@
if (selinux_trans_to_raw_context(context, &raw_context) < 0 || !raw_context)
RETURN_FALSE;
- RETVAL_STRING(raw_context, 1);
+ _RETVAL_STRING(raw_context);
freecon(raw_context);
}
/* }}} */
@@ -1133,7 +1140,7 @@
if (selinux_raw_to_trans_context(context, &trans_context) < 0)
RETURN_FALSE;
- RETVAL_STRING(trans_context, 1);
+ _RETVAL_STRING(trans_context);
freecon(trans_context);
}
/* }}} */
@@ -1184,7 +1191,7 @@
RETURN_FALSE;
}
selabel_close(hnd);
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
}
@@ -1224,7 +1231,7 @@
RETURN_FALSE;
}
selabel_close(hnd);
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
}
@@ -1272,7 +1279,7 @@
RETURN_FALSE;
}
selabel_close(hnd);
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
return;
@@ -1328,7 +1335,7 @@
RETURN_FALSE;
}
selabel_close(hnd);
- RETVAL_STRING(context, 1);
+ _RETVAL_STRING(context);
freecon(context);
return;
@@ -1349,11 +1356,11 @@
RETURN_FALSE;
if (enforce > 0) {
- RETVAL_STRING("enforcing", 1);
+ _RETVAL_STRING("enforcing");
} else if (enforce < 0) {
- RETVAL_STRING("disabled", 1);
+ _RETVAL_STRING("disabled");
} else {
- RETVAL_STRING("permissive", 1);
+ _RETVAL_STRING("permissive");
}
}
/* }}} */
@@ -1368,7 +1375,7 @@
ZEND_WRONG_PARAM_COUNT();
if (selinux_getpolicytype(&policytype) < 0)
RETURN_FALSE;
- RETVAL_STRING(policytype, 1);
+ _RETVAL_STRING(policytype);
free(policytype);
}
/* }}} */
@@ -1385,6 +1392,6 @@
root = (char *) selinux_policy_root();
if (!root)
RETURN_FALSE;
- RETVAL_STRING(root, 1);
+ _RETVAL_STRING(root);
}
/* }}} */