Skip to content

Commit

Permalink
Update the README and usage text for version subcommand. (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
amigus authored Sep 12, 2024
1 parent 8d2b02d commit 8cd22cd
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ func doit() {

The `.DefaultCollection()` returns whatever collection the _default_ _alias_ refers to.
It will generate an error if the _default_ alias is not set.
It usually points to the _login_ keyring.
Most Linux Keyring interfaces allow the user to set it.

The `.NamedCollection(string)` method provides access to collections by name.
Expand All @@ -78,16 +77,19 @@ The Linux binary supports three subcommands:
1. `get`
2. `set`
3. `del`
4. `version`

_Get_ and _del_ require one parameter; name, which is the secret _Label_ in D-Bus API terms.

_Del_ accepts one or more secret labels and deletes all of them.
If it generates an error it will stop.
_Del_ or _delete_ accepts one or more secret labels and deletes all of them.
It will stop on the first error condition it encounters.

_Set_ also requires the data as a _single_ string in the second parameter.
_Set_ requires the data as a _single_ string in the second parameter.
For example, `set foo bar baz` will generate an error but `set foo 'bar baz'` will work.
If the string is `-` then the string is read from standard input.

_Version_ prints the version and exits with status 0.

### Base64 encoding

_Get_ and _set_ take a `-b` or `--base64` flag that handles base64 automatically.
Expand Down Expand Up @@ -125,11 +127,12 @@ Error output goes to `stderr` so adding `2>/dev/null` to the end of a command wi

#### No keyring

The login collection does not exist because the keyring does not exist.
KDE may create _kdewallet_ instead of _login_ like GNOME.
The default alias does not point to a collection.
It might not exist or there may not be a default.
Use KDE Wallet Manager or GNOME Seahorse to create a collection and/or it as default.

```shell
Unable to get secret 'test_cred': Unable to retrieve secret 'test_cred' for application 'lkru' from collection '/org/freedesktop/secrets/collection/login': Object does not exist at path “/org/freedesktop/secrets/collection/login
Unable to get secret 'test_cred': Unable to retrieve secret 'test_cred' for application 'lkru' from collection '/org/freedesktop/secrets/aliases/default': Object does not exist at path “/org/freedesktop/secrets/aliases/default
```

#### No matching secret
Expand All @@ -141,9 +144,9 @@ If the secret was not created with lkru, it may not have the same [attributes](/
Unable to get secret 'test_cred': Unable to retrieve secret 'test_cred' for application 'lkru' from collection '/org/freedesktop/secrets/aliases/default': org.freedesktop.Secret.Collection.SearchItems returned nothing
```

#### No D-Bus Session
#### No D-Bus Session Secret Service

There may not be a D-Bus Session to host the Secret Service.
There is no Secret Service registered on the D-Bus Session.
This happens when the user is not logged into the GUI.

```shell
Expand All @@ -152,7 +155,7 @@ Unable to get the default keyring: Unable to open a D-Bus session: The name org.

#### No D-Bus

The system may not host D-Bus.
The system is not running D-Bus.
Several lightweight linux distributions ship without it by default.

```shell
Expand Down
4 changes: 2 additions & 2 deletions cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
var getCmd = &cobra.Command{
Use: "get [flags] <label>",
Args: cobra.ExactArgs(1),
Short: "Get a secret from the Linux Keyring.",
Long: `Get a secret from the Linux Keyring by it's label and print the value.
Short: "Get a secret from the Linux Keyring",
Long: `Get a secret from the Linux Keyring by label and print the value.
Use -b or --base64 to decode the secret from base64 before printing.
`,
Run: func(cmd *cobra.Command, args []string) {
Expand Down
18 changes: 9 additions & 9 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ var use_base64 = false
var rootCmd = &cobra.Command{
Use: "lkru [flags] <get|set|del>",
Short: "Linux Keyring Utility (lkru)",
Long: `lkru is a Linux Keyring Utility.
It manages secrets in a Linux Keyring using the collection interface of the D-Bus Secrets API.
It has a trivial set, get, and delete interface where set creates and always overwrites.
There is no list or search functionality.
Long: `Linux Keyring Utility manages secrets in a Linux Keyring.
It uses the collection interface of the D-Bus Secrets API.
It has a trivial set, get, and delete interface.
There is no list or search.
It sets attributes on the secret to facilitate namespacing.
The application name is an attribute on the secret.
There is an agent attribute containing 'lkru (Linux Keyring Utility)'.
And the label becomes the _id_ attribute on the secret.
It sets three attributes on the secret to facilitate lookups and namespacing.
1. The secret label becomes the 'id' attribute.
2. The application name is settable and 'lkru' by default.
3. The agent attribute always contains 'lkru (Linux Keyring Utility)'.
The default application name is 'lkru' and the default collection is 'login'.
The default application name is 'lkru' and the default collection is the 'default' alias.
`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion cmd/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
var setCmd = &cobra.Command{
Use: "set [flags] <label> <secret string>",
Args: cobra.ExactArgs(2),
Short: "Set a secret in the Linux keyring.",
Short: "Set a secret in the Linux keyring",
Long: `Set secret string as a secret in the Linux keyring with the corresponding label.
If the secret string is "-", lkru reads it from standard input.
Use -b or --base64 to encode the secret string as base64 before storing it.
Expand Down
9 changes: 5 additions & 4 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
var Version string

var versionCmd = &cobra.Command{
Use: "version",
Args: cobra.NoArgs,
Short: "Print the version",
Long: `Prints the version and exits with a status of 0.`,
Use: "version",
Aliases: []string{"ver"},
Args: cobra.NoArgs,
Short: "Print the version",
Long: `Prints the version and exits with a status of 0.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Fprintf(cmd.OutOrStdout(), "%s %s\n", application, Version)
},
Expand Down

0 comments on commit 8cd22cd

Please sign in to comment.