Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
79fb0d4d
Commit
79fb0d4d
authored
Apr 21, 2011
by
Rémi Duraffort
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sftp: lookup for the knowhosts and check if the remote key match.
parent
bba2eae5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
7 deletions
+40
-7
modules/access/sftp.c
modules/access/sftp.c
+40
-7
No files found.
modules/access/sftp.c
View file @
79fb0d4d
...
...
@@ -108,6 +108,8 @@ static int Open( vlc_object_t* p_this )
int
i_port
;
int
i_ret
;
vlc_url_t
url
;
size_t
i_len
;
int
i_type
;
if
(
!
p_access
->
psz_location
)
return
VLC_EGENERIC
;
...
...
@@ -162,15 +164,46 @@ static int Open( vlc_object_t* p_this )
goto
error
;
}
/* Ask for the fingerprint ... */
// TODO: check it
/* Set the socket in non-blocking mode */
libssh2_session_set_blocking
(
p_sys
->
ssh_session
,
1
);
const
char
*
fingerprint
=
libssh2_hostkey_hash
(
p_sys
->
ssh_session
,
LIBSSH2_HOSTKEY_HASH_MD5
);
fprintf
(
stderr
,
"Fingerprint: "
);
for
(
int
i
=
0
;
i
<
16
;
i
++
)
{
fprintf
(
stderr
,
"%02X "
,
(
unsigned
char
)
fingerprint
[
i
]);
/* List the know hosts */
LIBSSH2_KNOWNHOSTS
*
ssh_knownhosts
=
libssh2_knownhost_init
(
p_sys
->
ssh_session
);
if
(
!
ssh_knownhosts
)
goto
error
;
char
*
psz_home
=
config_GetUserDir
(
VLC_HOME_DIR
);
char
*
psz_knownhosts_file
;
asprintf
(
&
psz_knownhosts_file
,
"%s/.ssh/known_hosts"
,
psz_home
);
libssh2_knownhost_readfile
(
ssh_knownhosts
,
psz_knownhosts_file
,
LIBSSH2_KNOWNHOST_FILE_OPENSSH
);
free
(
psz_knownhosts_file
);
free
(
psz_home
);
const
char
*
fingerprint
=
libssh2_session_hostkey
(
p_sys
->
ssh_session
,
&
i_len
,
&
i_type
);
struct
libssh2_knownhost
*
host
;
int
check
=
libssh2_knownhost_check
(
ssh_knownhosts
,
url
.
psz_host
,
fingerprint
,
i_len
,
LIBSSH2_KNOWNHOST_TYPE_PLAIN
|
LIBSSH2_KNOWNHOST_KEYENC_RAW
,
&
host
);
libssh2_knownhost_free
(
ssh_knownhosts
);
/* Check that it does match or at least that the host is unkown */
switch
(
check
)
{
case
LIBSSH2_KNOWNHOST_CHECK_FAILURE
:
case
LIBSSH2_KNOWNHOST_CHECK_NOTFOUND
:
msg_Dbg
(
p_access
,
"Unable to check the remote host"
);
break
;
case
LIBSSH2_KNOWNHOST_CHECK_MATCH
:
msg_Dbg
(
p_access
,
"Succesfuly matched the host"
);
break
;
case
LIBSSH2_KNOWNHOST_CHECK_MISMATCH
:
msg_Err
(
p_access
,
"The host does not match !! The remote key changed !!"
);
goto
error
;
}
fprintf
(
stderr
,
"
\n
"
);
//TODO: ask for the available auth methods
...
...
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