-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
maint: Cleanup code and binaries generation and fix pam module loader (…
…#142) Cleanup the way we generate the targets moving some stuff to scripts so that they are more maintainable and and reusable (I'd need the proto generation for #121 for example). Plus address an issue we have with current module path loader when using relative paths.
- Loading branch information
Showing
7 changed files
with
111 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
//go:build generate | ||
|
||
//go:generate tools/generate-proto.sh --with-grpc authd.proto | ||
|
||
// Package authd contains the autogenerated GRPC API between the modules and daemon. | ||
package authd | ||
|
||
//TODO: Watch https://github.com/protocolbuffers/protobuf for any changes on the experimental status of optional fields, | ||
// previously described on: https://github.com/protocolbuffers/protobuf/blob/main/docs/implementing_proto3_presence.md. | ||
// | ||
// Should it become default, remove the --experimental_allow_proto3_optional flag from the go generate command below. | ||
//go:generate sh -c "PATH=\"$PATH:`go env GOPATH`/bin\" protoc --proto_path=. --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative authd.proto --experimental_allow_proto3_optional" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//go:build generate | ||
|
||
//go:generate ./generate.sh -tags !pam_binary_cli | ||
|
||
package main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
PROJECT_ROOT=$PWD/.. | ||
module_libname=pam_authd.so | ||
loader_libname=pam_go_loader.so | ||
|
||
if [ -d "$PROJECT_ROOT"/vendor ]; then | ||
echo Vendored dependencies detected, not re-generating pam_module.go | ||
else | ||
go run github.com/msteinert/pam/v2/cmd/pam-moduler \ | ||
-libname "$module_libname" -type pamModule \ | ||
"${@}" | ||
fi | ||
|
||
cc_args=() | ||
if [ -v AUTHD_PAM_MODULES_PATH ]; then | ||
cc_args+=(-DAUTHD_PAM_MODULES_PATH=\""${AUTHD_PAM_MODULES_PATH}"\") | ||
fi | ||
|
||
${CC:-cc} -o go-loader/"$loader_libname" \ | ||
go-loader/module.c ${CFLAGS:-} -Wl,--as-needed -Wl,--allow-shlib-undefined \ | ||
-shared -fPIC -Wl,--unresolved-symbols=report-all \ | ||
-Wl,-soname,"$loader_libname" -lpam ${LDFLAGS:-} "${cc_args[@]}" | ||
|
||
chmod 644 go-loader/"$loader_libname" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# TODO: Watch https://github.com/protocolbuffers/protobuf for any changes on the | ||
# experimental status of optional fields, previously described on: | ||
# https://github.com/protocolbuffers/protobuf/blob/main/docs/implementing_proto3_presence.md. | ||
args=( | ||
--proto_path=. | ||
--go_out=. | ||
--go_opt=paths=source_relative | ||
|
||
# Should it become default, remove the --experimental_allow_proto3_optional | ||
# flag from the go generate command below. | ||
--experimental_allow_proto3_optional | ||
) | ||
|
||
while [ "$#" -gt 0 ]; do | ||
case "$1" in | ||
--with-grpc) | ||
args+=( | ||
--go-grpc_out=. | ||
--go-grpc_opt=paths=source_relative | ||
) | ||
shift | ||
;; | ||
--) | ||
shift | ||
break | ||
;; | ||
-*) | ||
args+=("$1") | ||
shift | ||
;; | ||
*) | ||
proto_file="$1" | ||
shift | ||
;; | ||
esac | ||
done | ||
|
||
if [ ! -e "$proto_file" ]; then | ||
echo "No proto or invalid file provided: $proto_file" | ||
exit 1 | ||
fi | ||
|
||
PATH="$(go env GOPATH)/bin:$PATH" | ||
export PATH | ||
|
||
exec protoc "${args[@]}" "$proto_file" "${@}" |