summaryrefslogtreecommitdiff
path: root/src/nshd
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-06-17 10:57:55 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-06-17 10:57:55 -0400
commit40f96046cdfcdaeb7714fa814d7ce540c972fd51 (patch)
tree4bd68284c4b3b697ef7a78045ae5f27c9b20701a /src/nshd
parent2b96926eef130a4a1fecd6fe476f22e25716bf6e (diff)
lise libgnulinux crypt
Diffstat (limited to 'src/nshd')
-rw-r--r--src/nshd/hackers_git/check_password.go28
1 files changed, 3 insertions, 25 deletions
diff --git a/src/nshd/hackers_git/check_password.go b/src/nshd/hackers_git/check_password.go
index 81ad932..cde70d3 100644
--- a/src/nshd/hackers_git/check_password.go
+++ b/src/nshd/hackers_git/check_password.go
@@ -1,4 +1,4 @@
-// Copyright 2015 Luke Shumaker <lukeshu@sbcglobal.net>.
+// Copyright 2015-2016 Luke Shumaker <lukeshu@sbcglobal.net>.
//
// This is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -21,30 +21,8 @@
package hackers_git
-import "unsafe"
-
-/*
-#cgo LDFLAGS: -lcrypt
-#define _GNU_SOURCE // for crypt_r(3) in crypt.h
-#include <stdlib.h> // for free(3)
-#include <crypt.h> // for crypt_r(3)
-#include <string.h> // for strcmp(3) and memset(3)
-int check_password(const char *password, const char *hash)
-{
- int ret;
- struct crypt_data data;
- data.initialized = 0;
- ret = (strcmp(crypt_r(password, hash, &data), hash) == 0);
- memset(&data, 0, sizeof(data));
- return ret;
-}
-*/
-import "C"
+import "lukeshu.com/git/go/libgnulinux.git/crypt"
func check_password(password string, hash string) bool {
- cpassword := C.CString(password)
- defer C.free(unsafe.Pointer(cpassword))
- chash := C.CString(hash)
- defer C.free(unsafe.Pointer(chash))
- return C.check_password(cpassword, chash) != 0
+ return crypt.Crypt(password, hash) == hash
}