aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/policy.go1
-rw-r--r--crypto/crypto_test.go17
-rw-r--r--filesystem/mountpoint_test.go22
-rw-r--r--pam/pam.c3
-rw-r--r--pam/pam.go6
-rw-r--r--pam/pam.h2
6 files changed, 17 insertions, 34 deletions
diff --git a/actions/policy.go b/actions/policy.go
index 1291e6b..946bdd4 100644
--- a/actions/policy.go
+++ b/actions/policy.go
@@ -61,7 +61,6 @@ func PurgeAllPolicies(ctx *Context) error {
switch errors.Cause(err) {
case nil, crypto.ErrKeyringSearch:
// We don't care if the key has already been removed
- break
default:
return err
}
diff --git a/crypto/crypto_test.go b/crypto/crypto_test.go
index 5655fef..a154fbf 100644
--- a/crypto/crypto_test.go
+++ b/crypto/crypto_test.go
@@ -48,14 +48,15 @@ func makeKey(b byte, n int) (*Key, error) {
return NewFixedLengthKeyFromReader(ConstReader(b), n)
}
-var fakeValidDescriptor = "0123456789abcdef"
-var fakeInvalidDescriptor = "123456789abcdef"
-var fakeSalt = bytes.Repeat([]byte{'a'}, metadata.SaltLen)
-var fakePassword = []byte("password")
-
-var fakeValidPolicyKey, _ = makeKey(42, metadata.PolicyKeyLen)
-var fakeInvalidPolicyKey, _ = makeKey(42, metadata.PolicyKeyLen-1)
-var fakeWrappingKey, _ = makeKey(17, metadata.InternalKeyLen)
+var (
+ fakeValidDescriptor = "0123456789abcdef"
+ fakeSalt = bytes.Repeat([]byte{'a'}, metadata.SaltLen)
+ fakePassword = []byte("password")
+
+ fakeValidPolicyKey, _ = makeKey(42, metadata.PolicyKeyLen)
+ fakeInvalidPolicyKey, _ = makeKey(42, metadata.PolicyKeyLen-1)
+ fakeWrappingKey, _ = makeKey(17, metadata.InternalKeyLen)
+)
// As the passpharase hashing function clears the passphrase, we need to make
// a new passphrase key for each test
diff --git a/filesystem/mountpoint_test.go b/filesystem/mountpoint_test.go
index 5d53dc1..73904a2 100644
--- a/filesystem/mountpoint_test.go
+++ b/filesystem/mountpoint_test.go
@@ -20,37 +20,15 @@
package filesystem
import (
- "fmt"
"testing"
)
-func printMountInfo() {
- fmt.Println("\nBy Mountpoint:")
- for _, mnt := range mountsByPath {
- fmt.Println(mnt)
- }
-
- fmt.Println("\nBy Device:")
- for device, mnts := range mountsByDevice {
- fmt.Println("\t" + device)
- for _, mnt := range mnts {
- fmt.Println("\t\tPath: " + mnt.Path)
- }
- }
-}
-
func TestLoadMountInfo(t *testing.T) {
if err := UpdateMountInfo(); err != nil {
t.Error(err)
}
}
-func TestPrintMountInfo(t *testing.T) {
- // Uncomment to see the mount info in the tests
- // printMountInfo()
- // t.Fail()
-}
-
// Benchmarks how long it takes to update the mountpoint data
func BenchmarkLoadFirst(b *testing.B) {
for n := 0; n < b.N; n++ {
diff --git a/pam/pam.c b/pam/pam.c
index aee6671..4769705 100644
--- a/pam/pam.c
+++ b/pam/pam.c
@@ -79,7 +79,8 @@ static int conversation(int num_msg, const struct pam_message** msg,
return PAM_SUCCESS;
}
-const struct pam_conv conv = {conversation, NULL};
+static const struct pam_conv conv = {conversation, NULL};
+const struct pam_conv* goConv = &conv;
void freeData(pam_handle_t* pamh, void* data, int error_status) { free(data); }
diff --git a/pam/pam.go b/pam/pam.go
index 43bfd2e..e928883 100644
--- a/pam/pam.go
+++ b/pam/pam.go
@@ -179,7 +179,11 @@ func Start(service, username string) (*Transaction, error) {
handle: nil,
status: C.PAM_SUCCESS,
}
- t.status = C.pam_start(cService, cUsername, &C.conv, &t.handle)
+ t.status = C.pam_start(
+ cService,
+ cUsername,
+ C.goConv,
+ &t.handle)
return t, (*Handle)(t).err()
}
diff --git a/pam/pam.h b/pam/pam.h
index 9f3cdb2..09afb2e 100644
--- a/pam/pam.h
+++ b/pam/pam.h
@@ -23,7 +23,7 @@
#include <security/pam_appl.h>
// Conversation that will call back into Go code when appropriate.
-const struct pam_conv conv;
+const struct pam_conv *goConv;
// CleaupFuncs are used to cleanup specific PAM data.
typedef void (*CleanupFunc)(pam_handle_t *pamh, void *data, int error_status);