Skip to content

Commit ccaf89a

Browse files
authored
Merge pull request rancher-sandbox#8946 from mook-as/creds/no-require-pass
RPM spec: don't require pass
2 parents d5b01d8 + 6ed0dec commit ccaf89a

File tree

5 files changed

+39
-11
lines changed

5 files changed

+39
-11
lines changed

.github/actions/spelling/expect.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ libgtk
449449
libnspr
450450
libnss
451451
libpango
452+
libsecret
452453
libva
453454
libx
454455
libxcb

bats/tests/helpers/commands.bash

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ fi
1717
if is_macos; then
1818
CRED_HELPER="$PATH_RESOURCES/$PLATFORM/bin/docker-credential-osxkeychain"
1919
elif is_linux; then
20-
CRED_HELPER="$PATH_RESOURCES/$PLATFORM/bin/docker-credential-pass"
20+
if command -v pass; then
21+
CRED_HELPER="$PATH_RESOURCES/$PLATFORM/bin/docker-credential-pass"
22+
else
23+
CRED_HELPER="$PATH_RESOURCES/$PLATFORM/bin/docker-credential-secretservice"
24+
fi
2125
elif is_windows; then
2226
# Our docker-cli for WSL defaults to "wincred.exe" as well
2327
CRED_HELPER="$PATH_RESOURCES/win32/bin/docker-credential-wincred.exe"

packaging/linux/rancher-desktop.spec

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ Requires: qemu-utils
4949
Requires: qemu-system-x86
5050
Requires: pass
5151
Requires: openssh-client
52-
Requires: gnupg
5352
Requires: gnutls-bin # To enumerate system certificates
5453
Requires: libasound2
5554
Requires: libatk1.0-0
@@ -83,9 +82,9 @@ Requires: qemu
8382
Requires: openssh-clients
8483

8584
%if 0%{?fedora} || 0%{?rhel}
86-
Requires: pass
85+
Requires: (pass or libsecret)
8786
%else
88-
Requires: password-store
87+
Requires: (password-store or libsecret-1-0)
8988
Requires: qemu-img
9089
%endif
9190

pkg/rancher-desktop/utils/__tests__/dockerDirManager.spec.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,17 +435,40 @@ describe('DockerDirManager', () => {
435435
});
436436

437437
it('should return the right cred helper for the right platform', async() => {
438+
jest.spyOn(subj as any, 'credHelperWorking').mockReturnValue(true);
438439
await expect(subj['getCredsStoreFor'](undefined)).resolves.toEqual(platformDefaultHelper);
439440
});
440441

441442
it('should return the platform helper if the existing one does not work', async() => {
442-
jest.spyOn(subj as any, 'credHelperWorking').mockResolvedValue(false);
443+
jest.spyOn<any, any, (_: string) => Promise<boolean>>(subj, 'credHelperWorking').mockImplementation((helperName) => {
444+
return Promise.resolve(os.platform() === 'linux' && helperName === 'pass');
445+
});
443446
await expect(subj['getCredsStoreFor']('broken-helper')).resolves.toEqual(platformDefaultHelper);
444447
});
445448

446-
itLinux('should return secretservice when that is the current value', async() => {
447-
jest.spyOn(subj as any, 'credHelperWorking').mockResolvedValue(false);
448-
await expect(subj['getCredsStoreFor']('secretservice')).resolves.toEqual('secretservice');
449+
itLinux('should default to pass when it works', async() => {
450+
jest.spyOn<any, any, (_: string) => Promise<boolean>>(subj, 'credHelperWorking').mockImplementation((helperName) => {
451+
expect(helperName).toEqual('pass');
452+
453+
return Promise.resolve(true);
454+
});
455+
await expect(subj['getCredsStoreFor'](undefined)).resolves.toEqual('pass');
456+
});
457+
458+
itLinux('should default to pass when secretservice is broken', async() => {
459+
jest.spyOn<any, any, (_: string) => Promise<boolean>>(subj, 'credHelperWorking').mockImplementation((helperName) => {
460+
return Promise.resolve(helperName === 'pass');
461+
});
462+
await expect(subj['getCredsStoreFor']('secretservice')).resolves.toEqual('pass');
463+
});
464+
465+
itLinux('should default to secretservice when pass does not work', async() => {
466+
jest.spyOn<any, any, (_: string) => Promise<boolean>>(subj, 'credHelperWorking').mockImplementation((helperName) => {
467+
expect(helperName).toEqual('pass');
468+
469+
return Promise.resolve(false);
470+
});
471+
await expect(subj['getCredsStoreFor'](undefined)).resolves.toEqual('secretservice');
449472
});
450473
});
451474
});

pkg/rancher-desktop/utils/dockerDirManager.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,12 @@ export class DockerDirManager {
283283
} else if (platform === 'darwin') {
284284
return 'osxkeychain';
285285
} else if (platform === 'linux') {
286-
if (currentCredsStore === 'secretservice') {
287-
return 'secretservice';
288-
} else {
286+
// On Linux, we need to match the logic used by oras-go (used by helm):
287+
// If `pass` works, use it; otherwise use secret service.
288+
if (await this.credHelperWorking('pass')) {
289289
return 'pass';
290290
}
291+
return 'secretservice';
291292
} else {
292293
throw new Error(`platform "${ platform }" is not supported`);
293294
}

0 commit comments

Comments
 (0)