login-validator: Append shadow to original challenge archive
This commit is contained in:
parent
f317d11fac
commit
59abc217d1
4 changed files with 24 additions and 5 deletions
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
"crypto/md5"
|
||||
"crypto/sha512"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
|
@ -27,6 +28,12 @@ func RegisterUserIP(ip net.IP, username string) error {
|
|||
return registerUser(pxeUserTplPath, fmt.Sprintf("%02X%02X%02X%02X", ip.To4()[0], ip.To4()[1], ip.To4()[2], ip.To4()[3]), username, ip)
|
||||
}
|
||||
|
||||
func initrd_name(remote string) string {
|
||||
initrd := hmac.New(md5.New, []byte(loginSalt))
|
||||
initrd.Write([]byte(remote))
|
||||
return fmt.Sprintf("%x", initrd.Sum(nil))
|
||||
}
|
||||
|
||||
func registerUser(tplPath string, filename string, username string, ip net.IP) error {
|
||||
if pxeTplCnt, err := ioutil.ReadFile(path.Join(tftpDir, tplPath)); err != nil {
|
||||
return err
|
||||
|
|
@ -46,6 +53,7 @@ func registerUser(tplPath string, filename string, username string, ip net.IP) e
|
|||
return err
|
||||
} else if err := pxeTmpl.Execute(userfd, map[string]string{
|
||||
"username": username,
|
||||
"initrd": initrd_name(ip.String()),
|
||||
"pkey": fmt.Sprintf("%x", pkey.Sum(nil)),
|
||||
"ip": ip.String(),
|
||||
}); err != nil {
|
||||
|
|
|
|||
Reference in a new issue