21 |
#include <stdlib.h> /* malloc realloc free */ |
#include <stdlib.h> /* malloc realloc free */ |
22 |
#include <unistd.h> /* read close getuid getgid getpid getppid gethostname */ |
#include <unistd.h> /* read close getuid getgid getpid getppid gethostname */ |
23 |
#include <fcntl.h> /* open */ |
#include <fcntl.h> /* open */ |
|
#include <getopt.h> /* getopt */ |
|
24 |
#include <pwd.h> /* getpwuid */ |
#include <pwd.h> /* getpwuid */ |
25 |
#include <sys/stat.h> /* stat */ |
#include <sys/stat.h> /* stat */ |
26 |
#include <sys/time.h> /* gettimeofday */ |
#include <sys/time.h> /* gettimeofday */ |
32 |
int width = 800; |
int width = 800; |
33 |
int height = 600; |
int height = 600; |
34 |
int keylayout = 0x409; |
int keylayout = 0x409; |
35 |
BOOL motion = False; |
BOOL motion = True; |
36 |
BOOL orders = True; |
BOOL orders = True; |
37 |
BOOL licence = True; |
BOOL licence = True; |
38 |
|
|
41 |
{ |
{ |
42 |
STATUS("Usage: %s [options] server\n", program); |
STATUS("Usage: %s [options] server\n", program); |
43 |
STATUS(" -u: user name\n"); |
STATUS(" -u: user name\n"); |
44 |
|
STATUS(" -d: domain\n"); |
45 |
|
STATUS(" -s: shell\n"); |
46 |
|
STATUS(" -c: working directory\n"); |
47 |
|
STATUS(" -p: password (autologon)\n"); |
48 |
STATUS(" -n: client hostname\n"); |
STATUS(" -n: client hostname\n"); |
49 |
STATUS(" -w: desktop width\n"); |
STATUS(" -w: desktop width\n"); |
50 |
STATUS(" -h: desktop height\n"); |
STATUS(" -h: desktop height\n"); |
51 |
STATUS(" -k: keyboard layout (hex)\n"); |
STATUS(" -k: keyboard layout (hex)\n"); |
|
STATUS(" -m: send motion events\n"); |
|
52 |
STATUS(" -b: force bitmap updates\n"); |
STATUS(" -b: force bitmap updates\n"); |
53 |
|
STATUS(" -m: do not send motion events\n"); |
54 |
STATUS(" -l: do not request licence\n\n"); |
STATUS(" -l: do not request licence\n\n"); |
55 |
} |
} |
56 |
|
|
59 |
{ |
{ |
60 |
struct passwd *pw; |
struct passwd *pw; |
61 |
char *server; |
char *server; |
62 |
|
uint32 flags; |
63 |
|
char domain[16]; |
64 |
|
char password[16]; |
65 |
|
char shell[32]; |
66 |
|
char directory[32]; |
67 |
char title[32]; |
char title[32]; |
68 |
int c; |
int c; |
69 |
|
|
70 |
STATUS("rdesktop: A Remote Desktop Protocol client.\n"); |
STATUS("rdesktop: A Remote Desktop Protocol client.\n"); |
71 |
STATUS("Version "VERSION". Copyright (C) 1999-2000 Matt Chapman.\n\n"); |
STATUS("Version "VERSION". Copyright (C) 1999-2000 Matt Chapman.\n"); |
72 |
|
STATUS("See http://www.rdesktop.org/ for more information.\n\n"); |
73 |
|
|
74 |
while ((c = getopt(argc, argv, "u:n:w:h:k:mbl?")) != -1) |
flags = RDP_LOGON_NORMAL; |
75 |
|
domain[0] = password[0] = shell[0] = directory[0] = 0; |
76 |
|
|
77 |
|
while ((c = getopt(argc, argv, "u:d:s:c:p:n:w:h:k:bml?")) != -1) |
78 |
{ |
{ |
79 |
switch (c) |
switch (c) |
80 |
{ |
{ |
82 |
strncpy(username, optarg, sizeof(username)); |
strncpy(username, optarg, sizeof(username)); |
83 |
break; |
break; |
84 |
|
|
85 |
|
case 'd': |
86 |
|
strncpy(domain, optarg, sizeof(domain)); |
87 |
|
break; |
88 |
|
|
89 |
|
case 'p': |
90 |
|
flags |= RDP_LOGON_AUTO; |
91 |
|
strncpy(password, optarg, sizeof(password)); |
92 |
|
break; |
93 |
|
|
94 |
|
case 's': |
95 |
|
strncpy(shell, optarg, sizeof(shell)); |
96 |
|
break; |
97 |
|
|
98 |
|
case 'c': |
99 |
|
strncpy(directory, optarg, sizeof(directory)); |
100 |
|
break; |
101 |
|
|
102 |
case 'n': |
case 'n': |
103 |
strncpy(hostname, optarg, sizeof(hostname)); |
strncpy(hostname, optarg, sizeof(hostname)); |
104 |
break; |
break; |
116 |
break; |
break; |
117 |
|
|
118 |
case 'm': |
case 'm': |
119 |
motion = True; |
motion = False; |
120 |
break; |
break; |
121 |
|
|
122 |
case 'b': |
case 'b': |
163 |
} |
} |
164 |
} |
} |
165 |
|
|
166 |
if (!rdp_connect(server)) |
if (!rdp_connect(server, flags, domain, password, shell, directory)) |
167 |
return 1; |
return 1; |
168 |
|
|
169 |
STATUS("Connection successful.\n"); |
STATUS("Connection successful.\n"); |
170 |
|
|
171 |
snprintf(title, sizeof(title), "rdesktop - %s", server); |
strcpy(title, "rdesktop - "); |
172 |
|
strncat(title, server, sizeof(title)); |
173 |
|
|
174 |
if (ui_create_window(title)) |
if (ui_create_window(title)) |
175 |
{ |
{ |
176 |
rdp_main_loop(); |
rdp_main_loop(); |
185 |
void generate_random(uint8 *random) |
void generate_random(uint8 *random) |
186 |
{ |
{ |
187 |
struct stat st; |
struct stat st; |
188 |
|
struct tms tmsbuf; |
189 |
uint32 *r = (uint32 *)random; |
uint32 *r = (uint32 *)random; |
190 |
int fd; |
int fd; |
191 |
|
|
200 |
/* Otherwise use whatever entropy we can gather - ideas welcome. */ |
/* Otherwise use whatever entropy we can gather - ideas welcome. */ |
201 |
r[0] = (getpid()) | (getppid() << 16); |
r[0] = (getpid()) | (getppid() << 16); |
202 |
r[1] = (getuid()) | (getgid() << 16); |
r[1] = (getuid()) | (getgid() << 16); |
203 |
r[2] = times(NULL); /* system uptime (clocks) */ |
r[2] = times(&tmsbuf); /* system uptime (clocks) */ |
204 |
gettimeofday((struct timeval *)&r[3], NULL); /* sec and usec */ |
gettimeofday((struct timeval *)&r[3], NULL); /* sec and usec */ |
205 |
stat("/tmp", &st); |
stat("/tmp", &st); |
206 |
r[5] = st.st_atime; |
r[5] = st.st_atime; |