This commit is contained in:
Boshi Lian 2019-01-02 09:11:29 +00:00
parent 62ab849d2d
commit 7e9f9300d4
3 changed files with 8 additions and 4 deletions

View file

@ -13,10 +13,12 @@ parts:
source: /build
apps:
sshpiperd:
sshpiperd-daemon:
command: sshpiperd --config $SNAP_DATA/sshpiperd.ini
plugs: [network-bind]
daemon: simple
sshpiperd:
command: sshpiperd --config $SNAP_DATA/sshpiperd.ini
hooks:
configure:

View file

@ -2,7 +2,7 @@ package workingdir
var (
config = struct {
WorkingDir string `long:"upstream-workingdir" default:"/var/sshpiper" description:"Path to workingdir" env:"SSHPIPERD_UPSTREAM_WORKINGDIR" ini-name:"upstream-workingdir" required:"true"`
WorkingDir string `long:"upstream-workingdir" default:"/var/sshpiper" description:"Path to workingdir" env:"SSHPIPERD_UPSTREAM_WORKINGDIR" ini-name:"upstream-workingdir"`
AllowBadUsername bool `long:"upstream-workingdir-allowbadusername" description:"Disable username check while search the working dir" env:"SSHPIPERD_UPSTREAM_WORKINGDIR_ALLOWBADUSERNAME" ini-name:"upstream-workingdir-allowbadusername"`
NoCheckPerm bool `long:"upstream-workingdir-nocheckperm" description:"Disable 0400 checking when using files in the working dir" env:"SSHPIPERD_UPSTREAM_WORKINGDIR_NOCHECKPERM" ini-name:"upstream-workingdir-nocheckperm"`
FallbackUsername string `long:"upstream-workingdir-fallbackusername" description:"Fallback to a user when user does not exists in directory" env:"SSHPIPERD_UPSTREAM_WORKINGDIR_FALLBACKUSERNAME" ini-name:"upstream-workingdir-fallbackusername"`

View file

@ -15,7 +15,7 @@ type plugin struct {
}
func (p *plugin) CreatePipe(opt upstream.CreatePipeOption) error {
err := os.MkdirAll(config.WorkingDir+"/"+opt.Username, os.ModePerm)
err := os.MkdirAll(config.WorkingDir+"/"+opt.Username, 0775)
if err != nil {
return err
}
@ -30,7 +30,9 @@ func (p *plugin) CreatePipe(opt upstream.CreatePipeOption) error {
}
content := fmt.Sprintf("%v@%v:%v", upuser, opt.Host, opt.Port)
return ioutil.WriteFile(path, []byte(content), os.ModePerm)
return ioutil.WriteFile(path, []byte(content), 0600)
} else if err != nil {
return err
}
return fmt.Errorf("upstream file alreay exists")