Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
RELEASE_NOTES=n/a

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>
  • Loading branch information
AnomalRoil committed Dec 1, 2021
2 parents d0eccf6 + e01a58f commit 028e1e4
Show file tree
Hide file tree
Showing 15 changed files with 198 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
go-version: 1.17

- name: Ubuntu Dependencies
run: sudo apt-get install --yes git gnupg2
run: sudo apt-get install --yes git gnupg

- run: git config --global user.name nobody
- run: git config --global user.email foo.bar@example.org
Expand Down
14 changes: 13 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,31 @@ release:
prerelease: auto

nfpms:
- id: gopass
- id: gopass_deb
vendor: Gopass Authors
homepage: "https://www.gopass.pw"
maintainer: "Gopass Authors <gopass@gopass.pw>"
license: MIT
formats:
- deb
dependencies:
- git
- gnupg
recommends:
- rng-tools
- id: gopass_rpm
vendor: Gopass Authors
homepage: "https://www.gopass.pw"
maintainer: "Gopass Authors <gopass@gopass.pw>"
license: MIT
formats:
- rpm
dependencies:
- git
- gnupg2
recommends:
- rng-tools

source:
enabled: true
name_template: "{{.ProjectName}}-{{.Version}}"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# gopass

[![Build Status](https://img.shields.io/github/workflow/status/gopasspw/gopass/Build%20gopass/master)](https://github.com/gopasspw/gopass/actions/workflows/build.yml?query=branch%3Amaster)
[![Packaging status](https://repology.org/badge/tiny-repos/gopass.svg)](https://repology.org/project/gopass/versions)
[![Packaging status](https://repology.org/badge/tiny-repos/gopass-gopasspw.svg)](https://repology.org/project/gopass-gopasspw/versions)
[![Go Report Card](https://goreportcard.com/badge/github.com/gopasspw/gopass)](https://goreportcard.com/report/github.com/gopasspw/gopass)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/gopasspw/gopass/blob/master/LICENSE)
[![Github All Releases](https://img.shields.io/github/downloads/gopasspw/gopass/total.svg)](https://github.com/gopasspw/gopass/releases)
Expand Down
47 changes: 47 additions & 0 deletions docs/commands/cat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# `cat` command

The `cat` command is used to pipe password in and out of STDIN and STDOUT
respectively. As it is intended to be used with binary data, it encodes the
data-stream to store it.

## Synopsis

```bash
$ echo "test" | gopass cat test/new
$ gopass cat test/new
```

## Modes of operation

* Create a new entry with data-stream from STDIN
* Change an existing entry to data-stream from STDIN
* Retrive encoded data from password-store and echo it to STDOUT

Cat is intended to work with binary data, so it accepts any kind of stream from
STDIN. It reads the binary-stream from STDIN and encodes it Base64 and saves it
in the password store encoded, with some metadata about the input-stream and the
used encoding (currently only Base64 supported).

### Example
```
$ echo "234" | gopass cat test/new
$ gopass show -f test/new
Secret: test/new
content-disposition: attachment; filename="STDIN"
content-transfer-encoding: Base64
MjM0Cg==
$ gopass cat test/new
234
```

### Differences to `insert`

In contrast to `insert` it handles any kind of data-stream from STDIN and
encodes it.
Drawback: you can not just simply read the password with `gopass show`.

## Flags

This command has currently no supported flags except the gopass globals.
4 changes: 1 addition & 3 deletions docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ key generation if these are available for your platform.

```bash
apt-get update
apt-get install gnupg2 git rng-tools
apt-get install git gnupg rng-tools
```

_Note:_ installing on Ubuntu prior to 16.04 and similarly old Debian versions might require you to install `gnupg` instead of `gnupg2`.

#### RHEL & CentOS

```bash
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/kr/pretty v0.3.0 // indirect
github.com/martinhoefling/goxkcdpwgen v0.0.0-20190331205820-7dc3d102eca3
github.com/mattn/go-colorable v0.1.11
github.com/mattn/go-colorable v0.1.12
github.com/mattn/go-isatty v0.0.14
github.com/mattn/go-tty v0.0.3
github.com/mitchellh/go-homedir v1.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ github.com/martinhoefling/goxkcdpwgen v0.0.0-20190331205820-7dc3d102eca3 h1:fvQL
github.com/martinhoefling/goxkcdpwgen v0.0.0-20190331205820-7dc3d102eca3/go.mod h1:4HvZROUEazha3RDnoBcxQlwcIbQfwx035roFOMnICSE=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs=
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
Expand Down
59 changes: 59 additions & 0 deletions helpers/man/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
package main

import (
"fmt"
"io/fs"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"sort"
"strings"
"text/template"
Expand All @@ -22,6 +26,26 @@ import (
)

func main() {
// this is a workaround for the man helper getting accidentially
// installed into my $GOBIN dir and me not being able to figure out
// why. So instead of being greeted with an ugly panic message
// every now and then when I need to open a man page I decided
// to rather have a little bit of code to automate this away.
if len(os.Args) > 0 && os.Args[0] == "man" {
manPath, err := lookPath("man")
if err != nil {
panic(err)
}
cmd := exec.Command(manPath, os.Args[1:]...)
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
if err := cmd.Run(); err != nil {
os.Exit(cmd.ProcessState.ExitCode())
}
return
}

vs, err := ioutil.ReadFile("VERSION")
if err != nil {
panic(err)
Expand Down Expand Up @@ -97,6 +121,41 @@ type payload struct {
Flags []flag
}

// from https://cs.opensource.google/go/go/+/refs/tags/go1.17.3:src/os/exec/lp_unix.go
func lookPath(file string) (string, error) {
curPath, err := os.Executable()
if err != nil {
return "", err
}
path := os.Getenv("PATH")
for _, dir := range filepath.SplitList(path) {
if dir == "" {
// Unix shell semantics: path element "" means "."
dir = "."
}
path := filepath.Join(dir, file)
// do not call ourselves
if path == curPath {
continue
}
if err := findExecutable(path); err == nil {
return path, nil
}
}
return "", fmt.Errorf("%s: executable file not found in $PATH", file)
}

func findExecutable(file string) error {
d, err := os.Stat(file)
if err != nil {
return err
}
if m := d.Mode(); !m.IsDir() && m&0111 != 0 {
return nil
}
return fs.ErrPermission
}

var manTpl = `
.TH GOPASS "{{ .SectionNumber }}" "{{ .DatePretty }}" "gopass (github.com/gopasspw/gopass) {{ .Version }}" "{{ .SectionName }}"
.SH NAME
Expand Down
48 changes: 0 additions & 48 deletions helpers/postrel/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,6 @@ func (u *repoUpdater) update(ctx context.Context) {
Distro: "Homebrew",
UpFn: u.updateHomebrew,
},
{
Distro: "Termux",
UpFn: u.updateTermux,
},
{
Distro: "VoidLinux",
UpFn: u.updateVoid,
Expand Down Expand Up @@ -392,50 +388,6 @@ func (u *repoUpdater) updateHomebrew(ctx context.Context) error {
return u.createPR(ctx, r.commitMsg(), u.ghUser+":"+r.branch(), "Homebrew", "homebrew-core")
}

func (u *repoUpdater) updateTermux(ctx context.Context) error {
dir := "../repos/termux/"
if d := os.Getenv("GOPASS_TERMUX_PKG_DIR"); d != "" {
dir = d
}

r := &repo{
ver: u.v,
url: u.arcURL,
dir: dir,
rem: u.ghFork,
}

if err := r.updatePrepare(); err != nil {
return err
}
fmt.Println("✅ Prepared")

// update packages/gopass/build.sh
buildFn := "packages/gopass/build.sh"
buildPath := filepath.Join(dir, buildFn)

repl := map[string]*string{
"TERMUX_PKG_VERSION": strp("TERMUX_PKG_VERSION=" + u.v.String()),
"TERMUX_PKG_SHA256": strp("TERMUX_PKG_SHA256=" + u.arcSHA256),
"TERMUX_PKG_REVISON": nil, // a new release shouldn't have a revision
"TERMUX_PKG_SRCURL": strp(`TERMUX_PKG_SRCURL=https://github.com/gopasspw/gopass/archive/v$TERMUX_PKG_VERSION.tar.gz`),
}
if err := updateBuild(
buildPath,
repl,
); err != nil {
return err
}
fmt.Println("✅ Built")

if err := r.updateFinalize(buildFn); err != nil {
return err
}
fmt.Println("✅ Finalized")

return u.createPR(ctx, r.commitMsg(), u.ghUser+":"+r.branch(), "termux", "termux-packages")
}

func (u *repoUpdater) updateVoid(ctx context.Context) error {
dir := "../repos/void/"
if d := os.Getenv("GOPASS_VOID_PKG_DIR"); d != "" {
Expand Down
17 changes: 9 additions & 8 deletions internal/action/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package action

import (
"fmt"
"strings"

"github.com/gopasspw/gopass/internal/backend"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -128,7 +129,7 @@ func (s *Action) GetCommands() []*cli.Command {
},
&cli.StringFlag{
Name: "crypto",
Usage: fmt.Sprintf("Select crypto backend %v", backend.CryptoBackends()),
Usage: fmt.Sprintf("Select crypto backend: %s", strings.Join(backend.CryptoBackends(), ", ")),
},
},
},
Expand Down Expand Up @@ -164,11 +165,11 @@ func (s *Action) GetCommands() []*cli.Command {
},
&cli.StringFlag{
Name: "crypto",
Usage: fmt.Sprintf("Which crypto backend? %v", backend.CryptoBackends()),
Usage: fmt.Sprintf("Which crypto backend? %s", strings.Join(backend.CryptoBackends(), ", ")),
},
&cli.StringFlag{
Name: "storage",
Usage: fmt.Sprintf("Which storage backend? %v", backend.StorageBackends()),
Usage: fmt.Sprintf("Which storage backend? %s", strings.Join(backend.StorageBackends(), ", ")),
},
},
},
Expand Down Expand Up @@ -450,7 +451,7 @@ func (s *Action) GetCommands() []*cli.Command {
},
&cli.StringFlag{
Name: "storage",
Usage: fmt.Sprintf("Select storage backend %v", backend.StorageBackends()),
Usage: fmt.Sprintf("Select storage backend %s", strings.Join(backend.StorageBackends(), ", ")),
Value: "gitfs",
},
},
Expand Down Expand Up @@ -585,12 +586,12 @@ func (s *Action) GetCommands() []*cli.Command {
},
&cli.StringFlag{
Name: "crypto",
Usage: fmt.Sprintf("Select crypto backend %v", backend.CryptoBackends()),
Usage: fmt.Sprintf("Select crypto backend %s", strings.Join(backend.CryptoBackends(), ", ")),
Value: "gpgcli",
},
&cli.StringFlag{
Name: "storage",
Usage: fmt.Sprintf("Select storage backend %v", backend.StorageBackends()),
Usage: fmt.Sprintf("Select storage backend %s", strings.Join(backend.StorageBackends(), ", ")),
Value: "gitfs",
},
},
Expand Down Expand Up @@ -877,11 +878,11 @@ func (s *Action) GetCommands() []*cli.Command {
},
&cli.StringFlag{
Name: "crypto",
Usage: fmt.Sprintf("Select crypto backend %v", backend.CryptoBackends()),
Usage: fmt.Sprintf("Select crypto backend %s", strings.Join(backend.CryptoBackends(), ", ")),
},
&cli.StringFlag{
Name: "storage",
Usage: fmt.Sprintf("Select storage backend %v", backend.StorageBackends()),
Usage: fmt.Sprintf("Select storage backend %s", strings.Join(backend.StorageBackends(), ", ")),
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/backend/crypto/gpg/cli/encrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (g *GPG) Encrypt(ctx context.Context, plaintext []byte, recipients []string
if err != nil {
debug.Log("Failed to check key %s. Adding anyway. %s", err)
} else if len(kl.UseableKeys(gpg.IsAlwaysTrust(ctx))) < 1 {
out.Printf(ctx, "Not using expired key %s for encryption", r)
out.Printf(ctx, "Not using invalid key %s for encryption. (Check its expiration date or its encryption capabilities.)", r)
continue
}
args = append(args, "--recipient", r)
Expand Down
23 changes: 23 additions & 0 deletions internal/backend/crypto/gpg/colons/parse_colons.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func Parse(reader io.Reader) gpg.KeyList {
Ownertrust: fields[8],
Identities: make(map[string]gpg.Identity, 1),
SubKeys: make(map[string]struct{}, 1),
Caps: parseKeyCaps(fields[11]),
}
case "sub":
fallthrough
Expand All @@ -111,6 +112,28 @@ func Parse(reader io.Reader) gpg.KeyList {
return kl
}

func parseKeyCaps(field string) gpg.Capabilities {
keycaps := gpg.Capabilities{}

if strings.Contains(field, "S") {
keycaps.Sign = true
}
if strings.Contains(field, "E") {
keycaps.Encrypt = true
}
if strings.Contains(field, "C") {
keycaps.Certify = true
}
if strings.Contains(field, "A") {
keycaps.Authentication = true
}
if strings.Contains(field, "D") {
keycaps.Deactivated = true
}

return keycaps
}

func parseColonIdentity(fields []string) gpg.Identity {
for i, f := range fields {
fields[i] = strings.Replace(f, "\\x3a", ":", -1)
Expand Down
Loading

0 comments on commit 028e1e4

Please sign in to comment.