~ubuntu-desktop/libpam-freerdp/ubuntu

« back to all changes in this revision

Viewing changes to src/freerdp-auth-check.c

  • Committer: Ted Gould
  • Date: 2012-08-21 23:47:16 UTC
  • mfrom: (1.3.4)
  • Revision ID: ted@gould.cx-20120821234716-x8vy8isbkwbw3ars
* New upstream release.
  * Now with auth helper!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2012 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License version 3, as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
10
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
11
 * PURPOSE.  See the GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License along
 
14
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Author: Ted Gould <ted@canonical.com>
 
17
 */
 
18
 
 
19
#include <freerdp/freerdp.h>
 
20
#include <freerdp/channels/channels.h>
 
21
#include <string.h>
 
22
 
 
23
void
 
24
auth_context_new (freerdp * instance, rdpContext * context)
 
25
{
 
26
        context->channels = freerdp_channels_new();
 
27
        return;
 
28
}
 
29
 
 
30
void
 
31
auth_context_free (freerdp * instance, rdpContext * context)
 
32
{
 
33
        return;
 
34
}
 
35
 
 
36
boolean
 
37
auth_pre_connect (freerdp * instance)
 
38
{
 
39
        freerdp_channels_pre_connect(instance->context->channels, instance);
 
40
        return true;
 
41
}
 
42
 
 
43
boolean
 
44
auth_post_connect (freerdp * instance)
 
45
{
 
46
        freerdp_channels_post_connect(instance->context->channels, instance);
 
47
        return true;
 
48
}
 
49
 
 
50
int
 
51
main (int argc, char * argv[])
 
52
{
 
53
        char password[512];
 
54
        if (argc != 4) {
 
55
                printf("Not enough params");
 
56
                return -1;
 
57
        }
 
58
 
 
59
        if (scanf("%511s", password) != 1) {
 
60
                return -1;
 
61
        }
 
62
 
 
63
        freerdp_channels_global_init();
 
64
 
 
65
        freerdp * instance = freerdp_new();
 
66
 
 
67
        instance->PreConnect = auth_pre_connect;
 
68
        instance->PostConnect = auth_post_connect;
 
69
 
 
70
        instance->context_size = sizeof(rdpContext);
 
71
        instance->ContextNew = auth_context_new;
 
72
        instance->ContextFree = auth_context_free;
 
73
 
 
74
        freerdp_context_new(instance);
 
75
 
 
76
        instance->settings->hostname = argv[1];
 
77
        instance->settings->username = argv[2];
 
78
        instance->settings->domain = argv[3];
 
79
        instance->settings->password = password;
 
80
        instance->settings->ignore_certificate = true;
 
81
 
 
82
        if (freerdp_connect(instance)) {
 
83
                freerdp_disconnect(instance);
 
84
                return 0;
 
85
        } else {
 
86
                return -1;
 
87
        }
 
88
}