1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-21 09:34:08 +03:00

imported pam_http fix

This commit is contained in:
Adolfo Gómez García 2019-05-13 17:19:44 +02:00
commit 8a7ceb926d
3 changed files with 21 additions and 1 deletions

2
.gitignore vendored
View File

@ -165,3 +165,5 @@
/udsService/udsgui/obj/Debug
/udsService/udsgui/obj/Release
/udsService/udsgui/obj/x86
.vscode

View File

@ -1,6 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
#include <curl/curl.h>
#include <curl/easy.h>
@ -61,6 +62,18 @@ static int getUrl(const char* url, char* buffer, size_t size ) {
return res;
}
int isValid(const char* str)
{
const int len = strnlen(str, DATASIZE);
int i;
for( i = 0; i < len; i++ ) {
if ( !isalnum(str[i]) && str[i] != '-' ) {
return 0;
}
}
return 1;
}
int httpAuthenticate(const char* username, const char* password, const char* authHost)
{
@ -68,6 +81,11 @@ int httpAuthenticate(const char* username, const char* password, const char* aut
char* url = malloc(256);
int res;
/* Ensure username & passwords are valid */
if (!isValid(username) || !isValid(password)) {
return -1; /* no valid data, injecting? */
}
sprintf( url, "%s?%s=%s&%s=%s", authHost, AUTHID, username, AUTHPASS, password );
res = getUrl( url, buffer, DATASIZE );
free(url);

View File

@ -1,5 +1,5 @@
Server = http
Port = 9090
Port = 44300
SSLCertificateFile = /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile = /etc/ssl/private/ssl-cert-snakeoil.key