Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
iPXE/PHP
2012-09-17, 13:44 (This post was last modified: 2012-09-17 14:10 by Torgeir.)
Post: #3
RE: iPXE/PHP
Hi!

Ive tried with different configs:
Config 1:

With undionly.kpxe built from git (newest version)
Code:
if exists user-class and option user-class = "iPXE" {
                filename "http://<ip-address>/login.check.php";
        } else {
                filename "undionly.kpxe";
        }

Config 2 (which i prefer. With our current config in mind):

With ipxe linux kernel built from git (newest version)
make bin/ipxe.lkrn EMBED=dhcp.ipxe
with an ipxe script:
Code:
#!ipxe

dhcp
chain http://<ip-address>/login.check.php

DHCP option
Code:
if exists user-class and option user-class = "iPXE" {
                filename "http://<ip-address>/login.check.php";
        } else {
                filename "pxelinux.0";
        }

And with this in my pxelinux.cfg/default
Code:
label ipxe
kernel ipxe.lkrn

For various reasons, Ive tried to make undinoly.kpxe/ipxe.lkrn with and without EMBED scripts (with our current config in mind).

The example is as easy as this (this was written by hand, no copy/paste, so may contain "bugs" Smile But the logic should be clear.

PURE PHP login.php (This login does work as intended)
Code:
$user = "torgeir";
$pass = "torgeir";

if ($user === "torgeir" && $pass === "torgeir") {
          echo "Correct user/pass";
} else {
          echo "Wrong user/pass";
}

login.check.php (chain login.check2.php with arguments $_REQUEST. I know I'm not using MAC in this one, but this is the way my menu is working.

Code:
header ("Content-type: text/plain");
echo "#!ipxe\n";

# Get mac from ipxes built in variables
$MACADDRESS = "\${net0/mac}";

echo "chain ".
"http://".$_SERVER["SERVER_NAME"].
dirname($_SERVER["REQUEST_URI"] ) .
"login.check2.php?mac=${MACADDRESS}";

login.check2.php (this logic is not working)
Code:
header ("Content-type: text/plain");
echo "#!ipxe\n";

# Go back to this if wrong password
echo ":login \n";

# ipXE login menu
echo "logn \n";

# Get input from ipxe menu into php variables
# I can output these variables so I know whats in them.
# It works in the rest of my menu system.
# like: choose os && goto ${os}
# $OSTYPE = "\${os}";

$user = "\${username}";
$pass = "\${password}";

# I have tried with "\${password}" directly instead of $user/pass
if ($user === "torgeir" && $pass === "torgeir") {
          #echo "Correct user/pass";
           echo "chain http://serverip/next.step.php \n";
} else {
          #echo "Wrong user/pass";
          echo "goto login \n";
}
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
iPXE/PHP - Torgeir - 2012-09-17, 11:15
RE: iPXE/PHP - robinsmidsrod - 2012-09-17, 11:55
RE: iPXE/PHP - Torgeir - 2012-09-17 13:44
RE: iPXE/PHP - Torgeir - 2012-09-18, 07:29
RE: iPXE/PHP - Torgeir - 2012-09-18, 11:52



User(s) browsing this thread: 1 Guest(s)