Netgate SG-1000 microFirewall

Author Topic: Custom PHP build configuration? [ANSWERED]  (Read 1019 times)

0 Members and 1 Guest are viewing this topic.

Offline 10101000

  • Newbie
  • *
  • Posts: 13
  • Karma: +1/-0
    • View Profile
Custom PHP build configuration? [ANSWERED]
« on: July 18, 2015, 11:15:47 pm »
Hi,

Can someone point me toward the PHP build configuration that ships with 2.2.3-RELEASE? I've searched GitHub but am I missing it? I'd like to build it myself and maybe update it.

I realize that installing upstream FreeBSD packages is unsupported but I find joy in breaking and fixing my personal instance. The PHP version 5.5.26 that ships with 2.2.3-RELEASE has cgi-fcgi built in:

Code: [Select]
[2.2.3-RELEASE][root@pfsense1]/root: php -v
PHP 5.5.26 (cgi-fcgi) (built: Jun 12 2015 14:20:29)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
    with Suhosin v0.9.37.1, Copyright (c) 2007-2014, by SektionEins GmbH

The upstream FreeBSD build separates the php and php-cgi binaries and doesn't have cgi-fcgi built-in. Php-fpm also behaves differently: the Unix socket writes out the script and Content-Type headers:

PHP pfSense build 5.5.26 (WORKING):
Code: [Select]
[2.2.3-RELEASE][root@pfsense1]/root: /usr/local/sbin/fcgicli -f /etc/inc/openvpn.tls-verify.php -d "test.test&depth=2&certdepth=1&certsubject=C=US,"; echo; echo $?
OK
0

PHP FreeBSD build 5.5.27 (BROKEN):
Code: [Select]
[2.2.3-RELEASE][root@pfsense2]/root: /usr/local/sbin/fcgicli -f /etc/inc/openvpn.tls-verify.php -d "test.test&depth=2&certdepth=1&certsubject=C=US,"; echo; echo $?
Content-type: text/html

#!/usr/local/bin/php -f
OK
0

For me this breaks /usr/local/sbin/ovpn_auth_verify producing "WARNING: Failed running command (--tls-verify script): external program exited with error status: 1" and "VERIFY SCRIPT ERROR" messages since we only match on exactly "OK". So far this hasn't broken anything else that I'm aware of. Here is my patch if you want to continue using 5.5.27 with OpenVPN:

Note: this may not be a good idea for high traffic OpenVPN servers as we add an extra system call to grep:
Quote
--- /usr/local/sbin/ovpn_auth_verify.orig       2015-07-18 19:04:15.000000000 -0600
+++ /usr/local/sbin/ovpn_auth_verify    2015-07-18 19:04:50.000000000 -0600
@@ -9,7 +9,7 @@
        RESULT=$(/usr/local/sbin/fcgicli -f /etc/inc/openvpn.auth-user.php -d "username=$username&password=$password&cn=$common_name&strictcn=$3&authcfg=$2&modeid=$4")
 fi

-if [ "${RESULT}" = "OK" ]; then
+if echo "${RESULT}" | /usr/bin/grep -E "^OK$" &> /dev/null; then
        exit 0
 fi


EDIT: Here is a faster & much more elegant solution:
Code: [Select]
--- /usr/local/sbin/ovpn_auth_verify.orig       2015-07-18 20:11:02.000000000 -0600
+++ /usr/local/sbin/ovpn_auth_verify    2015-07-19 11:18:16.000000000 -0600
@@ -9,8 +9,11 @@
        RESULT=$(/usr/local/sbin/fcgicli -f /etc/inc/openvpn.auth-user.php -d "username=$username&password=$password&cn=$common_name&strictcn=$3&authcfg=$2&modeid=$4")
 fi

-if [ "${RESULT}" = "OK" ]; then
-       exit 0
-fi
-
-exit 1
+case "$RESULT" in
+   *"OK"*)
+      exit 0
+      ;;
+   *)
+      exit 1
+      ;;
+esac

Thanks!
« Last Edit: July 21, 2015, 12:10:52 pm by 10101000 »

Offline 10101000

  • Newbie
  • *
  • Posts: 13
  • Karma: +1/-0
    • View Profile
Re: Custom PHP build configuration?
« Reply #1 on: July 21, 2015, 11:15:35 am »
Anyone? This is supposed to be open source right? Do I need to be granted GitHub access? What am I missing?  ???

Offline KOM

  • Hero Member
  • *****
  • Posts: 5831
  • Karma: +710/-23
    • View Profile
Re: Custom PHP build configuration?
« Reply #2 on: July 21, 2015, 12:04:28 pm »
Quote
What am I missing?

The fact that the vast majority of people here are users and not developers?  Maybe if you posted in the Development forum, that might get some eyeballs.

Offline 10101000

  • Newbie
  • *
  • Posts: 13
  • Karma: +1/-0
    • View Profile
Re: Custom PHP build configuration?
« Reply #3 on: July 21, 2015, 12:08:34 pm »
This is an excellent point. I'd overlooked the Development section. Thanks for your reply!

Offline johnpoz

  • Hero Member
  • *****
  • Posts: 15753
  • Karma: +1472/-210
  • Not a pfSense employee, they cannot fire me...
    • View Profile
Re: Custom PHP build configuration? [ANSWERED]
« Reply #4 on: August 09, 2015, 07:26:38 am »
What are you saying is broken?

[2.2.4-RELEASE][root@pfSense.local.lan]/root: php -v
PHP 5.5.27 (cgi-fcgi) (built: Jul 13 2015 19:15:15)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
    with Suhosin v0.9.37.1, Copyright (c) 2007-2014, by SektionEins GmbH


[2.2.4-RELEASE][root@pfSense.local.lan]/root: /usr/local/sbin/fcgicli -f /etc/inc/openvpn.tls-verify.php -d "test.test&depth=2&certdepth=1&certsubject=C=US,"; echo; echo $?
OK
0
[2.2.4-RELEASE][root@pfSense.local.lan]/root:
- An intelligent man is sometimes forced to be drunk to spend time with his fools.
- Please don't PM me for personal help
- if you want to say thanks applaud or https://www.freebsdfoundation.org/donate/
1x SG-2440 2.4.3-RELEASE (work)
1x SG-3100 2.4.3-RELEASE (work)
1x SG-4860 2.4.3-RELEASE (home)