mirror of https://github.com/wolfSSL/wolfssh.git
change default path with sftp and chroot
parent
c4efae1f5d
commit
ee68ef9333
|
@ -322,15 +322,6 @@ static int SFTP_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
|
||||||
return WS_FATAL_ERROR;
|
return WS_FATAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set starting SFTP directory */
|
|
||||||
if (ret == WS_SUCCESS) {
|
|
||||||
if (wolfSSH_SFTP_SetDefaultPath(ssh, pPasswd->pw_dir) != WS_SUCCESS) {
|
|
||||||
wolfSSH_Log(WS_LOG_ERROR,
|
|
||||||
"[SSHD] Error setting SFTP default home path");
|
|
||||||
ret = WS_FATAL_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret == WS_SUCCESS) {
|
if (ret == WS_SUCCESS) {
|
||||||
error = SetupChroot(usrConf);
|
error = SetupChroot(usrConf);
|
||||||
if (error == 1) {
|
if (error == 1) {
|
||||||
|
@ -346,6 +337,22 @@ static int SFTP_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set starting SFTP directory */
|
||||||
|
if (ret == WS_SUCCESS) {
|
||||||
|
WDIR dir;
|
||||||
|
|
||||||
|
/* if home directory exists than set it as the default */
|
||||||
|
if (WOPENDIR(NULL, NULL, &dir, pPasswd->pw_dir) == 0) {
|
||||||
|
if (wolfSSH_SFTP_SetDefaultPath(ssh, pPasswd->pw_dir)
|
||||||
|
!= WS_SUCCESS) {
|
||||||
|
wolfSSH_Log(WS_LOG_ERROR,
|
||||||
|
"[SSHD] Error setting SFTP default home path");
|
||||||
|
ret = WS_FATAL_ERROR;
|
||||||
|
}
|
||||||
|
WCLOSEDIR(&dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (wolfSSHD_AuthReducePermissionsUser(conn->auth, pPasswd->pw_uid,
|
if (wolfSSHD_AuthReducePermissionsUser(conn->auth, pPasswd->pw_uid,
|
||||||
pPasswd->pw_gid) != WS_SUCCESS) {
|
pPasswd->pw_gid) != WS_SUCCESS) {
|
||||||
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Error setting user ID");
|
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Error setting user ID");
|
||||||
|
|
Loading…
Reference in New Issue