-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pam: Use pam.ModuleTransaction to implement pam module (#89)
Re-implement the PAM module bootstrap code by using pam-go and in particular the code proposed at msteinert/pam#13 That allows us to have a more tested and testable base. Also it will be a prerequisite for the gdm implementation and a pure-PAM protocol implementation. The module can now generated by just using `go generate -C pam` that would generate in two steps both the go-glue code and the library itself. See single commits for further details. UDENG-1647, UDENG-1604
- Loading branch information
Showing
19 changed files
with
1,650 additions
and
257 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
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,2 @@ | ||
./*.h | ||
*.so |
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
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,45 @@ | ||
//go:build pam_binary_cli | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/msteinert/pam" | ||
"github.com/sirupsen/logrus" | ||
"github.com/ubuntu/authd/internal/log" | ||
"github.com/ubuntu/authd/pam/pam_test" | ||
) | ||
|
||
// Simulating pam on the CLI for manual testing. | ||
func main() { | ||
log.SetLevel(log.DebugLevel) | ||
f, err := os.OpenFile("/tmp/logdebug", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0600) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer f.Close() | ||
logrus.SetOutput(f) | ||
|
||
module := &pamModule{} | ||
mTx := pam_test.NewModuleTransactionDummy(pam.ConversationFunc( | ||
func(style pam.Style, msg string) (string, error) { | ||
switch style { | ||
case pam.TextInfo: | ||
fmt.Fprintf(os.Stderr, "PAM INFO: %s\n", msg) | ||
case pam.ErrorMsg: | ||
fmt.Fprintf(os.Stderr, "PAM ERROR: %s\n", msg) | ||
default: | ||
return "", fmt.Errorf("pam style %d not implemented", style) | ||
} | ||
return "", nil | ||
})) | ||
|
||
authResult := module.Authenticate(mTx, pam.Flags(0), nil) | ||
fmt.Println("Auth return:", authResult) | ||
|
||
// Simulate setting auth broker as default. | ||
accMgmtResult := module.AcctMgmt(mTx, pam.Flags(0), nil) | ||
fmt.Println("Acct mgmt return:", accMgmtResult) | ||
} |
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
Oops, something went wrong.