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>
@ -62,12 +63,28 @@ static int getUrl(const char* url, char* buffer, size_t size ) {
}
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)
{
char* buffer = malloc(DATASIZE);
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 *);