src/vsl_ssh.c File Reference

Functions to perform SSH Starting Mode handshake. More...

#include "vsl_ssh.h"
#include "vsl_util.h"
#include "vsl.h"
#include <sys/types.h>
#include <sys/wait.h>
#include <netdb.h>
#include <sys/select.h>
#include <fcntl.h>

Go to the source code of this file.

Data Structures

struct  ssh_msg_port
 message containing the port More...
struct  ssh_msg_secret
 message containing the secret More...

Functions

int ssh_close (vsl_sock *sock, char *errmsg)
int ssh_daemonize (void)
int ssh_fork (vsl_sock *sock, const char *host, const char *user, const char *cmd, int argc, const char *const *argv)
int ssh_read_port (vsl_sock *sock, int *port)
int ssh_read_secret (unsigned char *secret)
int ssh_send_port (int port)
int ssh_send_secret (vsl_sock *sock, const unsigned char *secret)
int ssh_vfer_accept (vsl_sock *sock)
int ssh_vfer_connect (vsl_sock *sock, const char *host, int port)
int ssh_vfer_listen (vsl_sock *sock, int *port)


Detailed Description

Functions to perform SSH Starting Mode handshake.

Author:
Nikolaus Rath

Definition in file vsl_ssh.c.


Function Documentation

int ssh_close ( vsl_sock sock,
char *  errmsg 
)

Close ssh process

Parameters:
[in] sock socket to use
[out] errmsg if the ssh process returned an error message, it is written into this variable, which has to have a minimum length of 513 bytes.
Returns:
  • 0 on success
  • VFER_INPROGRESS if the socket is nonblocking and the call would block.
  • VSL_SSHF if the ssh process failed
  • VSL_TEMP if the server signaled a temporary error
  • VSL_PERM if the server signaled a permanent error
  • VSL_BADPROT in case of a protocol error
  • VSL_ERRNO for all other errors (errno is set accordingly)

Todo:
This close call often fails with 'Bad file descriptor!' -- ist that normal behaviour if the program has quit and there's no data on the pipe?

Definition at line 266 of file vsl_ssh.c.

int ssh_daemonize ( void   ) 

Daemonizes the process

Returns:
  • 0 on success
  • VSL_ERRNO if a system call failed (errno is set accordingly)

Definition at line 562 of file vsl_ssh.c.

int ssh_fork ( vsl_sock sock,
const char *  host,
const char *  user,
const char *  cmd,
int  argc,
const char *const *  argv 
)

Fork ssh process to connect to remote host and and start server process.

Stores pid and stdin of the ssh process in the socket.

Parameters:
[in] sock VSL socket to use
[in] host hostname to connect to
[in] user username for SSH connection, NULL to use current user
[in] cmd program name of the server application
[in] argc number of arguments in argv that are passed to the server application
[in] argv arguments that is passed to the server application
Returns:
  • 0 on success
  • VSL_ERRNO for all other errors (errno is set accordingly)

Definition at line 51 of file vsl_ssh.c.

int ssh_read_port ( vsl_sock sock,
int *  port 
)

Read port number from ssh process

Parameters:
[in] sock socket to use
[out] port read port
Returns:
  • 0 on success
  • VFER_INPROGRESS if the socket is nonblocking and the call would block.
  • VSL_BADPROT in case of a protocol error
  • VSL_ERRNO for all other errors (errno is set accordingly)

Definition at line 220 of file vsl_ssh.c.

int ssh_read_secret ( unsigned char *  secret  ) 

Reads the secret from stdin and stores it in the socket.

Parameters:
[out] secret variable to store secret in, minimum length VSL_KEYLEN
Returns:
  • 0 on success
  • VSL_BADPROT in case of a protocol error
  • VSL_ERRNO if a system call failed (errno is set accordingly)

Definition at line 414 of file vsl_ssh.c.

int ssh_send_port ( int  port  ) 

Prints the given port

Parameters:
[in] port port
Returns:
  • 0 on success
  • VSL_ERRNO if a system call failed (errno is set accordingly)

Definition at line 493 of file vsl_ssh.c.

int ssh_send_secret ( vsl_sock sock,
const unsigned char *  secret 
)

Sends the secret over the ssh connection.

Parameters:
[in] sock socket to use
[in] secret secret to send (length VSL_KEYLENGTH)
Returns:
  • 0 on success
  • VFER_INPROGRESS if the socket is nonblocking and the call would block.
  • VSL_ERRNO for all other errors (errno is set accordingly)

Definition at line 167 of file vsl_ssh.c.

int ssh_vfer_accept ( vsl_sock sock  ) 

Waits for a vfer connection and closes the listening socket.

Parameters:
[in] sock socket to use
Returns:

Definition at line 531 of file vsl_ssh.c.

int ssh_vfer_connect ( vsl_sock sock,
const char *  host,
int  port 
)

Establish a VFER connection to the given host

Parameters:
[in] sock VSL socket to use
[in] host hostname to connect to
[in] port port to connect to
Returns:
  • 0 on success
  • VSL_ERRNO for all other errors (errno is set accordingly)

Todo:
Disabled, for debbugging we use blocking IO.

Definition at line 349 of file vsl_ssh.c.

int ssh_vfer_listen ( vsl_sock sock,
int *  port 
)

Configures the socket to listen on a free port and returns that port.

Parameters:
[in] sock socket to use
[out] port reserved port
Returns:
  • 0 on success
  • VSL_ERRNO if a system call failed (errno is set accordingly)

Definition at line 456 of file vsl_ssh.c.


Generated on Tue Aug 8 16:07:22 2006 for VFER by  doxygen 1.4.7