-
-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
108 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// +build !windows | ||
|
||
package action | ||
|
||
import ( | ||
"crypto/sha256" | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"strconv" | ||
"syscall" | ||
) | ||
|
||
// clearClipboard will spwan a copy of gopass that waits in a detached background | ||
// process group until the timeout is expired. It will then compare the contents | ||
// of the clipboard and erase it if it still contains the data gopass copied | ||
// to it. | ||
func clearClipboard(content []byte, timeout int) error { | ||
hash := fmt.Sprintf("%x", sha256.Sum256(content)) | ||
|
||
cmd := exec.Command(os.Args[0], "unclip", "--timeout", strconv.Itoa(timeout)) | ||
// https://groups.google.com/d/msg/golang-nuts/shST-SDqIp4/za4oxEiVtI0J | ||
cmd.SysProcAttr = &syscall.SysProcAttr{ | ||
Setpgid: true, | ||
} | ||
cmd.Env = append(os.Environ(), "GOPASS_UNCLIP_CHECKSUM="+hash) | ||
return cmd.Start() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// +build windows | ||
|
||
package action | ||
|
||
import ( | ||
"crypto/sha256" | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"strconv" | ||
) | ||
|
||
// clearClipboard will spwan a copy of gopass that waits in a detached background | ||
// process group until the timeout is expired. It will then compare the contents | ||
// of the clipboard and erase it if it still contains the data gopass copied | ||
// to it. | ||
func clearClipboard(content []byte, timeout int) error { | ||
hash := fmt.Sprintf("%x", sha256.Sum256(content)) | ||
|
||
cmd := exec.Command(os.Args[0], "unclip", "--timeout", strconv.Itoa(timeout)) | ||
cmd.Env = append(os.Environ(), "GOPASS_UNCLIP_CHECKSUM="+hash) | ||
return cmd.Start() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// +build !windows | ||
|
||
package fsutil | ||
|
||
import ( | ||
"os" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
// Tempdir returns a temporary directory suiteable for sensitive data. It tries | ||
// /dev/shm but if this isn't working it will return an empty string. Using | ||
// this with ioutil.Tempdir will ensure that we're getting the "best" tempdir. | ||
func Tempdir() string { | ||
shmDir := "/dev/shm" | ||
if fi, err := os.Stat(shmDir); err == nil { | ||
if fi.IsDir() { | ||
if unix.Access(shmDir, unix.W_OK) == nil { | ||
return shmDir | ||
} | ||
} | ||
} | ||
return "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// +build windows | ||
|
||
package fsutil | ||
|
||
// Tempdir returns a temporary directory suiteable for sensitive data. On | ||
// Windows, just return empty string for ioutil.TempFile. | ||
func Tempdir() string { | ||
return "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// +build !windows | ||
|
||
package gpg | ||
|
||
import "syscall" | ||
|
||
func umask(mask int) int { | ||
return syscall.Umask(mask) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// +build windows | ||
|
||
package gpg | ||
|
||
func umask(mask int) int { | ||
return -1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters