Skip to content

Commit 77fa757

Browse files
mariusSincovicikeliramu
authored andcommitted
add snap new interfaces
Signed-off-by: Marius Sincovici <[email protected]>
1 parent 3aa6aa9 commit 77fa757

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cmd/daemon/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ func main() {
284284
machineID := machineIdGenerator.GetMachineID()
285285

286286
// obfuscated machineID and add the mask to identify how the ID was generated
287-
deviceID := fmt.Sprintf("%x_%x", sha256.Sum256([]byte(machineID.String()+Salt)), machineIdGenerator.GetUsedInformationMask())
287+
deviceID := fmt.Sprintf("%x_%d", sha256.Sum256([]byte(machineID.String()+Salt)), machineIdGenerator.GetUsedInformationMask())
288+
log.Println("read", deviceID)
288289

289290
analytics := newAnalytics(eventsDbPath, fsystem, defaultAPI, Version, Environment, deviceID)
290291
heartBeatSubject.Subscribe(analytics.NotifyHeartBeat)

snapconf/snapconf.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const (
3939
InterfaceHome Interface = "home"
4040
InterfaceLoginSessionObserve Interface = "login-session-observe"
4141
InterfaceSystemObserve Interface = "system-observe"
42+
InterfaceHardwareObserve Interface = "hardware-observe"
4243
)
4344

4445
// IsUnderSnap defines whether the current process is executed under snapd
@@ -59,8 +60,11 @@ type ConnChecker struct {
5960

6061
// NewSnapChecker snap permission checker with specific setup
6162
func NewSnapChecker(publisherErr events.Publisher[error]) *ConnChecker {
63+
// currently the order is important for machine ID generation:
64+
// At the moment InterfaceHardwareObserve needs to be first because snap restarts the daemon only for some of the interfaces.
6265
return NewConnChecker(
6366
[]Interface{
67+
InterfaceHardwareObserve,
6468
InterfaceNetwork,
6569
InterfaceNetworkBind,
6670
InterfaceNetworkControl,
@@ -71,6 +75,7 @@ func NewSnapChecker(publisherErr events.Publisher[error]) *ConnChecker {
7175
InterfaceSystemObserve,
7276
},
7377
[]Interface{
78+
InterfaceHardwareObserve,
7479
InterfaceNetwork,
7580
InterfaceNetworkBind,
7681
InterfaceNetworkControl,

0 commit comments

Comments
 (0)