18 Commits

Author SHA1 Message Date
Dimitri John Ledkov
d55f3123d4 go: go fix with 1.18
Apply `go fix ./...` to the whole code base using go-1.18 to remove
old build tags.
2023-09-25 13:22:14 +02:00
Michael Vogt
14d835a10c osutil: fix error message when restoring the "reuid" (thanks to Alfonso) 2023-07-20 13:52:49 +02:00
Michael Vogt
accf67f1a4 osutil: fix silly mistake from d35eccff 2023-07-20 13:52:49 +02:00
Michael Vogt
13717898a2 osutil: add more caveats to RunAsUidGid 2023-07-20 13:52:49 +02:00
Michael Vogt
089791d23e osutil: clarify RunAsUidGid() comment about LockOSThread() 2023-07-20 13:52:49 +02:00
Michael Vogt
da86ee58d0 osutil: remove no longer needed sys.UnrecoverableError 2023-07-20 13:52:49 +02:00
Michael Vogt
0ccf1491bf osutil: tweak error handling in sys.RunAsUidGid()
When an error happens during the restore of the uid/gid in RunAsUidGid()
deal with that more gracefully. Instead of panic() it is enough to
return the error but *not* call `runtime.UnlockOSThread()`. Because
the uid/gid is per OS-thread on restore failure it is enough to let
the thread "die" which will happen automatically when
runtime.UnlockOSThread is not called.

Also adding a test that ensures that on failure the thread is not
reused and the other threads have the correct uid.
2023-07-20 13:52:49 +02:00
Michael Vogt
57faa0dac8 sys: add comment about syscall.Setreuid() and RawSyscall
Clarify that on the *kernel* level the user/group ID are per-thread
attributes. However POSIX require all thread to share the same
credentials. This is why the code in RunAsUidGid uses RawSyscall()
and not the syscall.Setreuid() or similar helper.
2023-07-20 13:52:49 +02:00
Philip Meulengracht
d019a26956 osutil,tests: move runas code to own file
Add additional testing to verify goroutines dont inherit from a locked thread
2023-07-20 13:52:49 +02:00
Philip Meulengracht
b0bddef4c8 osutil/sys: dont forget darwin enums 2023-07-20 13:52:49 +02:00
Philip Meulengracht
bd6fddcc3e client,osutil: support for accessing auth.json without root
Revive PR 4983 from @chipaca as the launchpad issue is still relevant, and we moved on to newer go versions a long time ago.
2023-07-20 13:52:49 +02:00
Miguel Pires
13209fc52c many: fix formatting w/ latest go version
Fix formatting when running the latest version (1.17) of gofmt.
2021-12-08 13:59:56 +00:00
Dimitri John Ledkov
b5b5fa7171 osutil: Enable riscv64 build 2020-06-02 13:12:09 +01:00
John R. Lenton
36cb991494 osutil/sys: small tweaks to let it build on darwin 2018-08-21 13:40:36 +01:00
James Henstridge
d2a7ed2507 userd: add an OpenFile method for launching local files with xdg-open (#4766)
* userd: add OpenFile D-Bus method for opening local files

* interfaces: allow OpenFile method in cases where OpenURL was allowed

* userd: make changes requested by zyga

* userd: add a parentWindow argument, as requested by mvo

* userd: stat the filename first, as requested by jdstrand

* userd: check that the sender is still connected to the bus after looking
up process information
2018-03-05 14:06:21 +01:00
John R. Lenton
1548fe80fb typo 2018-01-17 13:45:08 +00:00
John R. Lenton
b3fb0c98d5 osutil/sys: ppc has 32-bit getuid already 2018-01-17 13:37:22 +00:00
John Lenton
9de4d3bb15 osutil/sys: reimplement getuid and chown with the right int type (#4291)
* osutil/sys: reimplement getuid and chown with the right int type

Due to golang#22739, os.Getuid() and co, and os.Chown and co, use the
wrong integer type and are thus wrong for high ids (especially
noticeable on 32-bit arches). This change addresses this (the only
remaining uses are for comparing with 0, which is OK), but it still
impacts godbus in our dependencies -- anything that uses godbus on a
system with high uids is broken today.

* osutil/sys: use a custom type for uids and gids

* cmd/snap-update-ns: also switch to uint32 uids/gids

* bboozzoo finds a bug, leads me to write a test, which finds a deeper bug

* in 14.04 tests go is not on the default PATH...
2017-11-30 09:51:29 +00:00