carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package host
2
3import (
4 "os"
5 "os/user"
6 "strconv"
7
8 "github.com/carlosframework/platform/internal/registry"
9)
10
11func openServiceRegistryReadOnly(path string) (*registry.Registry, error) {
12 if os.Geteuid() != 0 {
13 return registry.OpenReadOnly(path)
14 }
15 service, err := user.Lookup(serviceUser)
16 if err != nil {
17 return nil, err
18 }
19 uid, err := strconv.Atoi(service.Uid)
20 if err != nil {
21 return nil, err
22 }
23 gid, err := strconv.Atoi(service.Gid)
24 if err != nil {
25 return nil, err
26 }
27 return openRegistryChildReadOnly(path, uid, gid)
28}
29