Skip to content

Commit af5acc9

Browse files
committed
change sign ident
1 parent 3a4b335 commit af5acc9

File tree

3 files changed

+22
-28
lines changed

3 files changed

+22
-28
lines changed

scripts/build_go.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ arch="${GOARCH:-amd64}"
3939
slim="${CODER_SLIM_BUILD:-0}"
4040
sign_darwin="${CODER_SIGN_DARWIN:-0}"
4141
sign_windows="${CODER_SIGN_WINDOWS:-0}"
42+
bin_ident="com.coder.cli"
4243
output_path=""
4344
agpl="${CODER_BUILD_AGPL:-0}"
4445
boringcrypto=${CODER_BUILD_BORINGCRYPTO:-0}
@@ -185,6 +186,7 @@ if [[ "$dylib" == 1 ]]; then
185186
cmd_path="./vpn/dylib/lib.go"
186187
build_args+=("-buildmode=c-shared")
187188
sdk="$(xcrun --sdk macosx --show-sdk-path)"
189+
bin_ident="com.coder.desktop"
188190
fi
189191

190192
goexp=""
@@ -199,7 +201,7 @@ GOEXPERIMENT="$goexp" CGO_ENABLED="$cgo" GOOS="$os" GOARCH="$arch" GOARM="$arm_v
199201
"$cmd_path" 1>&2
200202

201203
if [[ "$sign_darwin" == 1 ]] && [[ "$os" == "darwin" ]]; then
202-
execrelative ./sign_darwin.sh "$output_path" 1>&2
204+
execrelative ./sign_darwin.sh "$output_path" "$bin_ident" 1>&2
203205
fi
204206

205207
if [[ "$sign_windows" == 1 ]] && [[ "$os" == "windows" ]]; then

scripts/sign_darwin.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# This script signs the provided darwin binary with an Apple Developer
44
# certificate.
55
#
6-
# Usage: ./sign_darwin.sh path/to/binary
6+
# Usage: ./sign_darwin.sh path/to/binary binary_identifier
77
#
88
# On success, the input file will be signed using the Apple Developer
99
# certificate.
@@ -25,15 +25,23 @@ set -euo pipefail
2525
# shellcheck source=scripts/lib.sh
2626
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
2727

28+
if [[ "$#" -lt 2 ]]; then
29+
echo "Usage: $0 path/to/binary binary_identifier"
30+
exit 1
31+
fi
32+
33+
BINARY_PATH="$1"
34+
BINARY_IDENTIFIER="$2"
35+
2836
# Check dependencies
2937
dependencies rcodesign
3038
requiredenvs AC_CERTIFICATE_FILE AC_CERTIFICATE_PASSWORD_FILE
3139

3240
# -v is quite verbose, the default output is pretty good on it's own.
3341
rcodesign sign \
34-
--binary-identifier "com.coder.cli" \
35-
--p12-file "$AC_CERTIFICATE_FILE" \
36-
--p12-password-file "$AC_CERTIFICATE_PASSWORD_FILE" \
37-
--code-signature-flags runtime \
38-
"$@" \
39-
1>&2
42+
--binary-identifier "$BINARY_IDENTIFIER" \
43+
--p12-file "$AC_CERTIFICATE_FILE" \
44+
--p12-password-file "$AC_CERTIFICATE_PASSWORD_FILE" \
45+
--code-signature-flags runtime \
46+
"$BINARY_PATH" \
47+
1>&2

vpn/dylib/lib.go

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,24 @@ import (
1515

1616
"cdr.dev/slog"
1717
"cdr.dev/slog/sloggers/sloghuman"
18+
1819
"github.com/coder/coder/v2/vpn"
1920
)
2021

2122
// OpenTunnel creates a new VPN tunnel by `dup`ing the provided 'PIPE'
2223
// file descriptors for reading, writing, and logging.
2324
//
2425
//export OpenTunnel
25-
func OpenTunnel(cReadFD, cWriteFD, cLogFD int32) int32 {
26+
func OpenTunnel(cReadFD, cWriteFD int32) int32 {
2627
ctx := context.Background()
2728

2829
conn, err := newFdConn(cReadFD, cWriteFD)
2930
if err != nil {
3031
return -1
3132
}
3233

33-
logger, err := newFdLogger(cLogFD)
34-
if err != nil {
35-
return -1
36-
}
37-
38-
_, err = vpn.NewTunnel(ctx, logger, conn)
34+
// Logs will be sent over the protocol
35+
_, err = vpn.NewTunnel(ctx, slog.Make(sloghuman.Sink(io.Discard)), conn)
3936
if err != nil {
4037
return -1
4138
}
@@ -93,17 +90,4 @@ func newFdConn(cReadFD, cWriteFD int32) (io.ReadWriteCloser, error) {
9390
}, nil
9491
}
9592

96-
func newFdLogger(cLogFD int32) (slog.Logger, error) {
97-
logFD, err := unix.Dup(int(cLogFD))
98-
if err != nil {
99-
return slog.Logger{}, xerrors.New("failed to dup logFD")
100-
}
101-
logFile := os.NewFile(uintptr(logFD), "PIPE")
102-
if logFile == nil {
103-
unix.Close(logFD)
104-
return slog.Logger{}, xerrors.New("failed to create log file")
105-
}
106-
return slog.Make(sloghuman.Sink(logFile)).Leveled(slog.LevelDebug), nil
107-
}
108-
10993
func main() {}

0 commit comments

Comments
 (0)