Skip to content

Don't use gpg in Debian instruction#4610

Merged
vilmibm merged 1 commit intocli:trunkfrom
TobiX:no-gpg-debian
Nov 17, 2021
Merged

Don't use gpg in Debian instruction#4610
vilmibm merged 1 commit intocli:trunkfrom
TobiX:no-gpg-debian

Conversation

@TobiX
Copy link
Contributor

@TobiX TobiX commented Oct 25, 2021

It's not really necessary, since apt can work with the keyring file
hosted on cli.github.com.

It's not really necessary, since apt can work with the keyring file
hosted on cli.github.com.
@TobiX TobiX requested a review from a team as a code owner October 25, 2021 18:53
@TobiX TobiX requested review from mislav and removed request for a team October 25, 2021 18:53
@cliAutomation
Copy link
Collaborator

Hi! Thanks for the pull request. Please ensure that this change is linked to an issue by mentioning an issue number in the description of the pull request. If this pull request would close the issue, please put the word 'Fixes' before the issue number somewhere in the pull request body. If this is a tiny change like fixing a typo, feel free to ignore this message.

Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for letting us know!


```bash
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with dd. Is it equally available on Ubuntu and Raspberry Pi OS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's part of coreutils, so it should be available on all Debian derivatives. You could probably just use cat, but then the command gets a bit ugly:

curl [...] | sudo sh -c 'cat > /usr/share/keyrings/githubcli-archive-keyring.gpg'

or even tee, like in the line below, but I'm not sure how tee handles binary data, so I went with dd. (Inspired by this post: https://unix.stackexchange.com/a/367709/498490)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see now. gpg --dearmor would change the incoming stream if it was encoded as ASCII, but it was a binary key to start with, so gpg doesn't do anything but save the stream to a file. dd of= does the same.

Since curl -o <file> can save to a file, we don't have to pipe to any extra utility. Could you switch to using that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I was under the impression that all those curl <something> | sudo [...] were written in that way so that security-minded administrators could run the networking tool (curl) as a less-privileged user as the file writing operation... But maybe they are just written like that to avoid nested shells (sudo -c "[...] > file"). I don't mind either way, your call!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah fair point running network calls without elevated permissions. I hadn't thought of that. Then maybe the dd approach is fine. @vilmibm what's your call?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with dd, this makes sense to me. I was cargo coding the gpg invocation.

mislav
mislav previously requested changes Oct 26, 2021

```bash
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see now. gpg --dearmor would change the incoming stream if it was encoded as ASCII, but it was a binary key to start with, so gpg doesn't do anything but save the stream to a file. dd of= does the same.

Since curl -o <file> can save to a file, we don't have to pipe to any extra utility. Could you switch to using that?

@vilmibm vilmibm dismissed mislav’s stale review November 17, 2021 16:47

as per discussion on comment

@vilmibm vilmibm enabled auto-merge November 17, 2021 16:47
@vilmibm vilmibm merged commit 57215ec into cli:trunk Nov 17, 2021
@TobiX TobiX deleted the no-gpg-debian branch November 17, 2021 17:30
@VictorBatta VictorBatta mentioned this pull request Dec 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants