add no_check_perm option

This commit is contained in:
tgic 2015-10-06 04:55:23 +08:00 committed by Boshi Lian
parent ed045e569e
commit 1946a542f7
2 changed files with 6 additions and 0 deletions

View file

@ -32,6 +32,7 @@ var (
Logfile string
ShowVersion bool
AllowBadUsername bool
NoCheckPerm bool
}{}
out = os.Stdout
@ -86,6 +87,7 @@ func initConfig() {
pflag.StringVarP(&config.Challenger, "challenger", "c", "", "Additional challenger name, e.g. pam, emtpy for no additional challenge")
pflag.StringVar(&config.Logfile, "log", "", "Logfile path. Leave emtpy or any error occurs will fall back to stdout")
pflag.BoolVar(&config.AllowBadUsername, "allow_bad_username", false, "disable username check while search the working dir")
mflag.BoolVar(&config.NoCheckPerm, -no_check_perm, false, "Disable 0400 checking when using files in the working dir")
pflag.BoolVarP(&config.ShowHelp, "help", "h", false, "Print help and exit")
pflag.BoolVar(&config.ShowVersion, "version", false, "Print version and exit")

View file

@ -60,6 +60,10 @@ func (file userFile) checkPerm(user string) error {
return err
}
if config.NoCheckPerm {
return nil
}
if fi.Mode().Perm()&0077 != 0 {
return fmt.Errorf("%v's perm is too open", filename)
}