From 67bf5bdca50850d9f379f26fd5cca55248fc8e56 Mon Sep 17 00:00:00 2001 From: Diederik de Groot Date: Mon, 16 Mar 2020 08:27:00 +0100 Subject: [PATCH] Added php-xml to README Added initial lib/xml.php Renamed srv/tftp/tftp_provisioner.php -> srv/tftp/tftp_provisioner Signed-off-by: Diederik de Groot --- README.md | 5 ++ data/settings/XMLDefault.cnf.xml | 18 +++---- etc/certs/gentlv | 7 +-- etc/certs/signfile | 3 +- lib/xml.php | 54 +++++++++++++++++++ ...{tftp_provisioner.php => tftp_provisioner} | 0 6 files changed, 74 insertions(+), 13 deletions(-) create mode 100644 lib/xml.php rename srv/tftp/{tftp_provisioner.php => tftp_provisioner} (100%) diff --git a/README.md b/README.md index 0231a2b..ec9fc01 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,11 @@ The project also serves as a repository of current / up to date cisco skinny/scc - [tftp-hpa](http://www.chschneider.eu/linux/server/tftpd-hpa.shtml) - [nginx](https://www.nginx.com/resources/wiki/) +## PHP Dependencies +- php >= 7.x +- php-cli +- php-xml + ## Usage - Clone the repository - Move the tftpboot directory (depends on your operating system): diff --git a/data/settings/XMLDefault.cnf.xml b/data/settings/XMLDefault.cnf.xml index da42da9..7616dc3 100644 --- a/data/settings/XMLDefault.cnf.xml +++ b/data/settings/XMLDefault.cnf.xml @@ -27,7 +27,7 @@ 2000 - 192.168.1.1 + 192.168.178.3 @@ -115,9 +115,9 @@ - 192.168.1.1 - 192.168.1.1 - 192.168.1.1 + 192.168.178.3 + 192.168.178.3 + 192.168.178.3 3 false false @@ -225,12 +225,12 @@ 9999 - http://192.168.1.1/idle.php - http://192.168.1.1/authenticate.php - http://192.168.1.1/cisco_menu/help/help.php + http://192.168.178.3/idle.php + http://192.168.178.3/authenticate.php + http://192.168.178.3/cisco_menu/help/help.php - http://192.168.1.1/tests.xml - http://192.168.1.1/cisco_menu/directory/menu.php + http://192.168.178.3/tests.xml + http://192.168.178.3/cisco_menu/directory/menu.php diff --git a/etc/certs/gentlv b/etc/certs/gentlv index 0b6fc82..0552d80 100755 --- a/etc/certs/gentlv +++ b/etc/certs/gentlv @@ -2,15 +2,16 @@ if [ $# == 0 ]; then # Create ITLFile.tlv in the tftpboot provisioning directory, the certificate used to sign the .tlv file is automatically included as providing the SAST function. -../../tools/certutils/tlvfile -b ../../tftpboot/settings/ITLFile.tlv -c CA.pem -r asterisk.pem -f ccm -r capf.pem -f capf -r tvs.pem -f tvs -r tftp.pem -f tftp -r webserver.pem -f https - +#../../tools/certutils/tlvfile -b ../../tftpboot/settings/ITLFile.tlv -c CA.pem -r asterisk.pem -f ccm -r capf.pem -f capf -r tvs.pem -f tvs -r tftp.pem -f tftp -r webserver.pem -f https -r vpn.pem -f https +../../tools/certutils/tlvfile -b ../../tftpboot/settings/ITLFile.tlv -c CA.pem -r asterisk.pem -f ccm -r tftp.pem -f tftp -r webserver.pem -f https -r vpn.pem -f https else # Optionally, the default ITLFile.tlv can be overridden using a file name based on the MAC address of the phone, eg: ITLSEP58971ECC97C1.tlv. #../../tools/certutils/tlvfile -b ../../tftpboot/settings/ITL${1}.tlv -c CA.pem -r vpn.pem -f https -F ITLFile.tlv +../../tools/certutils/tlvfile -b ../../tftpboot/settings/ITL${1}.tlv -c CA.pem -r asterisk.pem -f ccm -r tftp.pem -f tftp -r webserver.pem -f https -r vpn.pem -f https -F ITLFile.tlv # Optionally, additional certificates can be included using a file name based on the MAC address of the phone, eg: CTLSEP58971ECC97C1.tlv. # Example for the VPN certificate -../../tools/certutils/tlvfile -b ../../tftpboot/settings/CTL${1}.tlv -c CA.pem -r vpn.pem -f https -F CTLFile.tlv +#../../tools/certutils/tlvfile -b ../../tftpboot/settings/CTL${1}.tlv -c CA.pem -r vpn.pem -f https -F CTLFile.tlv # Enable SIP-TLS mode by setting to 3 and setting to either 2 (Authenticated) or 3 (Encrypted) in SEPMAC.cnf.xml. Optionally, any XML services can be configured to use HTTPS. fi diff --git a/etc/certs/signfile b/etc/certs/signfile index d0bcaa9..6f43383 100755 --- a/etc/certs/signfile +++ b/etc/certs/signfile @@ -2,5 +2,6 @@ if [ $# -gt 0 ]; then # Sign SEPMAC.cnf.xml -../../tools/certutils/sgnfile -b ../../tftpboot/settings/$1 -c tftp.pem +#../../tools/certutils/sgnfile -b ../../tftpboot/settings/$1 -c tftp.pem +../../tools/certutils/sgnfile -c ../../etc/certs/tftp.pem -b $* fi diff --git a/lib/xml.php b/lib/xml.php new file mode 100644 index 0000000..ee3c3ce --- /dev/null +++ b/lib/xml.php @@ -0,0 +1,54 @@ +config = $config; + $this->parser = xml_parser_create(); + //xml_error_string + } + function __destruct() { + xml_parser_free($this->parser); + } + function readStr($content) { + xml_parse_into_struct($this->parser , $content , $this->values, $this->index); + } + function readFile($filename) { + $content = file_get_contents($filename); + $this->read($content); + } + function write() { + } + function addAttr($elem, $attr) { + } + function removeAttr($elem, $attr) { + } + function updateAttr($elem, $attr) { + } + function add($parent) { + } + function remove($parent) { + } + function update($parent) { + } +} + +// Testing +if(defined('STDIN') ) { + $xml = new XML($config); + $test_cases = Array( + ); + foreach($test_cases as $test) { + try { + $xml->readStr(""); + } catch (Exception $e) { + } + } + unset($resolver); +} +?> diff --git a/srv/tftp/tftp_provisioner.php b/srv/tftp/tftp_provisioner similarity index 100% rename from srv/tftp/tftp_provisioner.php rename to srv/tftp/tftp_provisioner