mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-21 23:20:24 +00:00
portable mode: allow to read the password from a file
Fixes #1206 Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
parent
195cb9f081
commit
b0cfaf189c
2 changed files with 17 additions and 1 deletions
|
@ -84,6 +84,9 @@ Flags:
|
|||
--log-utc-time Use UTC time for logging
|
||||
-p, --password string Leave empty to use an auto generated
|
||||
value
|
||||
--password-file string Read the password from the specified
|
||||
file path. Leave empty to use an auto
|
||||
generated value
|
||||
-g, --permissions strings User's permissions. "*" means any
|
||||
permission (default [list,download])
|
||||
-k, --public-key strings
|
||||
|
|
|
@ -41,6 +41,7 @@ var (
|
|||
portableSFTPDPort int
|
||||
portableUsername string
|
||||
portablePassword string
|
||||
portablePasswordFile string
|
||||
portableStartDir string
|
||||
portableLogFile string
|
||||
portableLogLevel string
|
||||
|
@ -167,6 +168,15 @@ Please take a look at the usage below to customize the serving parameters`,
|
|||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
pwd := portablePassword
|
||||
if portablePasswordFile != "" {
|
||||
content, err := os.ReadFile(portablePasswordFile)
|
||||
if err != nil {
|
||||
fmt.Printf("Unable to read password file %q: %v", portablePasswordFile, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
pwd = strings.TrimSpace(string(content))
|
||||
}
|
||||
service.SetGraceTime(graceTime)
|
||||
service := service.Service{
|
||||
ConfigDir: filepath.Clean(defaultConfigDir),
|
||||
|
@ -183,7 +193,7 @@ Please take a look at the usage below to customize the serving parameters`,
|
|||
PortableUser: dataprovider.User{
|
||||
BaseUser: sdk.BaseUser{
|
||||
Username: portableUsername,
|
||||
Password: portablePassword,
|
||||
Password: pwd,
|
||||
PublicKeys: portablePublicKeys,
|
||||
Permissions: permissions,
|
||||
HomeDir: portableDir,
|
||||
|
@ -295,6 +305,9 @@ including scp
|
|||
value`)
|
||||
portableCmd.Flags().StringVarP(&portablePassword, "password", "p", "", `Leave empty to use an auto generated
|
||||
value`)
|
||||
portableCmd.Flags().StringVar(&portablePasswordFile, "password-file", "", `Read the password from the specified
|
||||
file path. Leave empty to use an auto
|
||||
generated value`)
|
||||
portableCmd.Flags().StringVarP(&portableLogFile, logFilePathFlag, "l", "", "Leave empty to disable logging")
|
||||
portableCmd.Flags().StringVar(&portableLogLevel, logLevelFlag, defaultLogLevel, `Set the log level.
|
||||
Supported values:
|
||||
|
|
Loading…
Reference in a new issue