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

fixing up pam_http

This commit is contained in:
Adolfo Gómez García 2019-05-13 16:56:19 +02:00
parent 8331c886de
commit 20ead2954b
3 changed files with 21 additions and 0 deletions

2
.gitignore vendored
View File

@ -164,3 +164,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,17 @@ static int getUrl(const char* url, char* buffer, size_t size ) {
return res;
}
int isValid(const char* str)
{
const int len = strnlen(str, 256);
for( int 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 +80,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

@ -14,6 +14,8 @@
#include <syslog.h>
#include "http.h"
char baseUrl[256] = { '\0' };
enum nss_status _nss_uds_getpwuid_r(uid_t,struct passwd *,char *, size_t,int *);