Skip to content

Commit

Permalink
i/builtin: do not use pointer to the local for-loop variable, instead…
Browse files Browse the repository at this point in the history
… use copies
  • Loading branch information
Meulengracht committed Feb 23, 2024
1 parent f7fea7f commit 765f72e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions interfaces/builtin/polkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ func (iface *polkitInterface) BeforePreparePlug(plug *snap.PlugInfo) error {
}

func isPathMountedWritable(mntProfile *osutil.MountProfile, fsPath string) bool {
mntMap := make(map[string]*osutil.MountEntry, len(mntProfile.Entries))
mntMap := make(map[string]osutil.MountEntry, len(mntProfile.Entries))
for _, mnt := range mntProfile.Entries {
mntMap[mnt.Dir] = &mnt
mntMap[mnt.Dir] = mnt
}

// go backwards in path until we hit a match
Expand Down
18 changes: 18 additions & 0 deletions interfaces/builtin/polkit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,24 @@ rpool/ROOT/ubuntu/usr/share /usr/share zfs rw,relatime,xattr,posixacl,casesensit
"/usr/share/",
true,
},
// Test an more real example
{
`/dev/sda3 /run/mnt/ubuntu-boot ext4 rw,relatime 0 0
/dev/sda2 /run/mnt/ubuntu-seed vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro>
/dev/sda5 /run/mnt/data ext4 rw,nosuid,relatime 0 0
/dev/sda4 /run/mnt/ubuntu-save ext4 rw,relatime,stripe=4 0 0
/dev/loop0 /run/mnt/base squashfs ro,relatime,errors=continue 0 0
/dev/loop1 /run/mnt/gadget squashfs ro,relatime,errors=continue 0 0
/dev/loop2 /run/mnt/kernel squashfs ro,relatime,errors=continue 0 0
/dev/loop3 /run/mnt/snapd squashfs ro,relatime,errors=continue 0 0
/dev/loop0 / squashfs ro,relatime,errors=continue 0 0
/dev/loop5 /snap/test-snapd-rsync-core22/1 squashfs ro,nodev,relatime,errors=continue 0 0
/dev/loop6 /snap/jq-core22/1 squashfs ro,nodev,relatime,errors=continue 0 0
nsfs /run/snapd/ns/jq-core22.mnt nsfs rw 0 0
`,
"/usr/share/polkit-1/actions",
false,
},
}

for _, t := range tests {
Expand Down

0 comments on commit 765f72e

Please sign in to comment.