99designs / 99designs/keyring

linux_syscall.c:67:13: error: implicit declaration of function 'setresgid' is invalid in C99

Open
#88 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
657
Forks
155
PR merge metrics
No merged PRs in 30d

Description

I'm building in a docker ubuntu 20.04 Linux container.

Below is a snippet of the code I'm using, the the relevant part of the Docker build file that I'm using to run my server in.
My server compiles code on demand for different environments. The code shown is part of that file that is being compiled when the error is thrown.

I have it working

- Linux->Windows
- Windows->Linux
- Windows-> Darwin
- Darwin->Windows
- Darwin->Linux

The last thing I need is to be ale to compile on Linux for Darwin. Since I'm running in Docker it is a must have, the other combinations make development easy.

I can build other go files that doesn't use this library.

The code is fairly straight forward. Here is the portion that uses this library
```
import (
set_var "components/payload/macos/commands/set-var"
"components/payload/types"
types3 "components/protocol/types"
"github.com/99designs/keyring"
"os/user"
"strconv"
)
```
[some code redacted]
```
kr, e1 := keyring.Open(keyring.Config{})
if e1 != nil {
response.Value = []byte("Failed to get a keyring object. This one is not on me.")
return
}

keys, e1 := kr.Keys()
if err != nil {
response.Value = []byte("Failed getting a list of keys from keyring\n")
return
}
var item keyring.Item
occurred := 0
for _, k := range keys{
if k == name {
item, err = kr.Get(k)
if err == nil {
if(skip == occurred) {
response.Value = []byte( item.Data)
}else{
occurred++
}
return
}else{
response.Value = []byte("I was not able to retrieve any values, I think they might have not allowed the activity.")
return
}
}
}
```
I have built the container with

```
FROM ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get install -yq wget git build-essential mysql-client

#required for windows xcompile
RUN apt-get install -yq mingw-w64 libc6-dev-i386

#required for darwin xcompile
RUN apt-get install -yq libpython2.7 libpython2.7-dev
RUN apt-get install -yq llvm libicu-dev clang

RUN wget -c https://dl.google.com/go/go1.16.5.linux-amd64.tar.gz -O - | tar -xz -C /usr/local

ENV PATH /usr/local/go/bin:$PATH
ENV GOROOT /usr/local/go
ENV GOPATH /var/go

# Now ot create the actual osx xcompiler
RUN apt-get install -yq gcc g++ zlib1g-dev libmpc-dev libmpfr-dev libgmp-dev
RUN apt-get install -yq cmake patch python libssl-dev lzma-dev libxml2-dev
RUN git clone https://github.com/tpoechtrager/osxcross.git

#Note you can get update tarbars at https://developer.apple.com/download/all/?q=xcode
# the instructions for creating the tarball are in the osxcross repo
# we are storing the current on in gitlab xcode 12.5.1

COPY ./deploy/osxcross/MacOSX11.3.sdk.tar.bz2 /osxcross/tarballs/MacOSX11.3.sdk.tar.bz2
#COPY ./deploy/osxcross/MacOSX11.sdk.tar.bz2 /osxcross/tarballs/MacOSX11.sdk.tar.bz2
#COPY ./deploy/osxcross/MacOSX10.15.sdk.tar.bz2 /osxcross/tarballs/MacOSX10.15.sdk.tar.bz2

ENV CXX clang++
ENV CC clang

RUN cd /osxcross
RUN UNATTENDED=1 SDK_VERSION=11.3 /osxcross/build.sh
ENV PATH /osxcross/target/bin:$PATH

# I don't think I need this. but I'll leave it here for now.
#RUN /osxcross/build_gcc.sh

#reset the build in environment
RUN cd ..
ENV CXX g++
ENV CC gcc

I add a bunch of modules after this.

```

Since the server is building this code, I log much of the environment settings in place in order to debug issues like this:

```

================================================================
= Build File
= OS = darwin
= ARCH = amd64
================================================================
Old PATH = /osxcross/target/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
New PATH = /osxcross/target/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/go/bin
*****************************
**** Environment : darwin - amd64
*****************************
*****************************
CGO_ENABLED=1
GO111MODULE=off
CXX=o64-clang++
GOOS=darwin
HOME=/root
GOARCH=amd64
PWD=/usr/lib/test
GOROOT=/usr/local/go
PATH=/osxcross/target/bin:/usr/local/go/bin:/usr/share/swift/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/go/bin
OLDPWD=/
GOPATH=/var/go
CC=o64-clang
CGO_CFLAGS=-I/usr/share/swift/usr/lib/swift
OSXCROSS_NO_INCLUDE_PATH_WARNINGS=1
MACOSX_DEPLOYMENT_TARGET=11.3
*****************************

Command : [go build -ldflags -extldflags "-static" -s -w -trimpath -gcflags -trimpath=/usr/lib/test/server -asmflags -trimpath=/usr/lib/test/server -o /usr/lib/test/server/L01F/darwin/amd64/test /usr/lib/test/server/L01F/test.go]

[0] go
[1] build
[2] -ldflags
[3] -extldflags "-static" -s -w
[4] -trimpath
[5] -gcflags
[6] -trimpath=/usr/lib/test/server
[7] -asmflags
[8] -trimpath=/usr/lib/test/server
[9] -o
[10] /usr/lib/test/server/L01F/darwin/amd64/test
[11] /usr/lib/test/server/L01F/test.go
------- err | # github.com/99designs/keyring
------- err | /var/go/src/github.com/99designs/keyring/keychain.go:136:8: kcItem.SetAccess undefined (type keychain.Item has no field or method SetAccess)
------- err | /var/go/src/github.com/99designs/keyring/keychain.go:181:9: kcItem.SetAccess undefined (type keychain.Item has no field or method SetAccess)
------- err | /var/go/src/github.com/99designs/keyring/keychain.go:181:21: undefined: keychain.Access
------- err | /var/go/src/github.com/99designs/keyring/keychain.go:187:9: kcItem.SetAccess undefined (type keychain.Item has no field or method SetAccess)
------- err | /var/go/src/github.com/99designs/keyring/keychain.go:187:21: undefined: keychain.Access
Error darwin - amd64 : exit status 2

```

FIX FOR THIS ERROR
EDIT : Note to fix the above error I had found a thread that suggested adding the following line to the go.mod.
```
replace github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4
```
so the output of that is noted below.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.