File: task.yaml

package info (click to toggle)
snapd 2.72-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 80,412 kB
  • sloc: sh: 16,506; ansic: 16,211; python: 11,213; makefile: 1,919; exp: 190; awk: 58; xml: 22
file content (26 lines) | stat: -rw-r--r-- 1,286 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
summary: Test that we can run go-code as effectively another user. 

details: |
  Check that a Go program can use RunAsUidGid to setuid/gid after locking the
  OS thread (so no other code can run), run some code and then restore the
  uid/gid. This is important so we can write auth.json as non-root.

# exclude core as there is no go
systems: [-ubuntu-core-*]

execute: |
  # Verify that no other go-routine is run under the same GID/UID as the code who has
  # locked the OS thread and changed GID/UID.
  go build ./runas-1/runas-verify-uidgid.go
  test "$(./runas-verify-uidgid)" = "before: 0/0, during: 12345/12345 (<nil>), after: 0/0; status: OK"
  test "$(sudo -u '#12345' -g '#12345' ./runas-verify-uidgid)" = "before: 12345/12345, during: 12345/12345 (<nil>), after: 12345/12345; status: OK"

  # Verify that all go-routines spawned by a locked OS thread is run on different, clean OS thread.
  # Prior to 1.10 it was possible for the spawned thread by locked OS thread to inherit its
  # state. See https://github.com/golang/go/issues/20676
  go build ./runas-2/runas-verify-thread-locked.go
  ./runas-verify-thread-locked

  # Verify error handling when restoring the uid/gid works correctly
  go build ./runas-3/runas-errors.go
  test "$(sudo ./runas-errors)" = "status: OK"