// RPC primitives for safcm: message and additional types // SPDX-License-Identifier: GPL-3.0-or-later // Copyright (C) 2021-2024 Simon Ruderich package safcm import ( "encoding/gob" "io/fs" ) // Messages type Msg interface { msg() // unused, only to implement interface } type MsgLog struct { Level LogLevel Text string } type MsgInfoReq struct { LogLevel LogLevel DetectGroups []string } type MsgInfoResp struct { Goos string Goarch string Output []string Error string } type MsgSyncReq struct { DryRun bool Groups []string // for commands Files map[string]*File Packages []string Services []string Commands []*Command } type MsgSyncResp struct { FileChanges []FileChange PackageChanges []PackageChange ServiceChanges []ServiceChange CommandChanges []CommandChange Error string } type MsgQuitReq struct { } type MsgQuitResp struct { } func (MsgLog) msg() {} func (MsgInfoReq) msg() {} func (MsgInfoResp) msg() {} func (MsgSyncReq) msg() {} func (MsgSyncResp) msg() {} func (MsgQuitReq) msg() {} func (MsgQuitResp) msg() {} func init() { // Necessary to receive "into" an interface type gob.Register(MsgLog{}) gob.Register(MsgInfoReq{}) gob.Register(MsgInfoResp{}) gob.Register(MsgSyncReq{}) gob.Register(MsgSyncResp{}) gob.Register(MsgQuitReq{}) gob.Register(MsgQuitResp{}) } // Types used in messages type File struct { OrigGroup string // group which provided this file Path string Mode fs.FileMode User string Uid int //lint:ignore ST1003 UID is too ugly Group string Gid int //lint:ignore ST1003 GID is too ugly Data []byte TriggerCommands []string } type Command struct { OrigGroup string // group which provided this command Cmd string } type FileChange struct { Path string Created bool Old FileChangeInfo New FileChangeInfo DataDiff string } type FileChangeInfo struct { Mode fs.FileMode User string Uid int //lint:ignore ST1003 UID is too ugly Group string Gid int //lint:ignore ST1003 GID is too ugly } type PackageChange struct { Name string } type ServiceChange struct { Name string Started bool Enabled bool } type CommandChange struct { Command string Trigger string // path which triggered this command (optional) Output string // stdout and stderr combined Error string }