Skip to content

feat: added logout command#379

Closed
marsom wants to merge 5 commits into
openpubkey:mainfrom
marsom:logout
Closed

feat: added logout command#379
marsom wants to merge 5 commits into
openpubkey:mainfrom
marsom:logout

Conversation

@marsom
Copy link
Copy Markdown

@marsom marsom commented Oct 20, 2025

like discussed in #311

Signed-off-by: Markus Sommer <markus.sommer@postfinance.ch>
Comment thread main.go Outdated
Comment on lines +223 to +226
go func() {
<-sigs
cancel()
}()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this needed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

i copied it from the login command above. however i think we coud simply all the smae into

ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) defer cancel()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

login needs this because it does some complex stuff with channels that causes the SIGTERM to hang unless we do this. Maybe we need it hear, maybe we don't, I wanted to know if we needed it because I wouldn't expect the sigterm call to hang for this functionality and I'd try to find the source of it.

Comment thread main.go Outdated
Comment thread main.go Outdated
Comment thread commands/logout.go Outdated
afs := &afero.Afero{Fs: l.Fs}

// empty config file
err = afs.WriteFile(userOpkSshConfig, []byte{}, 0o600)
Copy link
Copy Markdown
Member

@EthanHeilman EthanHeilman Oct 20, 2025

Choose a reason for hiding this comment

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

Why is logout creating a config file? Shouldn't it only be deleting keys?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

the login --configure adds an include directive to the users .ssh/config file includeing the given file. my intention was that referceing a non existing file in my config is not good. i will test it, if ssh complains. if not, i can remove the file instead.

also cleaning up the user config is not good i think, because the user needs to do the configure again.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree we shouldn't be deleting the config, but if no config exists, I don't think we should be creating it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

ok, i changed the code

Comment thread commands/logout.go Outdated
Comment thread commands/logout.go Outdated
return fmt.Errorf("key type (%s) has no default output file name; use -i <filePath>", l.KeyTypeArg.String())
}

for _, keyFilename := range keyFileNames {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you make this code more clear that we checking if a key is an opkssh before removing it. I initially thought the function removeKeys, based on the name, just deleted the keys without performing any check.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

ill rename the function

@EthanHeilman
Copy link
Copy Markdown
Member

@marsom Thanks for this PR. Very glad to see someone working on this issue. Can you provide a more detailed PR description and also tests? Since you imported the afero.Fs pattern, unittests shouldn't be that difficult to write

@EthanHeilman EthanHeilman added the enhancement New feature or request label Oct 20, 2025
@marsom
Copy link
Copy Markdown
Author

marsom commented Oct 20, 2025

@marsom Thanks for this PR. Very glad to see someone working on this issue. Can you provide a more detailed PR description and also tests? Since you imported the afero.Fs pattern, unittests shouldn't be that difficult to write

I will update the branch

EthanHeilman and others added 2 commits October 24, 2025 14:50
Signed-off-by: Markus Sommer <markus.sommer@postfinance.ch>
@fdcastel
Copy link
Copy Markdown
Contributor

Superseded by #496 . We can close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants