Commit 68530f0f authored by Konstantin Artyushkin's avatar Konstantin Artyushkin

Added nx-stub.c proxy.c and proxy.h files with new ssh API

parent 22d52905
/*
* NX proxy stubs for programs that link against libssh.a
* but don't use NX proxy functionality (sshd, ssh-keygen).
*
* These stubs satisfy the linker for NX symbols referenced
* by channels.c and packet.c without pulling in proxy.c
* and its NXcomp dependency.
*/
#include "includes.h"
#include <sys/types.h>
#include <poll.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include "proxy.h"
/* NX global variables - stub definitions */
int nx_proxy_log = 0;
int nx_check_switch = 0;
int nx_switch_received = 0;
char nx_switch_cookie[256];
char nx_switch_host[256];
int nx_switch_proxy = 0;
int nx_switch_port = 0;
int nx_switch_in = -1;
int nx_switch_out = -1;
char nx_switch_mode[256];
char nx_switch_options[1024];
int nx_switch_internal = 0;
int nx_switch_forward = 0;
/* NX global variables used in ssh.c, sshconnect*.c, readpass.c */
int NxModeEnabled = 0;
int NxAuthOnlyModeEnabled = 0;
int NXStdinPassEnabled = 0;
int NXServerMode = 0;
int NxAdminModeEnabled = 0;
/* Stub function implementations */
int
nx_check_channel_input(struct Channel *channel, char *data,
int *length, int limit)
{
return 0;
}
void
nx_proxy_init(void)
{
}
int
nx_proxy_select(int maxfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout)
{
return select(maxfds, readfds, writefds, exceptfds, timeout);
}
int
nx_proxy_ppoll(struct pollfd *fds, nfds_t nfds,
const struct timespec *timeout, const sigset_t *sigmask)
{
return ppoll(fds, nfds, timeout, sigmask);
}
int
nx_open_proxy_connection(void)
{
return -1;
}
int
nx_close_proxy_connection(void)
{
return 0;
}
int
nx_check_proxy_authentication(int proxy_fd)
{
return 0;
}
int
nx_switch_client_side_descriptors(struct Channel *channel, int proxy_fd)
{
return 0;
}
int
nx_switch_forward_descriptors(struct Channel *channel)
{
return 0;
}
int
nx_switch_forward_port(struct Channel *channel)
{
return 0;
}
int
nx_check_standard_input(void)
{
return 0;
}
void
nx_switch_server_side_descriptors(void)
{
}
void
nx_set_socket_options(int fd, int blocking)
{
}
const char *
nx_get_environment(const char *name)
{
return getenv(name);
}
int
nx_set_environment(const char *name, const char *value)
{
return setenv(name, value, 1);
}
This diff is collapsed. Click to expand it.
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
/* */
/* NXSSH, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
#ifndef _NX_PROXY_H
#define _NX_PROXY_H
#include <poll.h>
struct Channel;
/*
* Do we share the debug log with the proxy?
*/
extern int nx_proxy_log;
/*
* Do we check for the incoming command? This flag
* should be bound to a command line parameter.
*/
extern int nx_check_switch;
/*
* Did we receive the command? Switch is executed at
* the time the first channel receives the command,
* thus it is important to note that port forwarding
* should always be disabled when enabling the check.
*/
extern int nx_switch_received;
/*
* Parameters read from the switch command.
*/
extern char nx_switch_cookie[256];
extern char nx_switch_host[256];
extern int nx_switch_proxy;
extern int nx_switch_port;
extern int nx_switch_in;
extern int nx_switch_out;
extern char nx_switch_mode[256];
extern char nx_switch_options[1024];
extern int nx_switch_internal;
extern int nx_switch_forward;
/*
* Buffer the input while looking for the command.
* The buffering happens by flushing the input when
* a newline is received. This means that all input
* should be terminated with a newline or it will
* remain in the buffer and will never be sent to
* the packet interface.
*/
int nx_check_channel_input(struct Channel *channel, char *data, int *length, int limit);
/*
* Init buffer
*/
void nx_proxy_init(void);
/*
* Replace the select() with the version managing
* the NX descriptors.
*/
int nx_proxy_select(int maxfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout);
/*
* ppoll()-compatible wrapper that integrates NX transport.
* Converts pollfd[] <-> fd_set, calls NXTransPrepare/Select/Execute.
*/
int nx_proxy_ppoll(struct pollfd *fds, nfds_t nfds,
const struct timespec *timeout,
const sigset_t *sigmask);
/*
* Connect to the NX transport.
*/
int nx_open_proxy_connection(void);
/*
* Wait for the NX transport to terminate.
*/
int nx_close_proxy_connection(void);
/*
* If cookie was passed, manage authentication.
*/
int nx_check_proxy_authentication(int proxy_fd);
/*
* Reassign the descriptors.
*/
int nx_switch_client_side_descriptors(struct Channel *channel, int proxy_fd);
/*
* Reassign the descriptors.
*/
int nx_switch_forward_descriptors(struct Channel *channel);
/*
* Forward port to remote sshd.
*/
int nx_switch_forward_port(struct Channel *channel);
/*
* Used in ssh.c to monitor the standard input
* until the switch command is received.
*/
int nx_check_standard_input(void);
/*
* Used in ssh.c. Connect to the proxy and run the
* restricted loop forwarding the traffic to the
* local proxy.
*/
void nx_switch_server_side_descriptors(void);
/*
* Set the preferred options for using the socket
* with NX.
*/
void nx_set_socket_options(int fd, int blocking);
/*
* Wrappers used to get and set the environment.
*/
const char *nx_get_environment(const char *name);
int nx_set_environment(const char *name, const char *value);
#endif /* _NX_PROXY_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment