[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FSTP server question


Hi all.

I am trying to create a SSH/SFTP server in windows.
With the Sample I was able to get the SSH part running, but I am trying to figure out the SFTP part.
I have assign a callback for the subsystem_request_function = (subsystem_request) which will check for SFTP request(see below function subsystem_request).
With What I was able to find on the net as a SFTP Server sample ,I call sftp_server_new and  sftp_server_init. But sftp_server_init always failed.

Any help will be great
Thanks
Ricky

static ssh_channel new_session_channel(ssh_session session, void *userdata)
{
       (void) session;
       (void) userdata;
       if(chan != NULL)
             return NULL;
       printf("Allocated session channel\n");
       channel_cb.channel_subsystem_request_function = subsystem_request;
       channel_cb.channel_pty_request_function = pty_request;
       channel_cb.channel_shell_request_function = shell_request;
       chan = ssh_channel_new(session);
       ssh_callbacks_init(&channel_cb);
       ssh_set_channel_callbacks(chan, &channel_cb);
       return chan;
}


static int subsystem_request(ssh_session session, ssh_channel channel,  const char *subsystem, void *userdata)
{
    struct channel_data_struct *cdata = (struct channel_data_struct *)userdata;
    int rc = 1;

    if (strcmp(subsystem, "sftp"))
        return SSH_ERROR;
        sftp_session sftp = sftp_server_new(session,channel );

        if(!sftp)
        {
                fprintf(stderr, "sftp error initialising channel: %s\n",
                        ssh_get_error(session));
                return 0;
        }
        if(sftp_server_init(sftp))
        {
                fprintf(stderr, "error initialising sftp: %s\n",
                        ssh_get_error(session));
                return 0;
        }

    return SSH_OK;
}

Thanks
Ricky



This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If you are not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited.

Archive administrator: postmaster@lists.cynapses.org