File: mkpinentry.sh

package info (click to toggle)
snapd 2.72-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 80,412 kB
  • sloc: sh: 16,506; ansic: 16,211; python: 11,213; makefile: 1,919; exp: 190; awk: 58; xml: 22
file content (21 lines) | stat: -rwxr-xr-x 657 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash

if gpg --version | MATCH 'gpg \(GnuPG\) 1.'; then
    echo "fake gpg pinentry not used for gpg v1"
else
    echo "setup fake gpg pinentry environment for gpg v2 or higher"
    gpgdir=~/.snap/gnupg
    if gpg --version | MATCH 'gpg \(GnuPG\) 2.0'; then
        gpgdir=~/.gnupg
    fi
    mkdir -p "$gpgdir"
    # It is just created once by gpg-agent, then if this dir does not exist gpg will
    # fail to create the key
    mkdir -p "$gpgdir/private-keys-v1.d"
    echo pinentry-program "$TESTSLIB/pinentry-fake.sh" > "$gpgdir/gpg-agent.conf"
    chmod -R go-rwx "$gpgdir"
    if [ -d ~/.snap ]; then
        chmod -R go-rwx ~/.snap
    fi
fi