Commit ca890c0 1 parent 69a2138 commit ca890c0 Copy full SHA for ca890c0
File tree 2 files changed +32
-0
lines changed
2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ func (cmd *RestartCmd) Run(config *Config) error {
30
30
printRepr (cmd )
31
31
}
32
32
33
+ if err := lockMemory (); err != nil {
34
+ return err
35
+ }
36
+
33
37
_ , _ = messageAgent (config .Socket , "SHUTDOWN" )
34
38
35
39
identitiesText , err := decryptIdentities (config .Identities )
@@ -45,6 +49,10 @@ func (cmd *RunCmd) Run(config *Config) error {
45
49
printRepr (cmd )
46
50
}
47
51
52
+ if err := lockMemory (); err != nil {
53
+ return err
54
+ }
55
+
48
56
return runAgent (config .Socket )
49
57
}
50
58
@@ -53,6 +61,10 @@ func (cmd *StartCmd) Run(config *Config) error {
53
61
printRepr (cmd )
54
62
}
55
63
64
+ if err := lockMemory (); err != nil {
65
+ return err
66
+ }
67
+
56
68
if err := pingAgent (config .Socket ); err == nil {
57
69
return fmt .Errorf ("found agent responding on socket" )
58
70
}
Original file line number Diff line number Diff line change
1
+ // pago - a command-line password manager.
2
+ //
3
+ // License: MIT.
4
+ // See the file LICENSE.
5
+
6
+ package main
7
+
8
+ import (
9
+ "fmt"
10
+
11
+ "golang.org/x/sys/unix"
12
+ )
13
+
14
+ func lockMemory () error {
15
+ if err := unix .Mlockall (unix .MCL_CURRENT | unix .MCL_FUTURE ); err != nil {
16
+ return fmt .Errorf ("failed to lock memory: %v" , err )
17
+ }
18
+
19
+ return nil
20
+ }
You can’t perform that action at this time.
0 commit comments