mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 14:20:55 +03: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:
@@ -84,6 +84,9 @@ Flags:
|
|||||||
--log-utc-time Use UTC time for logging
|
--log-utc-time Use UTC time for logging
|
||||||
-p, --password string Leave empty to use an auto generated
|
-p, --password string Leave empty to use an auto generated
|
||||||
value
|
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
|
-g, --permissions strings User's permissions. "*" means any
|
||||||
permission (default [list,download])
|
permission (default [list,download])
|
||||||
-k, --public-key strings
|
-k, --public-key strings
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ var (
|
|||||||
portableSFTPDPort int
|
portableSFTPDPort int
|
||||||
portableUsername string
|
portableUsername string
|
||||||
portablePassword string
|
portablePassword string
|
||||||
|
portablePasswordFile string
|
||||||
portableStartDir string
|
portableStartDir string
|
||||||
portableLogFile string
|
portableLogFile string
|
||||||
portableLogLevel string
|
portableLogLevel string
|
||||||
@@ -167,6 +168,15 @@ Please take a look at the usage below to customize the serving parameters`,
|
|||||||
os.Exit(1)
|
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.SetGraceTime(graceTime)
|
||||||
service := service.Service{
|
service := service.Service{
|
||||||
ConfigDir: filepath.Clean(defaultConfigDir),
|
ConfigDir: filepath.Clean(defaultConfigDir),
|
||||||
@@ -183,7 +193,7 @@ Please take a look at the usage below to customize the serving parameters`,
|
|||||||
PortableUser: dataprovider.User{
|
PortableUser: dataprovider.User{
|
||||||
BaseUser: sdk.BaseUser{
|
BaseUser: sdk.BaseUser{
|
||||||
Username: portableUsername,
|
Username: portableUsername,
|
||||||
Password: portablePassword,
|
Password: pwd,
|
||||||
PublicKeys: portablePublicKeys,
|
PublicKeys: portablePublicKeys,
|
||||||
Permissions: permissions,
|
Permissions: permissions,
|
||||||
HomeDir: portableDir,
|
HomeDir: portableDir,
|
||||||
@@ -295,6 +305,9 @@ including scp
|
|||||||
value`)
|
value`)
|
||||||
portableCmd.Flags().StringVarP(&portablePassword, "password", "p", "", `Leave empty to use an auto generated
|
portableCmd.Flags().StringVarP(&portablePassword, "password", "p", "", `Leave empty to use an auto generated
|
||||||
value`)
|
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().StringVarP(&portableLogFile, logFilePathFlag, "l", "", "Leave empty to disable logging")
|
||||||
portableCmd.Flags().StringVar(&portableLogLevel, logLevelFlag, defaultLogLevel, `Set the log level.
|
portableCmd.Flags().StringVar(&portableLogLevel, logLevelFlag, defaultLogLevel, `Set the log level.
|
||||||
Supported values:
|
Supported values:
|
||||||
|
|||||||
Reference in New Issue
Block a user