forked from gopasspw/gopass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
legacy.go
169 lines (154 loc) · 6.78 KB
/
legacy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
package config
import "github.com/gopasspw/gopass/pkg/backend"
// Pre182 is the current config struct
type Pre182 struct {
Path string `yaml:"-"`
Root *Pre182StoreConfig `yaml:"root"`
Mounts map[string]*Pre182StoreConfig `yaml:"mounts"`
Version string `yaml:"version"`
// Catches all undefined files and must be empty after parsing
XXX map[string]interface{} `yaml:",inline"`
}
// Pre182StoreConfig is a per-store (root or mount) config
type Pre182StoreConfig struct {
AskForMore bool `yaml:"askformore"` // ask for more data on generate
AutoClip bool `yaml:"autoclip"` // decide whether passwords are automatically copied or not
AutoImport bool `yaml:"autoimport"` // import missing public keys w/o asking
AutoSync bool `yaml:"autosync"` // push to git remote after commit, pull before push if necessary
CheckRecpHash bool `yaml:"check_recipient_hash"`
ClipTimeout int `yaml:"cliptimeout"` // clear clipboard after seconds
Concurrency int `yaml:"concurrency"` // allow to run multiple thread when batch processing
EditRecipients bool `yaml:"editrecipients"` // edit recipients when confirming
NoColor bool `yaml:"nocolor"` // do not use color when outputing text
NoConfirm bool `yaml:"noconfirm"` // do not confirm recipients when encrypting
NoPager bool `yaml:"nopager"` // do not invoke a pager to display long lists
Notifications bool `yaml:"notifications"` // enable desktop notifications
Path *backend.URL `yaml:"path"` // path to the root store
RecipientHash map[string]string `yaml:"recipient_hash"`
SafeContent bool `yaml:"safecontent"` // avoid showing passwords in terminal
UseSymbols bool `yaml:"usesymbols"` // always use symbols when generating passwords
}
// StoreConfig returns a current StoreConfig
func (c *Pre182StoreConfig) StoreConfig() *StoreConfig {
sc := &StoreConfig{
AskForMore: c.AskForMore,
AutoClip: c.AutoClip,
AutoImport: c.AutoImport,
AutoSync: c.AutoSync,
CheckRecpHash: c.CheckRecpHash,
ClipTimeout: c.ClipTimeout,
Concurrency: c.Concurrency,
EditRecipients: c.EditRecipients,
NoColor: c.NoColor,
NoConfirm: c.NoConfirm,
NoPager: c.NoPager,
Notifications: c.Notifications,
Path: c.Path,
RecipientHash: c.RecipientHash,
SafeContent: c.SafeContent,
UseSymbols: c.UseSymbols,
}
return sc
}
// CheckOverflow implements configer
func (c *Pre182) CheckOverflow() error {
return checkOverflow(c.XXX, "config")
}
// Config converts the Pre140 config to the current config struct
func (c *Pre182) Config() *Config {
cfg := &Config{
Root: c.Root.StoreConfig(),
Mounts: make(map[string]*StoreConfig, len(c.Mounts)),
}
for k, v := range c.Mounts {
cfg.Mounts[k] = v.StoreConfig()
}
return cfg
}
// Pre140 is the gopass config structure before version 1.4.0
type Pre140 struct {
AskForMore bool `yaml:"askformore"` // ask for more data on generate
AutoImport bool `yaml:"autoimport"` // import missing public keys w/o asking
AutoSync bool `yaml:"autosync"` // push to git remote after commit, pull before push if necessary
ClipTimeout int `yaml:"cliptimeout"` // clear clipboard after seconds
Mounts map[string]string `yaml:"mounts,omitempty"`
NoConfirm bool `yaml:"noconfirm"` // do not confirm recipients when encrypting
Path string `yaml:"path"` // path to the root store
SafeContent bool `yaml:"safecontent"` // avoid showing passwords in terminal
Version string `yaml:"version"`
// Catches all undefined files and must be empty after parsing
XXX map[string]interface{} `yaml:",inline"`
}
// CheckOverflow implements configer
func (c *Pre140) CheckOverflow() error {
return checkOverflow(c.XXX, "config")
}
// Config converts the Pre140 config to the current config struct
func (c *Pre140) Config() *Config {
sc := StoreConfig{
AskForMore: c.AskForMore,
AutoImport: c.AutoImport,
AutoSync: c.AutoSync,
ClipTimeout: c.ClipTimeout,
NoConfirm: c.NoConfirm,
Path: backend.FromPath(c.Path),
SafeContent: c.SafeContent,
}
cfg := &Config{
Root: &sc,
Mounts: make(map[string]*StoreConfig, len(c.Mounts)),
}
for k, v := range c.Mounts {
subSc := sc
subSc.Path = backend.FromPath(v)
cfg.Mounts[k] = &subSc
}
return cfg
}
// Pre130 is the gopass config structure before version 1.3.0. Not all fields were
// available between 1.0.0 and 1.3.0, but this struct should cover all of them.
type Pre130 struct {
AlwaysTrust bool `yaml:"alwaystrust"` // always trust public keys when encrypting
AskForMore bool `yaml:"askformore"` // ask for more data on generate
AutoImport bool `yaml:"autoimport"` // import missing public keys w/o asking
AutoPull bool `yaml:"autopull"` // pull from git before push
AutoPush bool `yaml:"autopush"` // push to git remote after commit
ClipTimeout int `yaml:"cliptimeout"` // clear clipboard after seconds
Debug bool `yaml:"debug"` // enable debug output
LoadKeys bool `yaml:"loadkeys"` // load missing keys from store
Mounts map[string]string `yaml:"mounts,omitempty"`
NoColor bool `yaml:"nocolor"` // disable colors in output
NoConfirm bool `yaml:"noconfirm"` // do not confirm recipients when encrypting
Path string `yaml:"path"` // path to the root store
PersistKeys bool `yaml:"persistkeys"` // store recipient keys in store
SafeContent bool `yaml:"safecontent"` // avoid showing passwords in terminal
Version string `yaml:"version"`
// Catches all undefined files and must be empty after parsing
XXX map[string]interface{} `yaml:",inline"`
}
// CheckOverflow implements configer
func (c *Pre130) CheckOverflow() error {
return checkOverflow(c.XXX, "config")
}
// Config converts the Pre130 config to the current config struct
func (c *Pre130) Config() *Config {
sc := StoreConfig{
AskForMore: c.AskForMore,
AutoImport: c.AutoImport,
AutoSync: c.AutoPull && c.AutoPush,
ClipTimeout: c.ClipTimeout,
NoConfirm: c.NoConfirm,
Path: backend.FromPath(c.Path),
SafeContent: c.SafeContent,
}
cfg := &Config{
Root: &sc,
Mounts: make(map[string]*StoreConfig, len(c.Mounts)),
}
for k, v := range c.Mounts {
subSc := sc
subSc.Path = backend.FromPath(v)
cfg.Mounts[k] = &subSc
}
return cfg
}