Revert "Abort if accounts.conf is world readable"
This reverts commit a755608ef9
.
This commit is contained in:
parent
ff51625513
commit
fb3826cee5
2 changed files with 4 additions and 30 deletions
6
aerc.go
6
aerc.go
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
@ -10,12 +9,12 @@ import (
|
||||||
|
|
||||||
"github.com/mattn/go-isatty"
|
"github.com/mattn/go-isatty"
|
||||||
|
|
||||||
|
"git.sr.ht/~sircmpwn/aerc2/config"
|
||||||
"git.sr.ht/~sircmpwn/aerc2/commands"
|
"git.sr.ht/~sircmpwn/aerc2/commands"
|
||||||
"git.sr.ht/~sircmpwn/aerc2/commands/account"
|
"git.sr.ht/~sircmpwn/aerc2/commands/account"
|
||||||
"git.sr.ht/~sircmpwn/aerc2/commands/compose"
|
"git.sr.ht/~sircmpwn/aerc2/commands/compose"
|
||||||
"git.sr.ht/~sircmpwn/aerc2/commands/msgview"
|
"git.sr.ht/~sircmpwn/aerc2/commands/msgview"
|
||||||
"git.sr.ht/~sircmpwn/aerc2/commands/terminal"
|
"git.sr.ht/~sircmpwn/aerc2/commands/terminal"
|
||||||
"git.sr.ht/~sircmpwn/aerc2/config"
|
|
||||||
libui "git.sr.ht/~sircmpwn/aerc2/lib/ui"
|
libui "git.sr.ht/~sircmpwn/aerc2/lib/ui"
|
||||||
"git.sr.ht/~sircmpwn/aerc2/widgets"
|
"git.sr.ht/~sircmpwn/aerc2/widgets"
|
||||||
)
|
)
|
||||||
|
@ -62,8 +61,7 @@ func main() {
|
||||||
|
|
||||||
conf, err := config.LoadConfig(nil)
|
conf, err := config.LoadConfig(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to load config: %v\n", err)
|
panic(err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -3,7 +3,6 @@ package config
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -143,11 +142,7 @@ func LoadConfig(root *string) (*AercConfig, error) {
|
||||||
_root := path.Join(xdg.ConfigHome(), "aerc")
|
_root := path.Join(xdg.ConfigHome(), "aerc")
|
||||||
root = &_root
|
root = &_root
|
||||||
}
|
}
|
||||||
filename := path.Join(*root, "aerc.conf")
|
file, err := ini.Load(path.Join(*root, "aerc.conf"))
|
||||||
if err := checkConfigPerms(filename); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
file, err := ini.Load(filename)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -294,22 +289,3 @@ func LoadConfig(root *string) (*AercConfig, error) {
|
||||||
config.Bindings.Global.Globals = false
|
config.Bindings.Global.Globals = false
|
||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkConfigPerms checks for too open permissions
|
|
||||||
// printing the fix on stdout and returning an error
|
|
||||||
func checkConfigPerms(filename string) error {
|
|
||||||
info, err := os.Stat(filename)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
perms := info.Mode().Perm()
|
|
||||||
goPerms := perms >> 3
|
|
||||||
// group or others have read access
|
|
||||||
if goPerms&0x44 != 0 {
|
|
||||||
fmt.Printf("The file %v has too open permissions.\n", filename)
|
|
||||||
fmt.Println("This is a security issue (it contains passwords).")
|
|
||||||
fmt.Printf("To fix it, run `chmod 600 %v`\n", filename)
|
|
||||||
return errors.New("account.conf permissions too lax")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue