aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBernhard Miklautz <bernhard.miklautz@shacknet.at>2017-12-18 12:44:54 +0100
committerBernhard Miklautz <bernhard.miklautz@shacknet.at>2017-12-18 12:53:19 +0100
commit5583d6a2d86038bdeceb99e4752f961147dd585b (patch)
tree2b78f9afb046a10586bc3c1a678501e33035b392 /src
parentea05a6160c17460f8cdde00ac35f6023e47dd6a7 (diff)
downloadlibpam-freerdp2-5583d6a2d86038bdeceb99e4752f961147dd585b.tar.gz
libpam-freerdp2-5583d6a2d86038bdeceb99e4752f961147dd585b.tar.bz2
libpam-freerdp2-5583d6a2d86038bdeceb99e4752f961147dd585b.zip
Update to use the freerdp2 API
* use the new API * use AuthenticationOnly * return 0 on SUCCESS the last known error otherwise * disable wlog output (unless compiled with ENABLE_WLOG)
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am5
-rw-r--r--src/freerdp-auth-check.c53
2 files changed, 40 insertions, 18 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index ab46225..4eb3aa0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -39,9 +39,12 @@ freerdp2_auth_check_SOURCES = \
freerdp-auth-check.c
freerdp2_auth_check_CFLAGS = \
$(FREERDP2_CFLAGS) \
+ $(WINPR2_CFLAGS) \
$(COVERAGE_CFLAGS)
freerdp2_auth_check_LDADD = \
- $(FREERDP2_LIBS)
+ $(FREERDP2_LIBS) \
+ $(WINPR2_LIBS)
freerdp2_auth_check_LDFLAGS = \
$(FREERDP2_LDFLAGS) \
+ $(WINPR2_LDFLAGS) \
$(COVERAGE_LDFLAGS)
diff --git a/src/freerdp-auth-check.c b/src/freerdp-auth-check.c
index 30b4637..698c098 100644
--- a/src/freerdp-auth-check.c
+++ b/src/freerdp-auth-check.c
@@ -19,12 +19,14 @@
#include <freerdp/freerdp.h>
#include <freerdp/channels/channels.h>
#include <string.h>
+#include <sys/mman.h>
+#include <winpr/wlog.h>
-int
+
+BOOL
auth_context_new (freerdp * instance, rdpContext * context)
{
- context->channels = freerdp_channels_new();
- return 0;
+ return TRUE;
}
void
@@ -36,14 +38,12 @@ auth_context_free (freerdp * instance, rdpContext * context)
BOOL
auth_pre_connect (freerdp * instance)
{
- freerdp_channels_pre_connect(instance->context->channels, instance);
return TRUE;
}
BOOL
auth_post_connect (freerdp * instance)
{
- freerdp_channels_post_connect(instance->context->channels, instance);
return TRUE;
}
@@ -64,8 +64,13 @@ main (int argc, char * argv[])
return -1;
}
- freerdp_channels_global_init();
+#ifndef ENABLE_WLOG
+ wLog* root = WLog_GetRoot();
+ if (!WLog_SetStringLogLevel(root, "OFF")){
+ return -1;
+ }
+#endif
freerdp * instance = freerdp_new();
instance->PreConnect = auth_pre_connect;
@@ -75,12 +80,10 @@ main (int argc, char * argv[])
instance->ContextNew = auth_context_new;
instance->ContextFree = auth_context_free;
- freerdp_context_new(instance);
-
- instance->settings->ServerHostname = argv[1];
- instance->settings->Username = argv[2];
- instance->settings->Domain = argv[3];
- instance->settings->Password = password;
+ if (!freerdp_context_new(instance)) {
+ printf("Coudln't create freerdp context\n");
+ return -1;
+ }
char * colonloc = strstr(argv[1], ":");
if (colonloc != NULL) {
@@ -91,14 +94,30 @@ main (int argc, char * argv[])
instance->settings->ServerPort = strtoul(colonloc, NULL, 10);
}
- int retval = -1;
- if (freerdp_connect(instance)) {
- freerdp_disconnect(instance);
- retval = 0;
- }
+ instance->settings->AuthenticationOnly = TRUE;
+ instance->settings->ServerHostname = argv[1];
+ instance->settings->Username = argv[2];
+ instance->settings->Domain = argv[3];
+ instance->settings->Password = password;
+
+ BOOL connection_successful;
+ connection_successful = freerdp_connect(instance);
+ freerdp_disconnect(instance);
memset(password, 0, sizeof(password));
munlock(password, sizeof(password));
+ instance->settings->Password = NULL;
+ instance->settings->ServerHostname = NULL;
+ instance->settings->Username = NULL;
+ instance->settings->Domain = NULL;
+
+ int retval = 0;
+ if (!connection_successful) {
+ retval = freerdp_get_last_error(instance->context);
+ }
+
+ freerdp_context_free(instance);
+ freerdp_free(instance);
return retval;
}