Skip to content

Commit 440f7ea

Browse files
author
Sam Ban
committed
update servers upon group operations
1 parent c487fc2 commit 440f7ea

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

backend/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func ReadConfig() *config {
2727
C.home, _ = os.UserHomeDir()
2828
b, err := os.ReadFile(C.home + "/.ssh/.sshman")
2929
if err != nil {
30+
C.persistent = true // testing doesn't have this where we just create the config
3031
fmt.Println("No configuration file ~/.ssh/.sshman, creating one")
3132
return &C
3233
}

cmd/groupsServer.go

+2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ $ ./sshman groups server serveralias group1 group2
2222
email := args[0]
2323
groups := args[1:]
2424
if host, ok := cfg.Hosts[args[0]]; ok {
25+
oldgroups := host.GetGroups()
2526
host.SetGroups(groups)
2627
cfg.Hosts[args[0]] = host
28+
host.UpdateGroups(cfg, oldgroups)
2729
cfg.Write()
2830
fmt.Printf("Groups for %s edited: %v\n", email, host.GetGroups())
2931
}

cmd/groupsUser.go

+2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ $ ./sshman groups user [email protected] group1 group2
2323
groups := args[1:]
2424
key, user := cfg.GetUserByEmail(email)
2525
if user != nil {
26+
oldGroups := user.GetGroups()
2627
user.SetGroups(groups)
2728
cfg.Users[key] = *user
29+
user.UpdateGroups(cfg, oldGroups)
2830
cfg.Write()
2931
fmt.Printf("Groups for %s edited: %v\n", email, groups)
3032
}

0 commit comments

Comments
 (0)