pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/security



Module Name:    pkgsrc
Committed By:   jschauma
Date:           Sun Jul 16 18:36:44 UTC 2023

Modified Files:
        pkgsrc/security: Makefile
Added Files:
        pkgsrc/security/go-getpass: DESCR Makefile PLIST distinfo

Log Message:
Import github.com/jschauma/getpass

The `getpass` module provides a simple way to retrieve a password from
the user by specifying a number of different password sources:

func Getpass(passfrom string) (pass string, err error)

Getpass retrieves a password from the user using a method defined by
the `passfrom` string.  The following methods are supported:

`cmd:command` -- Obtain the password by running the given command.  The
command will be passed to the shell for execution via `/bin/sh -c
'command'`.

`env:var` -- Obtain the password from the environment variable var.
Since the environment of other processes may be visible
via e.g. `ps(1)`, this option should be used with caution.

`file:pathname` -- The first line of `pathname` is the password.
`pathname` need not refer to a regular file: it could for example refer
to a device or named pipe.  `pathname` undergoes standard "~" and
environment variable expansion.  Note that standard Unix file access
controls should be used to protect this file.

`keychain:name` -- Use the `security(1)` utility to retrieve the
password from the macOS keychain.

`lpass:name` -- Use the LastPass command-line client `lpass(1)` to
retrieve the named password.  You should previously have run `lpass
login` for this to work.

`op:name` -- Use the 1Password command-line client `op(1)` to retrieve
the named password.

`pass:password` -- The actual password is password.  Since the
password is visible to utilities such as `ps(1)` and possibly leaked
into the shell history file, this form should only be used where
security is not important.

`tty[:prompt]` -- This is the default: `Getpass` will prompt the user on
the controlling tty using the provided `prompt`.  If no `prompt` is
provided, then `Getpass` will use "Password: ".

## Examples

```
package main

import (
        "flag"
        "fmt"
        "log"

        "github.com/jschauma/getpass"
)

func main() {

        var pass string
        flag.StringVar(&pass, "p", "tty", "password method")
        flag.Parse()

        // Try out any of the options:
        p, err := getpass.Getpass(pass)
        if err != nil {
                log.Fatal("Unable to get password from user: ", err)
        } else {
                fmt.Printf("%s\n", p)
        }

        // Alternatively:

        // This will prompt the user to enter a password interactively,
        // using the default prompt.
        p, err = getpass.Getpass()
        if err != nil {
                log.Fatal("Unable to get password from user: ", err)
        } else {
                fmt.Printf("%s\n", p)
        }

        // Using a custom prompt:
        p, err = getpass.Getpass("tty:Please enter your secret passphrase: ")
        if err != nil {
                log.Fatal("Unable to get password from user: ", err)
        } else {
                fmt.Printf("%s\n", p)
        }

        // Using an environment variable:
        p, err = getpass.Getpass("env:MYSECRET")
        if err != nil {
                log.Fatal("Unable to get password from user: ", err)
        } else {
                fmt.Printf("%s\n", p)
        }

        // Using a file:
        p, err = getpass.Getpass("file:~/.secret")
        if err != nil {
                log.Fatal("Unable to get password from user: ", err)
        } else {
                fmt.Printf("%s\n", p)
        }

        // etc. etc.
}
```

---

See also:
* https://www.netmeister.org/blog/passing-passwords.html
* https://www.netmeister.org/blog/consistent-tools.html#passwords


To generate a diff of this commit:
cvs rdiff -u -r1.905 -r1.906 pkgsrc/security/Makefile
cvs rdiff -u -r0 -r1.1 pkgsrc/security/go-getpass/DESCR \
    pkgsrc/security/go-getpass/Makefile pkgsrc/security/go-getpass/PLIST \
    pkgsrc/security/go-getpass/distinfo

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/security/Makefile
diff -u pkgsrc/security/Makefile:1.905 pkgsrc/security/Makefile:1.906
--- pkgsrc/security/Makefile:1.905      Mon Jul  3 13:43:28 2023
+++ pkgsrc/security/Makefile    Sun Jul 16 18:36:44 2023
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.905 2023/07/03 13:43:28 nros Exp $
+# $NetBSD: Makefile,v 1.906 2023/07/16 18:36:44 jschauma Exp $
 #
 
 COMMENT=       Security and cryptography tools and libraries
