summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-09-21 07:47:15 +0300
committerLars Wirzenius <liw@liw.fi>2023-09-21 07:47:15 +0300
commite3364a68f77a0af164be19b4b802033cc778911d (patch)
treea8c75f9fc4e0f5122b13d812abbf04ecc395a79f
parentbb830960fedcc58a47141406ef7707f4892fb2db (diff)
downloadsshca-e3364a68f77a0af164be19b4b802033cc778911d.tar.gz
fix: add principals to host
Previously, adding replaced the whole set of principals, which was wrong. Also, change the test scenario to catch the problem this fixes. Sponsored-by: author
-rw-r--r--src/cmd/host.rs2
-rw-r--r--sshca.md7
2 files changed, 7 insertions, 2 deletions
diff --git a/src/cmd/host.rs b/src/cmd/host.rs
index d3a85b4..830a5f4 100644
--- a/src/cmd/host.rs
+++ b/src/cmd/host.rs
@@ -466,7 +466,7 @@ pub struct AddPrincipals {
impl Runnable for AddPrincipals {
fn run(&mut self, _config: &Config, store: &mut KeyStore) -> Result<(), CAError> {
if let Some(host) = store.get_host_mut(&self.hostname) {
- host.set_principals(&self.principals);
+ host.add_principals(&self.principals);
assert!(store.is_dirty());
Ok(())
} else {
diff --git a/sshca.md b/sshca.md
index d9afeb9..4e3cbc9 100644
--- a/sshca.md
+++ b/sshca.md
@@ -468,7 +468,12 @@ when I run sshca host principals list myhost
then stdout doesn't contain "alfred.lan"
then stdout doesn't contain "alfred.example.com"
-when I run sshca host principals add --host myhost alfred.lan alfred.example.com
+when I run sshca host principals add --host myhost alfred.lan
+when I run sshca host principals list myhost
+then stdout contains "alfred.lan"
+then stdout doesn't contain "alfred.example.com"
+
+when I run sshca host principals add --host myhost alfred.example.com
when I run sshca host principals list myhost
then stdout contains "alfred.lan"
then stdout contains "alfred.example.com"