jeudi 28 septembre 2017

How would you change a channel to root and then change to a subsystem SFTP?

According to RFC 4254, under "Starting a Shell or a Command", it sounds as though you can execute shell commands as either a subsystem or a shell. I need to su into root and then change to a subsystem sftp.

LIBSSH2_CHANNEL * chen = libssh2_channel_open_session(_thisSession);
if(!chen){
    std::cerr << "ERROR: " << err(libssh2_session_last_errno(_thisSession),0) << std::endl;
}
rc = libssh2_channel_exec(chen, "su -");
if(rc < 0){
    std::err << "ERROR: " << err(rc, 0) << std::endl;
}
//stops working, for obvious reasons, but this is meant to reflect my intention.
rc = libssh2_channel_process_startup(chen, "shell", strlen("shell"), "sftp", strlen("sftp"));
if(rc < 0){
    std::err << "ERROR: " << err(rc, 0) << std::endl;
}

What am I doing wrong? How do you switch to root and then switch to an SFTP subsystem?

Aucun commentaire:

Enregistrer un commentaire