diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index eb9cb6b2..3ede96a6 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -253,26 +253,28 @@ STRING *publickey_to_string(PUBLIC_KEY *key); PUBLIC_KEY *publickey_from_privatekey(PRIVATE_KEY *prv); void private_key_free(PRIVATE_KEY *prv); STRING *publickey_from_file(SSH_SESSION *session, char *filename,int *_type); -STRING *publickey_from_next_file(SSH_SESSION *session,char **pub_keys_path,char **keys_path, - char **privkeyfile,int *type,int *count); +STRING *publickey_from_next_file(SSH_SESSION *session, const char **pub_keys_path, + const char **keys_path, char **privkeyfile, int *type, int *count); int ssh_is_server_known(SSH_SESSION *session); int ssh_write_knownhost(SSH_SESSION *session); /* in channels.c */ CHANNEL *channel_new(SSH_SESSION *session); -int channel_open_forward(CHANNEL *channel,char *remotehost, int remoteport, char *sourcehost, int localport); +int channel_open_forward(CHANNEL *channel, const char *remotehost, + int remoteport, const char *sourcehost, int localport); int channel_open_session(CHANNEL *channel); void channel_free(CHANNEL *channel); int channel_request_pty(CHANNEL *channel); -int channel_request_pty_size(CHANNEL *channel, char *term,int cols, int rows); +int channel_request_pty_size(CHANNEL *channel, const char *term, + int cols, int rows); int channel_change_pty_size(CHANNEL *channel,int cols,int rows); int channel_request_shell(CHANNEL *channel); -int channel_request_subsystem(CHANNEL *channel, char *system); -int channel_request_env(CHANNEL *channel,char *name, char *value); -int channel_request_exec(CHANNEL *channel, char *cmd); +int channel_request_subsystem(CHANNEL *channel, const char *system); +int channel_request_env(CHANNEL *channel, const char *name, const char *value); +int channel_request_exec(CHANNEL *channel, const char *cmd); int channel_request_sftp(CHANNEL *channel); -int channel_write(CHANNEL *channel, void *data, u32 len); +int channel_write(CHANNEL *channel, const void *data, u32 len); int channel_send_eof(CHANNEL *channel); int channel_is_eof(CHANNEL *channel); int channel_read(CHANNEL *channel, BUFFER *buffer, u32 bytes, int is_stderr); diff --git a/libssh/channels.c b/libssh/channels.c index ae45c7f4..04242cab 100644 --- a/libssh/channels.c +++ b/libssh/channels.c @@ -76,8 +76,8 @@ u32 ssh_channel_new_id(SSH_SESSION *session){ return ret; } -static int channel_open(CHANNEL *channel,char *type_c,int window, - int maxpacket,BUFFER *payload){ +static int channel_open(CHANNEL *channel, const char *type_c, int window, + int maxpacket, BUFFER *payload) { SSH_SESSION *session=channel->session; STRING *type=string_from_char(type_c); u32 foo; @@ -348,7 +348,7 @@ static void channel_rcv_request(SSH_SESSION *session){ if(!strcmp(request,"exit-signal")){ STRING *signal_s; char *signal; - char *core="(core dumped)"; + const char *core = "(core dumped)"; u8 i; signal_s=buffer_get_ssh_string(session->in_buffer); if(!signal_s){ @@ -459,7 +459,8 @@ int channel_open_session(CHANNEL *channel){ * SSH_OK on success * \warning API changed from 0.11 */ -int channel_open_forward(CHANNEL *channel,char *remotehost, int remoteport, char *sourcehost, int localport){ +int channel_open_forward(CHANNEL *channel, const char *remotehost, + int remoteport, const char *sourcehost, int localport) { BUFFER *payload=buffer_new(); STRING *str=string_from_char(remotehost); SSH_SESSION *session=channel->session; @@ -581,7 +582,7 @@ int channel_close(CHANNEL *channel){ * SSH_ERROR on error * \see channel_read() */ -int channel_write(CHANNEL *channel, void *data, u32 len) { +int channel_write(CHANNEL *channel, const void *data, u32 len) { SSH_SESSION *session=channel->session; int effectivelen; int origlen=len; @@ -675,7 +676,8 @@ void channel_set_blocking(CHANNEL *channel, int blocking){ channel->blocking=blocking; } -static int channel_request(CHANNEL *channel,char *request, BUFFER *buffer,int reply){ +static int channel_request(CHANNEL *channel, const char *request, + BUFFER *buffer, int reply) { STRING *request_s=string_from_char(request); SSH_SESSION *session=channel->session; int err; @@ -718,7 +720,8 @@ static int channel_request(CHANNEL *channel,char *request, BUFFER *buffer,int re * \return SSH_SUCCESS on success\n * SSH_ERROR on error */ -int channel_request_pty_size(CHANNEL *channel, char *terminal, int col, int row){ +int channel_request_pty_size(CHANNEL *channel, const char *terminal, + int col, int row) { STRING *term; BUFFER *buffer; SSH_SESSION *session=channel->session; @@ -811,10 +814,10 @@ int channel_request_shell(CHANNEL *channel){ * \warning you normally don't have to call it to have sftp * \see sftp_new() */ -int channel_request_subsystem(CHANNEL *channel, char *system){ +int channel_request_subsystem(CHANNEL *channel, const char *sys){ BUFFER* buffer=buffer_new(); int ret; - STRING *subsystem=string_from_char(system); + STRING *subsystem=string_from_char(sys); buffer_add_ssh_string(buffer,subsystem); free(subsystem); ret=channel_request(channel,"subsystem",buffer,1); @@ -834,7 +837,7 @@ int channel_request_sftp( CHANNEL *channel){ * SSH_ERROR on error * \warning some environement variables may be refused by security * */ -int channel_request_env(CHANNEL *channel,char *name, char *value){ +int channel_request_env(CHANNEL *channel, const char *name, const char *value){ BUFFER *buffer=buffer_new(); int ret; STRING *string=string_from_char(name); @@ -856,7 +859,7 @@ int channel_request_env(CHANNEL *channel,char *name, char *value){ * SSH_ERROR on error * \see channel_request_shell() */ -int channel_request_exec(CHANNEL *channel, char *cmd){ +int channel_request_exec(CHANNEL *channel, const char *cmd) { BUFFER *buffer; STRING *command; int ret; diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c index 7d922270..fde20865 100644 --- a/libssh/keyfiles.c +++ b/libssh/keyfiles.c @@ -739,8 +739,8 @@ STRING *publickey_from_file(SSH_SESSION *session,char *filename,int *_type){ /* why recursing ? i'll explain. on top, publickey_from_next_file will be executed until NULL returned */ /* we can't return null if one of the possible keys is wrong. we must test them before getting over */ -STRING *publickey_from_next_file(SSH_SESSION *session,char **pub_keys_path,char **keys_path, - char **privkeyfile,int *type,int *count){ +STRING *publickey_from_next_file(SSH_SESSION *session, const char **pub_keys_path, + const char **keys_path, char **privkeyfile, int *type, int *count) { static char *home=NULL; char public[256]; char private[256];