From 40f96046cdfcdaeb7714fa814d7ce540c972fd51 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 17 Jun 2016 10:57:55 -0400 Subject: lise libgnulinux crypt --- src/lukeshu.com/git/go/libgnulinux.git | 2 +- src/nshd/hackers_git/check_password.go | 28 +++------------------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/src/lukeshu.com/git/go/libgnulinux.git b/src/lukeshu.com/git/go/libgnulinux.git index 58bfc62..d8c4fd9 160000 --- a/src/lukeshu.com/git/go/libgnulinux.git +++ b/src/lukeshu.com/git/go/libgnulinux.git @@ -1 +1 @@ -Subproject commit 58bfc6259f5ced680b5b200687240d2449313b2f +Subproject commit d8c4fd9aef9137b04e4311a1f50024ab88d4c6e3 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 . +// Copyright 2015-2016 Luke Shumaker . // // 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 // for free(3) -#include // for crypt_r(3) -#include // 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 } -- cgit v1.2.2