Skip to content

Commit

Permalink
fixup! PAM: Build GDM support only on the library
Browse files Browse the repository at this point in the history
  • Loading branch information
3v1n0 committed Oct 7, 2024
1 parent f548d5f commit d219a3e
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 10 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Then build the PAM module:

```shell
go generate ./pam/
go build -tags pam_binary_exec -o ./pam/authd-pam ./pam
go build -o ./pam/authd-pam ./pam
```

This last command will produce two libraries (`./pam/pam_authd.so` and `./pam/go-exec/pam_authd_exec.so`) and an executable (`./pam/authd-pam`).
Expand All @@ -170,7 +170,7 @@ The library resulting from the build is located in `./target/debug/libnss_authd.

The project includes a comprehensive test suite made of unit and integration tests. All the tests must pass before the review is considered. If you have troubles with the test suite, feel free to mention it in your PR description.

You can run all tests with: `go test ./...` (add the `-race` flag for race detection).
You can run all tests with: `go test -tags withgdmmodel ./...` (add the `-race` flag for race detection).

Every package has a suite of at least package-level tests. They may integrate more granular unit tests for complex functionalities. Integration tests are located in `./pam/integration-tests` for the PAM module and `./nss/integration-tests` for the NSS module.

Expand Down
3 changes: 3 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ override_dh_auto_build:
# Build the daemon
dh_auto_build -- $(AUTHD_GO_PACKAGE)/cmd/authd

override_dh_auto_test:
dh_auto_test -- -tags withgdmmodel

override_dh_auto_install:
dh_auto_install --destdir=debian/tmp -- --no-source

Expand Down
2 changes: 1 addition & 1 deletion pam/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

//go:generate go generate -C internal/proto

//go:generate ./generate.sh -tags !pam_debug -build-tags withgdmmodel
//go:generate ./generate.sh -tags "!pam_debug && withgdmmodel" -build-tags withgdmmodel

package main
2 changes: 1 addition & 1 deletion pam/generate_debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

//go:generate go generate -C internal/proto

//go:generate env CFLAGS=-g3 CGO_CFLAGS=-g3 ./generate.sh -tags pam_debug -build-tags "pam_gdm_debug,withgdmmodel" -build-flags "\"-gcflags=all=-N -l\"" -output pam_module_debug.go
//go:generate env CFLAGS=-g3 CGO_CFLAGS=-g3 ./generate.sh -tags "pam_debug && withgdmmodel" -build-tags "pam_gdm_debug,withgdmmodel" -build-flags "\"-gcflags=all=-N -l\"" -output pam_module_debug.go

package main
2 changes: 2 additions & 0 deletions pam/integration-tests/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"github.com/ubuntu/authd/pam/internal/pam_test"
)

const authdCurrentUserRootEnvVariableContent = "AUTHD_INTEGRATIONTESTS_CURRENT_USER_AS_ROOT=1"

func runAuthd(t *testing.T, gpasswdOutput, groupsFile string, currentUserAsRoot bool) string {
t.Helper()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build withgdmmodel

package main_test

import (
Expand All @@ -8,8 +10,6 @@ import (
"github.com/ubuntu/authd/internal/testutils"
)

const authdCurrentUserRootEnvVariableContent = "AUTHD_INTEGRATIONTESTS_CURRENT_USER_AS_ROOT=1"

func TestMain(m *testing.M) {
// Needed to skip the test setup when running the gpasswd mock.
if os.Getenv("GO_WANT_HELPER_PROCESS") != "" {
Expand Down
12 changes: 12 additions & 0 deletions pam/integration-tests/main-invalid_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build !withgdmmodel

package main_test

import (
"log"
"testing"
)

func TestMain(m *testing.M) {
log.Fatal("Setup: Tests must be compiled with `withgdmmodel` tag")
}
4 changes: 2 additions & 2 deletions pam/pam_module.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pam/pam_module_debug.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d219a3e

Please sign in to comment.