@@ -113,6 +113,7 @@ SUBDIR+=    gnupg2
 SUBDIR+=       gnutls
 SUBDIR+=       go-asn1-ber
 SUBDIR+=       go-crypto
+SUBDIR+=       go-getpass
 SUBDIR+=       go-mkcert
 SUBDIR+=       google-authenticator
 SUBDIR+=       gopass

Added files:

Index: pkgsrc/security/go-getpass/DESCR
diff -u /dev/null pkgsrc/security/go-getpass/DESCR:1.1
--- /dev/null   Sun Jul 16 18:36:44 2023
+++ pkgsrc/security/go-getpass/DESCR    Sun Jul 16 18:36:44 2023
@@ -0,0 +1,112 @@
+The `getpass` module provides a simple way to retrieve a password from
+the user by specifying a number of different password sources:
+
+func Getpass(passfrom string) (pass string, err error)
+
+Getpass retrieves a password from the user using a method defined by
+the `passfrom` string.  The following methods are supported:
+
+`cmd:command` -- Obtain the password by running the given command.  The
+command will be passed to the shell for execution via `/bin/sh -c
+'command'`.
+
+`env:var` -- Obtain the password from the environment variable var.
+Since the environment of other processes may be visible
+via e.g. `ps(1)`, this option should be used with caution.
+
+`file:pathname` -- The first line of `pathname` is the password.
+`pathname` need not refer to a regular file: it could for example refer
+to a device or named pipe.  `pathname` undergoes standard "~" and
+environment variable expansion.  Note that standard Unix file access
+controls should be used to protect this file.
+
+`keychain:name` -- Use the `security(1)` utility to retrieve the
+password from the macOS keychain.
+
+`lpass:name` -- Use the LastPass command-line client `lpass(1)` to
+retrieve the named password.  You should previously have run `lpass
+login` for this to work.
+
+`op:name` -- Use the 1Password command-line client `op(1)` to retrieve
+the named password.
+
+`pass:password` -- The actual password is password.  Since the
+password is visible to utilities such as `ps(1)` and possibly leaked
+into the shell history file, this form should only be used where
+security is not important.
+
+`tty[:prompt]` -- This is the default: `Getpass` will prompt the user on
+the controlling tty using the provided `prompt`.  If no `prompt` is
+provided, then `Getpass` will use "Password: ".
+
+## Examples
+
+```
+package main
+
+import (
+       "flag"
+       "fmt"
+       "log"
+
+       "github.com/jschauma/getpass"
+)
+
+func main() {
+
+       var pass string
+       flag.StringVar(&pass, "p", "tty", "password method")
+       flag.Parse()
+
+       // Try out any of the options:
+       p, err := getpass.Getpass(pass)
+       if err != nil {
+               log.Fatal("Unable to get password from user: ", err)
+       } else {
+               fmt.Printf("%s\n", p)
+       }
+
+       // Alternatively:
+
+       // This will prompt the user to enter a password interactively,
+       // using the default prompt.
+       p, err = getpass.Getpass()
+       if err != nil {
+               log.Fatal("Unable to get password from user: ", err)
+       } else {
+               fmt.Printf("%s\n", p)
+       }
+
+       // Using a custom prompt:
+       p, err = getpass.Getpass("tty:Please enter your secret passphrase: ")
+       if err != nil {
+               log.Fatal("Unable to get password from user: ", err)
+       } else {
+               fmt.Printf("%s\n", p)
+       }
+
+       // Using an environment variable:
+       p, err = getpass.Getpass("env:MYSECRET")
+       if err != nil {
+               log.Fatal("Unable to get password from user: ", err)
+       } else {
+               fmt.Printf("%s\n", p)
+       }
+
+       // Using a file:
+       p, err = getpass.Getpass("file:~/.secret")
+       if err != nil {
+               log.Fatal("Unable to get password from user: ", err)
+       } else {
+               fmt.Printf("%s\n", p)
+       }
+
+       // etc. etc.
+}
+```
+
+---
+
+See also:
+* https://www.netmeister.org/blog/passing-passwords.html
+* https://www.netmeister.org/blog/consistent-tools.html#passwords
Index: pkgsrc/security/go-getpass/Makefile
diff -u /dev/null pkgsrc/security/go-getpass/Makefile:1.1
--- /dev/null   Sun Jul 16 18:36:44 2023
+++ pkgsrc/security/go-getpass/Makefile Sun Jul 16 18:36:44 2023
@@ -0,0 +1,22 @@
+# $NetBSD: Makefile,v 1.1 2023/07/16 18:36:44 jschauma Exp $
+
+DISTNAME=      getpass-0.2.1
+PKGNAME=       go-${DISTNAME}
+MASTER_SITES=  ${MASTER_SITE_GITHUB:=jschauma/}
+CATEGORIES=    security
+GITHUB_PROJECT=        getpass
+GITHUB_TAG=    v${PKGVERSION_NOREV}
+
+MAINTAINER=    jschauma%NetBSD.org@localhost
+HOMEPAGE=      https://github.com/jschauma/getpass
+COMMENT=       a Go module to get a password
+LICENSE=       mit
+
+GO_DIST_BASE=  ${GITHUB_PROJECT}-${PKGVERSION_NOREV}
+GO_SRCPATH=    github.com/jschauma/getpass
+
+post-build:
+       rm -fr ${WRKDIR}/bin
+
+.include "../../lang/go/go-package.mk"
+.include "../../mk/bsd.pkg.mk"
Index: pkgsrc/security/go-getpass/PLIST
diff -u /dev/null pkgsrc/security/go-getpass/PLIST:1.1
--- /dev/null   Sun Jul 16 18:36:44 2023
+++ pkgsrc/security/go-getpass/PLIST    Sun Jul 16 18:36:44 2023
@@ -0,0 +1,9 @@
+@comment $NetBSD: PLIST,v 1.1 2023/07/16 18:36:44 jschauma Exp $
+gopkg/pkg/${GO_PLATFORM}/github.com/jschauma/getpass.a
+gopkg/src/github.com/jschauma/getpass/LICENSE
+gopkg/src/github.com/jschauma/getpass/LICENSE
+gopkg/src/github.com/jschauma/getpass/README.md
+gopkg/src/github.com/jschauma/getpass/getpass.go
+gopkg/src/github.com/jschauma/getpass/getpass_test.go
+gopkg/src/github.com/jschauma/getpass/example/getpass_example.go
+gopkg/src/github.com/jschauma/getpass/go.mod
Index: pkgsrc/security/go-getpass/distinfo
diff -u /dev/null pkgsrc/security/go-getpass/distinfo:1.1
--- /dev/null   Sun Jul 16 18:36:44 2023
+++ pkgsrc/security/go-getpass/distinfo Sun Jul 16 18:36:44 2023
@@ -0,0 +1,5 @@
+$NetBSD: distinfo,v 1.1 2023/07/16 18:36:44 jschauma Exp $
+
+BLAKE2s (getpass-0.2.1.tar.gz) = b175b5961c3c8ebb61d499d7c5b766df89c57e4e9532fcee753bfd0c9dff6dcf
+SHA512 (getpass-0.2.1.tar.gz) = 9f476d4a2a172a2913d606fe7898022a6eebed0e89f04ef05b2454e887bdb43d671dec269e9ea3df19a32d782197e1bb4f50d1b29ec5aeafb5cc0e6bae9b5e02
+Size (getpass-0.2.1.tar.gz) = 4742 bytes



Home | Main Index | Thread Index | Old Index