mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-11-29 22:08:10 +02:00
refactor custom actions
SFTPGo is now fully auditable, all fs and provider events that change something are notified and can be collected using hooks/plugins. There are some backward incompatible changes for command hooks
This commit is contained in:
@@ -717,11 +717,13 @@ func (c *sshCommand) sendErrorResponse(err error) error {
|
||||
|
||||
func (c *sshCommand) sendExitStatus(err error) {
|
||||
status := uint32(0)
|
||||
cmdPath := c.getDestPath()
|
||||
vCmdPath := c.getDestPath()
|
||||
cmdPath := ""
|
||||
targetPath := ""
|
||||
vTargetPath := ""
|
||||
if c.command == "sftpgo-copy" {
|
||||
targetPath = cmdPath
|
||||
cmdPath = c.getSourcePath()
|
||||
vTargetPath = vCmdPath
|
||||
vCmdPath = c.getSourcePath()
|
||||
}
|
||||
if err != nil {
|
||||
status = uint32(1)
|
||||
@@ -737,20 +739,20 @@ func (c *sshCommand) sendExitStatus(err error) {
|
||||
// for scp we notify single uploads/downloads
|
||||
if c.command != scpCmdName {
|
||||
metric.SSHCommandCompleted(err)
|
||||
if cmdPath != "" {
|
||||
_, p, errFs := c.connection.GetFsAndResolvedPath(cmdPath)
|
||||
if vCmdPath != "" {
|
||||
_, p, errFs := c.connection.GetFsAndResolvedPath(vCmdPath)
|
||||
if errFs == nil {
|
||||
cmdPath = p
|
||||
}
|
||||
}
|
||||
if targetPath != "" {
|
||||
_, p, errFs := c.connection.GetFsAndResolvedPath(targetPath)
|
||||
if vTargetPath != "" {
|
||||
_, p, errFs := c.connection.GetFsAndResolvedPath(vTargetPath)
|
||||
if errFs == nil {
|
||||
targetPath = p
|
||||
}
|
||||
}
|
||||
common.ExecuteActionNotification(&c.connection.User, common.OperationSSHCmd, cmdPath, c.getDestPath(), targetPath, c.command,
|
||||
common.ProtocolSSH, 0, err)
|
||||
common.ExecuteActionNotification(&c.connection.User, common.OperationSSHCmd, cmdPath, vCmdPath, targetPath,
|
||||
vTargetPath, c.command, common.ProtocolSSH, c.connection.GetRemoteIP(), 0, err)
|
||||
if err == nil {
|
||||
logger.CommandLog(sshCommandLogSender, cmdPath, targetPath, c.connection.User.Username, "", c.connection.ID,
|
||||
common.ProtocolSSH, -1, -1, "", "", c.connection.command, -1, c.connection.GetLocalAddress(),
|
||||
|
||||
Reference in New Issue
Block a user