go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/os/connection/owner_unix.go (about)

     1  // Copyright (c) Mondoo, Inc.
     2  // SPDX-License-Identifier: BUSL-1.1
     3  
     4  //go:build !windows
     5  // +build !windows
     6  
     7  package connection
     8  
     9  import (
    10  	"os"
    11  	"syscall"
    12  )
    13  
    14  func (c *FileSystemConnection) fileowner(stat os.FileInfo) (int64, int64) {
    15  	uid := int64(-1)
    16  	gid := int64(-1)
    17  	if stat, ok := stat.Sys().(*syscall.Stat_t); ok {
    18  		uid = int64(stat.Uid)
    19  		gid = int64(stat.Gid)
    20  	}
    21  	return uid, gid
    22  }