Skip to content

Commit

Permalink
pam/main-exec: Support running in GDM mode
Browse files Browse the repository at this point in the history
  • Loading branch information
3v1n0 committed Apr 7, 2024
1 parent 94019d7 commit 43104c2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pam/main-exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import (
"github.com/msteinert/pam/v2"
"github.com/ubuntu/authd/internal/log"
"github.com/ubuntu/authd/pam/internal/dbusmodule"
"github.com/ubuntu/authd/pam/internal/gdm"
)

var (
pamFlags = flag.Int64("flags", 0, "pam flags")
serverAddress = flag.String("server-address", "", "the dbus connection to use to communicate with module")
enableGdm = flag.Bool("enable-gdm", false, "toggle to enable GDM protocol")
)

func init() {
Expand Down Expand Up @@ -49,11 +51,22 @@ func mainFunc() error {

action, args := args[0], args[1:]

// We parse again the remaining arguments again
err = flag.CommandLine.Parse(args)
if err != nil {
return fmt.Errorf("%w: can't parse arguments: %w", pam.ErrSystem, err)
}
args = flag.CommandLine.Args()

flags := pam.Flags(0)
if pamFlags != nil {
flags = pam.Flags(*pamFlags)
}

if enableGdm != nil && *enableGdm {
gdm.AdvertisePamExtensions([]string{gdm.PamExtensionCustomJSON})
}

switch action {
case "authenticate":
return module.Authenticate(mTx, flags, args)
Expand Down

0 comments on commit 43104c2

Please sign in to comment.