Skip to content

Commit c2ca986

Browse files
Hugo Osvaldo BarrerathaJeztah
authored andcommitted
Set a better displaylabel for secretservice
Secretservice entries have a "label". This is intended to be a human-readable description. It's actually called "Description" in UIs like seahorse, and the listing of existing secrets shows this as a name for each one. The entries stored by the credential helper set this to simply the repository URL. This is rather unfriendly, since entries like "gitlab.com" and "index.docker.io/v1" show up. Mixed in with entries from all other applications, it's hard to figure out what application owns each entry. This commit changes the label used when saving entries to be something human-readable (this is the intent of the "label" field, btw). Because of the naming scheme, this also results in all entries being shown together by default (since UIs tend to sort lexicographically). New entries will now be stores as: Registry credentials for $REGISTRY_URL Note that items stored by the secret service have multiple fields inside of them. One of those fields is called "label", and is used by the helper to filter items from the secret service. This "label" field is entirely unrelated to the items' label. The naming is most unfortunate. Signed-off-by: Hugo Osvaldo Barrera <[email protected]> Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 407e50d commit c2ca986

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

secretservice/secretservice.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ const SecretSchema *docker_get_schema(void)
1717
return &docker_schema;
1818
}
1919

20-
GError *add(char *label, char *server, char *username, char *secret) {
20+
GError *add(char *label, char *server, char *username, char *secret, char *displaylabel) {
2121
GError *err = NULL;
2222

2323
secret_password_store_sync (DOCKER_SCHEMA, SECRET_COLLECTION_DEFAULT,
24-
server, secret, NULL, &err,
24+
displaylabel, secret, NULL, &err,
2525
"label", label,
2626
"server", server,
2727
"username", username,

secretservice/secretservice.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ func (h Secretservice) Add(creds *credentials.Credentials) error {
3333
defer C.free(unsafe.Pointer(username))
3434
secret := C.CString(creds.Secret)
3535
defer C.free(unsafe.Pointer(secret))
36+
displayLabel := C.CString("Registry credentials for " + creds.ServerURL)
37+
defer C.free(unsafe.Pointer(displayLabel))
3638

37-
if err := C.add(credsLabel, server, username, secret); err != nil {
39+
if err := C.add(credsLabel, server, username, secret, displayLabel); err != nil {
3840
defer C.g_error_free(err)
3941
errMsg := (*C.char)(unsafe.Pointer(err.message))
4042
return errors.New(C.GoString(errMsg))

secretservice/secretservice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const SecretSchema *docker_get_schema(void) G_GNUC_CONST;
66

77
#define DOCKER_SCHEMA docker_get_schema()
88

9-
GError *add(char *label, char *server, char *username, char *secret);
9+
GError *add(char *label, char *server, char *username, char *secret, char *displaylabel);
1010
GError *delete(char *server);
1111
GError *get(char *server, char **username, char **secret);
1212
GError *list(char *label, char *** paths, char *** accts, unsigned int *list_l);

0 commit comments

Comments
 (0)