18 |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 |
*/ |
*/ |
20 |
|
|
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 */ |
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 */ |
27 |
#include <sys/times.h> /* times */ |
#include <sys/times.h> /* times */ |
28 |
#include "rdesktop.h" |
#include "rdesktop.h" |
29 |
|
|
30 |
char username[16]; |
char username[16]; |
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"); |
STATUS("Version " VERSION |
72 |
|
". Copyright (C) 1999-2000 Matt Chapman.\n"); |
73 |
STATUS("See http://www.rdesktop.org/ for more information.\n\n"); |
STATUS("See http://www.rdesktop.org/ for more information.\n\n"); |
74 |
|
|
75 |
while ((c = getopt(argc, argv, "u:n:w:h:k:mbl?")) != -1) |
flags = RDP_LOGON_NORMAL; |
76 |
|
domain[0] = password[0] = shell[0] = directory[0] = 0; |
77 |
|
|
78 |
|
while ((c = getopt(argc, argv, "u:d:s:c:p:n:w:h:k:bml?")) != -1) |
79 |
{ |
{ |
80 |
switch (c) |
switch (c) |
81 |
{ |
{ |
83 |
strncpy(username, optarg, sizeof(username)); |
strncpy(username, optarg, sizeof(username)); |
84 |
break; |
break; |
85 |
|
|
86 |
|
case 'd': |
87 |
|
strncpy(domain, optarg, sizeof(domain)); |
88 |
|
break; |
89 |
|
|
90 |
|
case 'p': |
91 |
|
flags |= RDP_LOGON_AUTO; |
92 |
|
strncpy(password, optarg, sizeof(password)); |
93 |
|
break; |
94 |
|
|
95 |
|
case 's': |
96 |
|
strncpy(shell, optarg, sizeof(shell)); |
97 |
|
break; |
98 |
|
|
99 |
|
case 'c': |
100 |
|
strncpy(directory, optarg, sizeof(directory)); |
101 |
|
break; |
102 |
|
|
103 |
case 'n': |
case 'n': |
104 |
strncpy(hostname, optarg, sizeof(hostname)); |
strncpy(hostname, optarg, sizeof(hostname)); |
105 |
break; |
break; |
117 |
break; |
break; |
118 |
|
|
119 |
case 'm': |
case 'm': |
120 |
motion = True; |
motion = False; |
121 |
break; |
break; |
122 |
|
|
123 |
case 'b': |
case 'b': |
164 |
} |
} |
165 |
} |
} |
166 |
|
|
167 |
if (!rdp_connect(server)) |
if (!rdp_connect(server, flags, domain, password, shell, directory)) |
168 |
return 1; |
return 1; |
169 |
|
|
170 |
STATUS("Connection successful.\n"); |
STATUS("Connection successful.\n"); |
186 |
void generate_random(uint8 *random) |
void generate_random(uint8 *random) |
187 |
{ |
{ |
188 |
struct stat st; |
struct stat st; |
189 |
uint32 *r = (uint32 *)random; |
struct tms tmsbuf; |
190 |
|
uint32 *r = (uint32 *) random; |
191 |
int fd; |
int fd; |
192 |
|
|
193 |
/* If we have a kernel random device, use it. */ |
/* If we have a kernel random device, use it. */ |
201 |
/* Otherwise use whatever entropy we can gather - ideas welcome. */ |
/* Otherwise use whatever entropy we can gather - ideas welcome. */ |
202 |
r[0] = (getpid()) | (getppid() << 16); |
r[0] = (getpid()) | (getppid() << 16); |
203 |
r[1] = (getuid()) | (getgid() << 16); |
r[1] = (getuid()) | (getgid() << 16); |
204 |
r[2] = times(NULL); /* system uptime (clocks) */ |
r[2] = times(&tmsbuf); /* system uptime (clocks) */ |
205 |
gettimeofday((struct timeval *)&r[3], NULL); /* sec and usec */ |
gettimeofday((struct timeval *) &r[3], NULL); /* sec and usec */ |
206 |
stat("/tmp", &st); |
stat("/tmp", &st); |
207 |
r[5] = st.st_atime; |
r[5] = st.st_atime; |
208 |
r[6] = st.st_mtime; |
r[6] = st.st_mtime; |
254 |
thisline = 16; |
thisline = 16; |
255 |
|
|
256 |
for (i = 0; i < thisline; i++) |
for (i = 0; i < thisline; i++) |
257 |
STATUS("%02x ", line[i]) |
STATUS("%02x ", line[i]) for (; i < 16; i++) |
258 |
|
STATUS(" "); |
|
for (; i < 16; i++) |
|
|
STATUS(" "); |
|
259 |
|
|
260 |
for (i = 0; i < thisline; i++) |
for (i = 0; i < thisline; i++) |
261 |
STATUS("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.'); |
STATUS("%c", |
262 |
|
(line[i] >= 0x20 |
263 |
|
&& line[i] < 0x7f) ? line[i] : '.'); |
264 |
|
|
265 |
STATUS("\n"); |
STATUS("\n"); |
266 |
offset += thisline; |
offset += thisline; |