Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
libvncserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rasky
libvncserver
Commits
11271316
Commit
11271316
authored
Jun 18, 2004
by
dscho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support password reading with getpass(); support -play to play vncrec'orded files
parent
a7446d71
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
24 deletions
+122
-24
rfbproto.c
libvncclient/rfbproto.c
+48
-17
sockets.c
libvncclient/sockets.c
+39
-1
vncviewer.c
libvncclient/vncviewer.c
+35
-6
No files found.
libvncclient/rfbproto.c
View file @
11271316
...
@@ -175,8 +175,7 @@ static rfbBool decompStreamInited = FALSE;
...
@@ -175,8 +175,7 @@ static rfbBool decompStreamInited = FALSE;
*/
*/
/* Separate buffer for compressed data. */
/* Separate buffer for compressed data. */
// TODO:
/* TODO: threading issues */
// #define ZLIB_BUFFER_SIZE 512
#define ZLIB_BUFFER_SIZE 30000
#define ZLIB_BUFFER_SIZE 30000
static
char
zlib_buffer
[
ZLIB_BUFFER_SIZE
];
static
char
zlib_buffer
[
ZLIB_BUFFER_SIZE
];
...
@@ -205,6 +204,33 @@ ConnectToRFBServer(rfbClient* client,const char *hostname, int port)
...
@@ -205,6 +204,33 @@ ConnectToRFBServer(rfbClient* client,const char *hostname, int port)
{
{
unsigned
int
host
;
unsigned
int
host
;
if
(
client
->
serverPort
==-
1
)
{
/* serverHost is a file recorded by vncrec. */
const
char
*
magic
=
"vncLog0.0"
;
char
buffer
[
10
];
rfbVNCRec
*
rec
=
(
rfbVNCRec
*
)
malloc
(
sizeof
(
rfbVNCRec
));
client
->
vncRec
=
rec
;
rec
->
file
=
fopen
(
client
->
serverHost
,
"rb"
);
rec
->
tv
.
tv_sec
=
0
;
rec
->
readTimestamp
=
FALSE
;
rec
->
doNotSleep
=
FALSE
;
if
(
!
rec
->
file
)
{
rfbClientLog
(
"Could not open %s.
\n
"
,
client
->
serverHost
);
return
FALSE
;
}
setbuf
(
rec
->
file
,
0
);
fread
(
buffer
,
1
,
strlen
(
magic
),
rec
->
file
);
if
(
strncmp
(
buffer
,
magic
,
strlen
(
magic
)))
{
rfbClientLog
(
"File %s was not recorded by vncrec.
\n
"
,
client
->
serverHost
);
fclose
(
rec
->
file
);
return
FALSE
;
}
client
->
sock
=
0
;
return
TRUE
;
}
if
(
!
StringToIPAddr
(
hostname
,
&
host
))
{
if
(
!
StringToIPAddr
(
hostname
,
&
host
))
{
rfbClientLog
(
"Couldn't convert '%s' to host address
\n
"
,
hostname
);
rfbClientLog
(
"Couldn't convert '%s' to host address
\n
"
,
hostname
);
return
FALSE
;
return
FALSE
;
...
@@ -289,6 +315,7 @@ InitialiseRFBConnection(rfbClient* client)
...
@@ -289,6 +315,7 @@ InitialiseRFBConnection(rfbClient* client)
case
rfbVncAuth
:
case
rfbVncAuth
:
if
(
!
ReadFromRFBServer
(
client
,
(
char
*
)
challenge
,
CHALLENGESIZE
))
return
FALSE
;
if
(
!
ReadFromRFBServer
(
client
,
(
char
*
)
challenge
,
CHALLENGESIZE
))
return
FALSE
;
if
(
client
->
serverPort
!=-
1
)
{
/* if not playing a vncrec file */
if
(
client
->
GetPassword
)
if
(
client
->
GetPassword
)
passwd
=
client
->
GetPassword
(
client
);
passwd
=
client
->
GetPassword
(
client
);
...
@@ -306,8 +333,10 @@ InitialiseRFBConnection(rfbClient* client)
...
@@ -306,8 +333,10 @@ InitialiseRFBConnection(rfbClient* client)
for
(
i
=
strlen
(
passwd
);
i
>=
0
;
i
--
)
{
for
(
i
=
strlen
(
passwd
);
i
>=
0
;
i
--
)
{
passwd
[
i
]
=
'\0'
;
passwd
[
i
]
=
'\0'
;
}
}
free
(
passwd
);
if
(
!
WriteToRFBServer
(
client
,
(
char
*
)
challenge
,
CHALLENGESIZE
))
return
FALSE
;
if
(
!
WriteToRFBServer
(
client
,
(
char
*
)
challenge
,
CHALLENGESIZE
))
return
FALSE
;
}
if
(
!
ReadFromRFBServer
(
client
,
(
char
*
)
&
authResult
,
4
))
return
FALSE
;
if
(
!
ReadFromRFBServer
(
client
,
(
char
*
)
&
authResult
,
4
))
return
FALSE
;
...
@@ -638,6 +667,8 @@ HandleRFBServerMessage(rfbClient* client)
...
@@ -638,6 +667,8 @@ HandleRFBServerMessage(rfbClient* client)
{
{
rfbServerToClientMsg
msg
;
rfbServerToClientMsg
msg
;
if
(
client
->
serverPort
==-
1
)
client
->
vncRec
->
readTimestamp
=
TRUE
;
if
(
!
ReadFromRFBServer
(
client
,
(
char
*
)
&
msg
,
1
))
if
(
!
ReadFromRFBServer
(
client
,
(
char
*
)
&
msg
,
1
))
return
FALSE
;
return
FALSE
;
...
...
libvncclient/sockets.c
View file @
11271316
...
@@ -58,12 +58,43 @@ static int buffered = 0;
...
@@ -58,12 +58,43 @@ static int buffered = 0;
rfbBool
rfbBool
ReadFromRFBServer
(
rfbClient
*
client
,
char
*
out
,
unsigned
int
n
)
ReadFromRFBServer
(
rfbClient
*
client
,
char
*
out
,
unsigned
int
n
)
{
{
//#define
DEBUG_READ_EXACT
#undef
DEBUG_READ_EXACT
#ifdef DEBUG_READ_EXACT
#ifdef DEBUG_READ_EXACT
char
*
oout
=
out
;
char
*
oout
=
out
;
int
nn
=
n
;
int
nn
=
n
;
rfbClientLog
(
"ReadFromRFBServer %d bytes
\n
"
,
n
);
rfbClientLog
(
"ReadFromRFBServer %d bytes
\n
"
,
n
);
#endif
#endif
if
(
client
->
serverPort
==-
1
)
{
/* vncrec playing */
rfbVNCRec
*
rec
=
client
->
vncRec
;
struct
timeval
tv
;
if
(
rec
->
readTimestamp
)
{
rec
->
readTimestamp
=
FALSE
;
if
(
!
fread
(
&
tv
,
sizeof
(
struct
timeval
),
1
,
rec
->
file
))
return
FALSE
;
tv
.
tv_sec
=
rfbClientSwap32IfLE
(
tv
.
tv_sec
);
tv
.
tv_usec
=
rfbClientSwap32IfLE
(
tv
.
tv_usec
);
if
(
rec
->
tv
.
tv_sec
!=
0
&&
!
rec
->
doNotSleep
)
{
struct
timeval
diff
;
diff
.
tv_sec
=
tv
.
tv_sec
-
rec
->
tv
.
tv_sec
;
diff
.
tv_usec
=
tv
.
tv_usec
-
rec
->
tv
.
tv_usec
;
if
(
diff
.
tv_usec
<
0
)
{
diff
.
tv_sec
--
;
diff
.
tv_usec
+=
1000000
;
}
sleep
(
diff
.
tv_sec
);
usleep
(
diff
.
tv_usec
);
}
rec
->
tv
=
tv
;
}
return
(
fread
(
out
,
1
,
n
,
rec
->
file
)
<
0
?
FALSE
:
TRUE
);
}
if
(
n
<=
buffered
)
{
if
(
n
<=
buffered
)
{
memcpy
(
out
,
bufoutptr
,
n
);
memcpy
(
out
,
bufoutptr
,
n
);
bufoutptr
+=
n
;
bufoutptr
+=
n
;
...
@@ -161,6 +192,9 @@ WriteToRFBServer(rfbClient* client, char *buf, int n)
...
@@ -161,6 +192,9 @@ WriteToRFBServer(rfbClient* client, char *buf, int n)
int
i
=
0
;
int
i
=
0
;
int
j
;
int
j
;
if
(
client
->
serverPort
==-
1
)
return
TRUE
;
/* vncrec playing */
while
(
i
<
n
)
{
while
(
i
<
n
)
{
j
=
write
(
client
->
sock
,
buf
+
i
,
(
n
-
i
));
j
=
write
(
client
->
sock
,
buf
+
i
,
(
n
-
i
));
if
(
j
<=
0
)
{
if
(
j
<=
0
)
{
...
@@ -445,6 +479,10 @@ int WaitForMessage(rfbClient* client,unsigned int usecs)
...
@@ -445,6 +479,10 @@ int WaitForMessage(rfbClient* client,unsigned int usecs)
struct
timeval
timeout
;
struct
timeval
timeout
;
int
num
;
int
num
;
if
(
client
->
serverPort
==-
1
)
/* playing back vncrec file */
return
1
;
timeout
.
tv_sec
=
(
usecs
/
1000000
);
timeout
.
tv_sec
=
(
usecs
/
1000000
);
timeout
.
tv_usec
=
(
usecs
%
1000000
);
timeout
.
tv_usec
=
(
usecs
%
1000000
);
...
...
libvncclient/vncviewer.c
View file @
11271316
...
@@ -34,7 +34,23 @@ static rfbBool DummyPoint(rfbClient* client, int x, int y) {
...
@@ -34,7 +34,23 @@ static rfbBool DummyPoint(rfbClient* client, int x, int y) {
static
void
DummyRect
(
rfbClient
*
client
,
int
x
,
int
y
,
int
w
,
int
h
)
{
static
void
DummyRect
(
rfbClient
*
client
,
int
x
,
int
y
,
int
w
,
int
h
)
{
}
}
static
char
*
NoPassword
(
rfbClient
*
client
)
{
static
char
*
NoPassword
(
rfbClient
*
client
)
{
return
""
;
return
strdup
(
""
);
}
#include <stdio.h>
#include <termios.h>
static
char
*
ReadPassword
(
rfbClient
*
client
)
{
int
i
=
8
;
char
*
p
=
malloc
(
9
);
struct
termios
save
,
noecho
;
p
[
0
]
=
0
;
if
(
tcgetattr
(
fileno
(
stdin
),
&
save
)
!=
0
)
return
p
;
noecho
=
save
;
noecho
.
c_lflag
&=
~
ECHO
;
if
(
tcsetattr
(
fileno
(
stdin
),
TCSAFLUSH
,
&
noecho
)
!=
0
)
return
p
;
fprintf
(
stderr
,
"Password: "
);
getline
(
&
p
,
&
i
,
stdin
);
if
(
i
>
0
&&
p
[
i
-
2
]
==
'\n'
)
p
[
i
-
2
]
=
0
;
tcsetattr
(
fileno
(
stdin
),
TCSAFLUSH
,
&
save
);
return
p
;
}
}
static
rfbBool
MallocFrameBuffer
(
rfbClient
*
client
)
{
static
rfbBool
MallocFrameBuffer
(
rfbClient
*
client
)
{
if
(
client
->
frameBuffer
)
if
(
client
->
frameBuffer
)
...
@@ -107,7 +123,7 @@ rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel,
...
@@ -107,7 +123,7 @@ rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel,
client
->
SoftCursorLockArea
=
DummyRect
;
client
->
SoftCursorLockArea
=
DummyRect
;
client
->
SoftCursorUnlockScreen
=
Dummy
;
client
->
SoftCursorUnlockScreen
=
Dummy
;
client
->
GotFrameBufferUpdate
=
DummyRect
;
client
->
GotFrameBufferUpdate
=
DummyRect
;
client
->
GetPassword
=
No
Password
;
client
->
GetPassword
=
Read
Password
;
client
->
MallocFrameBuffer
=
MallocFrameBuffer
;
client
->
MallocFrameBuffer
=
MallocFrameBuffer
;
client
->
Bell
=
Dummy
;
client
->
Bell
=
Dummy
;
...
@@ -143,15 +159,22 @@ static rfbBool rfbInitConnection(rfbClient* client)
...
@@ -143,15 +159,22 @@ static rfbBool rfbInitConnection(rfbClient* client)
}
}
rfbBool
rfbInitClient
(
rfbClient
*
client
,
int
*
argc
,
char
**
argv
)
{
rfbBool
rfbInitClient
(
rfbClient
*
client
,
int
*
argc
,
char
**
argv
)
{
int
i
;
int
i
,
j
;
if
(
client
->
programName
==
0
)
if
(
client
->
programName
==
0
)
client
->
programName
=
argv
[
0
];
client
->
programName
=
argv
[
0
];
for
(
i
=
1
;
i
<
*
argc
;
i
++
)
{
for
(
i
=
1
;
i
<
*
argc
;
i
++
)
{
j
=
i
;
if
(
strcmp
(
argv
[
i
],
"-listen"
)
==
0
)
{
if
(
strcmp
(
argv
[
i
],
"-listen"
)
==
0
)
{
listenForIncomingConnections
(
client
);
listenForIncomingConnections
(
client
);
break
;
break
;
}
else
if
(
strcmp
(
argv
[
i
],
"-play"
)
==
0
)
{
client
->
serverPort
=
-
1
;
j
++
;
}
else
if
(
i
+
1
<*
argc
&&
strcmp
(
argv
[
i
],
"-encodings"
)
==
0
)
{
client
->
appData
.
encodingsString
=
argv
[
i
+
1
];
j
+=
2
;
}
else
{
}
else
{
char
*
colon
=
strchr
(
argv
[
i
],
':'
);
char
*
colon
=
strchr
(
argv
[
i
],
':'
);
...
@@ -159,10 +182,16 @@ rfbBool rfbInitClient(rfbClient* client,int* argc,char** argv) {
...
@@ -159,10 +182,16 @@ rfbBool rfbInitClient(rfbClient* client,int* argc,char** argv) {
if
(
colon
)
{
if
(
colon
)
{
*
colon
=
0
;
*
colon
=
0
;
client
->
serverPort
=
atoi
(
colon
+
1
);
client
->
serverPort
=
atoi
(
colon
+
1
);
}
else
}
client
->
serverPort
=
0
;
if
(
client
->
serverPort
>=
0
&&
client
->
serverPort
<
5900
)
client
->
serverPort
+=
5900
;
client
->
serverPort
+=
5900
;
}
}
/* purge arguments */
if
(
j
>
i
)
{
*
argc
-=
j
-
i
;
memmove
(
argv
+
i
,
argv
+
j
,(
*
argc
-
i
)
*
sizeof
(
char
*
));
i
--
;
}
}
}
if
(
!
rfbInitConnection
(
client
))
{
if
(
!
rfbInitConnection
(
client
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment