add support for Git over SSH

We use the system commands "git-receive-pack", "git-upload-pack" and
"git-upload-archive". they need to be installed and in your system's
PATH. Since we execute system commands we have no direct control on
file creation/deletion and so quota check is suboptimal: if quota is
enabled, the number of files is checked at the command begin and not
while new files are created.
The allowed size is calculated as the difference between the max quota
and the used one. The command is aborted if it uploads more bytes than
the remaining allowed size calculated at the command start. Quotas are
recalculated at the command end with a full home directory scan, this
could be heavy for big directories.
This commit is contained in:
Nicola Murino
2019-11-26 22:26:42 +01:00
parent 7a8b1645ef
commit 0a025aabfd
16 changed files with 846 additions and 88 deletions

View File

@@ -55,6 +55,18 @@ var (
Help: "The total download size as bytes",
})
// totalSSHCommands is the metric that reports the total number of executed SSH commands
totalSSHCommands = promauto.NewCounter(prometheus.CounterOpts{
Name: "sftpgo_ssh_commands_total",
Help: "The total number of executed SSH commands",
})
// totalSSHCommandErrors is the metric that reports the total number of SSH command errors
totalSSHCommandErrors = promauto.NewCounter(prometheus.CounterOpts{
Name: "sftpgo_ssh_command_errors_total",
Help: "The total number of SSH command errors",
})
// totalLoginAttempts is the metric that reports the total number of login attempts
totalLoginAttempts = promauto.NewCounter(prometheus.CounterOpts{
Name: "sftpgo_login_attempts_total",
@@ -157,6 +169,15 @@ func TransferCompleted(bytesSent, bytesReceived int64, transferKind int, err err
}
}
// SSHCommandCompleted update metrics after an SSH command terminates
func SSHCommandCompleted(err error) {
if err == nil {
totalSSHCommands.Inc()
} else {
totalSSHCommandErrors.Inc()
}
}
// UpdateDataProviderAvailability updates the metric for the data provider availability
func UpdateDataProviderAvailability(err error) {
if err == nil {