Apply patch: ncpfs-2.2.6-php_auth_nds-php8.patch

This commit is contained in:
Mario Fetka
2026-04-28 21:15:10 +02:00
parent 238ee10077
commit ec01e736af

View File

@@ -814,47 +814,34 @@ bailout:
PHP_FUNCTION (read_nds_string)
{
int res; /* fcn result code */
const char *treen, *objectn, *attributen;
char *treen, *objectn, *attributen;
size_t treen_len, objectn_len, attributen_len;
char errstr[512];
char local_buffer [8192];
char * buffer; // returned by NWCXGetMultiStringAttributeValue
int argc = ZEND_NUM_ARGS();
zval **tree, **object, **attribute;
if (argc != 3 || zend_get_parameters_ex(argc, &tree, &object, &attribute)) {
WRONG_PARAM_COUNT;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss", &treen, &treen_len,
&objectn, &objectn_len,
&attributen, &attributen_len) == FAILURE) {
RETURN_THROWS();
}
sprintf(errstr, "Wrong parameters values");
if (!tree || !object || !attribute) {
RETURN_STRING(errstr,1);
}
convert_to_string_ex(tree);
convert_to_string_ex(object);
convert_to_string_ex(attribute);
treen = (*tree)->value.str.val;
objectn = (*object)->value.str.val;
attributen = (*attribute)->value.str.val;
if (!treen || !objectn || !attributen) {
RETURN_STRING(errstr,1);
RETURN_STRING(errstr);
}
sprintf(errstr, "failure");
res=nds_read_string_fn(errstr,treen,objectn,attributen,&buffer);
if (res) {
RETURN_STRING(errstr,1);
RETURN_STRING(errstr);
}
if (strlen(buffer) >=sizeof(local_buffer)) {
buffer[sizeof(local_buffer)-1]=0;
}
strcpy(local_buffer,buffer);
free(buffer);
RETURN_STRING(local_buffer,1);
RETURN_STRING(local_buffer);
}
@@ -862,78 +849,53 @@ PHP_FUNCTION (read_nds_string2)
//use a servername instaed of a tree name
{
int res; /* fcn result code */
const char *servern, *objectn, *attributen;
char *servern, *objectn, *attributen;
size_t servern_len, objectn_len, attributen_len;
char errstr[512];
char local_buffer [8192];
char * buffer; // returned by NWCXGetMultiStringAttributeValue
int argc = ZEND_NUM_ARGS();
zval **server, **object, **attribute;
if (argc != 3 || zend_get_parameters_ex(argc, &server, &object, &attribute)) {
WRONG_PARAM_COUNT;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss", &servern, &servern_len,
&objectn, &objectn_len,
&attributen, &attributen_len) == FAILURE) {
RETURN_THROWS();
}
sprintf(errstr, "Wrong parameters values");
if (!server || !object || !attribute) {
RETURN_STRING(errstr,1);
}
convert_to_string_ex(server);
convert_to_string_ex(object);
convert_to_string_ex(attribute);
servern = (*server)->value.str.val;
objectn = (*object)->value.str.val;
attributen = (*attribute)->value.str.val;
if (!servern || !objectn || !attributen) {
RETURN_STRING(errstr,1);
RETURN_STRING(errstr);
}
sprintf(errstr, "failure");
res=nds_read_string_fn2(errstr,servern,objectn,attributen,&buffer);
if (res) {
RETURN_STRING(errstr,1);
RETURN_STRING(errstr);
}
if (strlen(buffer) >=sizeof(local_buffer)) {
buffer[sizeof(local_buffer)-1]=0;
}
strcpy(local_buffer,buffer);
free(buffer);
RETURN_STRING(local_buffer,1);
RETURN_STRING(local_buffer);
}
PHP_FUNCTION (read_nds_int)
{
int res; /* fcn result code */
const char *treen, *objectn, *attributen;
char *treen, *objectn, *attributen;
size_t treen_len, objectn_len, attributen_len;
char errstr[512];
int argc = ZEND_NUM_ARGS();
zval **tree, **object, **attribute;
if (argc != 3 || zend_get_parameters_ex(argc, &tree, &object, &attribute)) {
WRONG_PARAM_COUNT;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss", &treen, &treen_len,
&objectn, &objectn_len,
&attributen, &attributen_len) == FAILURE) {
RETURN_THROWS();
}
sprintf(errstr, "Wrong parameters values");
if (!tree || !object || !attribute) {
RETURN_STRING(errstr,1);
}
convert_to_string_ex(tree);
convert_to_string_ex(object);
convert_to_string_ex(attribute);
treen = (*tree)->value.str.val;
objectn = (*object)->value.str.val;
attributen = (*attribute)->value.str.val;
if (!treen || !objectn || !attributen) {
RETURN_STRING(errstr,1);
RETURN_STRING(errstr);
}
sprintf(errstr, "failure");
{
@@ -943,7 +905,7 @@ PHP_FUNCTION (read_nds_int)
sprintf(errstr, "%d", result);
}
}
RETURN_STRING(errstr, 1);
RETURN_STRING(errstr);
}
@@ -951,31 +913,19 @@ PHP_FUNCTION (read_nds_int2)
// use a servername instead of a tree name as first argument
{
int res; /* fcn result code */
const char *servern, *objectn, *attributen;
char *servern, *objectn, *attributen;
size_t servern_len, objectn_len, attributen_len;
char errstr[512];
int argc = ZEND_NUM_ARGS();
zval **server, **object, **attribute;
if (argc != 3 || zend_get_parameters_ex(argc, &server, &object, &attribute)) {
WRONG_PARAM_COUNT;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss", &servern, &servern_len,
&objectn, &objectn_len,
&attributen, &attributen_len) == FAILURE) {
RETURN_THROWS();
}
sprintf(errstr, "Wrong parameters values");
if (!server || !object || !attribute) {
RETURN_STRING(errstr,1);
}
convert_to_string_ex(server);
convert_to_string_ex(object);
convert_to_string_ex(attribute);
servern = (*server)->value.str.val;
objectn = (*object)->value.str.val;
attributen = (*attribute)->value.str.val;
if (!servern || !objectn || !attributen) {
RETURN_STRING(errstr,1);
RETURN_STRING(errstr);
}
sprintf(errstr, "failure");
{
@@ -986,37 +936,28 @@ PHP_FUNCTION (read_nds_int2)
sprintf(errstr, "%d", result);
}
}
RETURN_STRING(errstr, 1);
RETURN_STRING(errstr);
}
PHP_FUNCTION(auth_bindery)
{
int res; /* fcn result code */
const char *servern, *usern, *sent_pw, *groupn;
char *servern, *usern, *sent_pw, *groupn;
size_t servern_len, usern_len, sent_pw_len, groupn_len;
char errstr[512];
int argc = ZEND_NUM_ARGS();
zval **server, **user, **password, ** group;
if (argc != 4 || zend_get_parameters_ex(argc, &server, &user, &password, &group)) {
WRONG_PARAM_COUNT;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ssss", &servern, &servern_len,
&usern, &usern_len,
&sent_pw, &sent_pw_len,
&groupn, &groupn_len) == FAILURE) {
RETURN_THROWS();
}
convert_to_string_ex(server);
convert_to_string_ex(user);
convert_to_string_ex(password);
convert_to_string_ex(group);
servern = (*server)->value.str.val;
usern = (*user)->value.str.val;
sent_pw = (*password)->value.str.val;
groupn = (*group)->value.str.val;
/* do they know the magic word? */
sprintf(errstr, "failure");
res = bindery_auth(errstr, servern, usern, sent_pw, groupn );
if (res) {
RETURN_STRING(errstr,1);
RETURN_STRING(errstr);
}
RETURN_FALSE;
}
@@ -1024,64 +965,46 @@ PHP_FUNCTION(auth_bindery)
PHP_FUNCTION(auth_tree)
{
int res; /* fcn result code */
const char *servern, *ctxs,*usern, *sent_pw, *groupn;
char *servern, *ctxs,*usern, *sent_pw, *groupn;
size_t servern_len, ctxs_len, usern_len, sent_pw_len, groupn_len;
char errstr[512];
char fqdn[MAX_DN_CHARS+5]; // to get 'DN=' plus the FQDN used
int argc = ZEND_NUM_ARGS();
zval **server, **user, **contexts, **password, **group;
if (argc != 5 || zend_get_parameters_ex(argc, &server, &user, &contexts,&password, &group)) {
WRONG_PARAM_COUNT;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sssss", &servern, &servern_len,
&usern, &usern_len,
&ctxs, &ctxs_len,
&sent_pw, &sent_pw_len,
&groupn, &groupn_len) == FAILURE) {
RETURN_THROWS();
}
convert_to_string_ex(server);
convert_to_string_ex(user);
convert_to_string_ex(contexts);
convert_to_string_ex(password);
convert_to_string_ex(group);
servern = (*server)->value.str.val;
usern = (*user)->value.str.val;
ctxs = (*contexts)->value.str.val ;
sent_pw = (*password)->value.str.val;
groupn = (*group)->value.str.val;
/* do they know the magic word? */
sprintf(errstr, "failure");
strcpy(fqdn, "DN=");
res = tree_auth_fn(errstr, servern, usern, ctxs,sent_pw, groupn, fqdn + 3);
if (res) {
RETURN_STRING(errstr, 1);
RETURN_STRING(errstr);
}
RETURN_STRING(fqdn, 1);
RETURN_STRING(fqdn);
}
PHP_FUNCTION(auth_nds)
{
int res; /* fcn result code */
const char *servern, *usern, *sent_pw, *groupn;
char *servern, *usern, *sent_pw, *groupn;
size_t servern_len, usern_len, sent_pw_len, groupn_len;
char errstr[512];
int argc = ZEND_NUM_ARGS();
zval **server, **user, **password, **group;
if (argc != 4 || zend_get_parameters_ex(argc, &server, &user, &password, &group)) {
WRONG_PARAM_COUNT;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ssss", &servern, &servern_len,
&usern, &usern_len,
&sent_pw, &sent_pw_len,
&groupn, &groupn_len) == FAILURE) {
RETURN_THROWS();
}
convert_to_string_ex(server);
convert_to_string_ex(user);
convert_to_string_ex(password);
convert_to_string_ex(group);
servern = (*server)->value.str.val;
usern = (*user)->value.str.val;
sent_pw = (*password)->value.str.val;
groupn = (*group)->value.str.val;
/* do they know the magic word? */
sprintf(errstr, "failure");
res = nds_auth_fn(errstr, servern, usern, sent_pw, groupn);
if (res) {
RETURN_STRING(errstr,1);
RETURN_STRING(errstr);
}
RETURN_FALSE;
}