Re: Systemd support in 2.4

2014-12-05 Thread Jan Kaluža

On 12/02/2014 02:08 PM, Jeff Trawick wrote:

On Wed, Sep 17, 2014 at 9:22 AM, Jeff Trawick traw...@gmail.com
mailto:traw...@gmail.com wrote:

On Mon, Sep 15, 2014 at 2:00 AM, Jan Kaluža jkal...@redhat.com
mailto:jkal...@redhat.com wrote:

On 09/14/2014 01:21 PM, Martynas Bendorius wrote:

Hello,

Is there any special reason why mod_systemd and mod_journald
(available
in trunk) are not backported to 2.4 yet?


Hi,

I think mod_systemd could be proposed for 2.4 branch (maybe even
with the changes adding socket activation), but for
mod_journald, we would have to backport modular logging, which
breaks the API/ABI and therefore I'm afraid that won't happen in
2.4 branch :(.


I have an old patch somewhere that doesn't break the API/ABI, and
accommodates such differences as syslog being built-in in 2.4.x.  I
didn't realize that anybody besides me actually cared.

I'll try to find time to see how it fits in 2.4.x-HEAD.


I've simply attached it from its state one year ago, not having time to
play with it.  I don't think it is necessary to break the ABI.  syslog
support remains part of core logging instead of in a module.


I've created my version of the patch based on yours. It includes also 
more recent commits from trunk related to errorlog providers. Can you 
try it? I presume you have done that backport, because you are running 
that somewhere :).


Regards,
Jan Kaluza


Jan Kaluza


As we have a lot of distributions already using systemd by
default
(CentOS/RHEL 7, Fedora, Arch Linux, CoreOS, openSUSE), and
more of them
are going to use systemd by default (Debian 8 (Jessie),
Ubuntu), it
requires manual patching of apache for the support of
systemd/journald.

Thank you!





--
Born in Roswell... married an alien...
http://emptyhammock.com/



Index: docs/manual/mod/core.xml
===
--- docs/manual/mod/core.xml	(revision 1643223)
+++ docs/manual/mod/core.xml	(working copy)
@@ -1315,6 +1315,9 @@
 
 highlight language=configErrorLog syslog:user/highlight
 
+pAdditional modules can provide their own ErrorLog providers. The syntax
+is similar to codesyslog/code example above./p
+
 pSECURITY: See the a
 href=../misc/security_tips.html#serverrootsecurity tips/a
 document for details on why your security could be compromised
Index: include/http_core.h
===
--- include/http_core.h	(revision 1643223)
+++ include/http_core.h	(working copy)
@@ -835,8 +835,44 @@
 
 /** message format */
 const char *format;
+/** 1 if logging using provider, 0 otherwise */
+int using_provider;
 } ap_errorlog_info;
 
+#define AP_ERRORLOG_PROVIDER_GROUP error_log_writer
+#define AP_ERRORLOG_PROVIDER_VERSION 0
+#define AP_ERRORLOG_DEFAULT_PROVIDER file
+
+/** add APR_EOL_STR to the end of log message */
+#define AP_ERRORLOG_PROVIDER_ADD_EOL_STR   1
+
+typedef struct ap_errorlog_provider ap_errorlog_provider;
+
+struct ap_errorlog_provider {
+/** Initializes the error log writer.
+ * @param p The pool to create any storage from
+ * @param s Server for which the logger is initialized
+ * @return Pointer to handle passed later to writer() function
+ * @note On success, the provider must return non-NULL, even if
+ * the handle is not necessary when the writer() function is
+ * called.  On failure, the provider should log a startup error
+ * message and return NULL to abort httpd startup.
+ */
+void * (*init)(apr_pool_t *p, server_rec *s);
+
+/** Logs the error message to external error log.
+ * @param info Context of the error message
+ * @param handle Handle created by init() function
+ * @param errstr Error message
+ * @param len Length of the error message
+ */
+apr_status_t (*writer)(const ap_errorlog_info *info, void *handle,
+   const char *errstr, apr_size_t len);
+
+/** a combination of the AP_ERRORLOG_PROVIDER_* flags */
+unsigned int flags;
+};
+
 /**
  * callback function prototype for a external errorlog handler
  * @note To avoid unbounded memory usage, these functions must not allocate
Index: include/httpd.h
===
--- include/httpd.h	(revision 1643223)
+++ include/httpd.h	(working copy)
@@ -1248,6 +1248,10 @@
 apr_file_t *error_log;
 /** The log level configuration */
 struct ap_logconf log;
+/** External error log writer provider */
+struct ap_errorlog_provider *errorlog_provider;
+/** Handle to be passed to external log provider's logging method */
+void *errorlog_provider_handle;
 
 /* Module-specific configuration for server, and 

Re: svn commit: r1643179 - in /httpd/httpd/trunk/server/mpm: prefork/prefork.c worker/worker.c

2014-12-05 Thread Yann Ylavic
On Fri, Dec 5, 2014 at 8:57 AM,  yla...@apache.org wrote:
 Author: ylavic
 Date: Fri Dec  5 07:57:57 2014
 New Revision: 1643179

 URL: http://svn.apache.org/viewvc?rev=1643179view=rev

The URL used here seems to have changed since recent upgrade (was
httpd://svn.a.o/r[rev] before).
The previous one looked more generic IMHO, less dependant on the SVN
viewer (would not break if the viewer changes some day).


Re: svn commit: r1643179 - in /httpd/httpd/trunk/server/mpm: prefork/prefork.c worker/worker.c

2014-12-05 Thread Daniel Gruno

I'm working on that right now, Yann :)

With regards,
Daniel.
On 2014-12-05 13:40, Yann Ylavic wrote:

On Fri, Dec 5, 2014 at 8:57 AM,  yla...@apache.org wrote:

Author: ylavic
Date: Fri Dec  5 07:57:57 2014
New Revision: 1643179

URL: http://svn.apache.org/viewvc?rev=1643179view=rev

The URL used here seems to have changed since recent upgrade (was
httpd://svn.a.o/r[rev] before).
The previous one looked more generic IMHO, less dependant on the SVN
viewer (would not break if the viewer changes some day).




Re: svn commit: r1643179 - in /httpd/httpd/trunk/server/mpm: prefork/prefork.c worker/worker.c

2014-12-05 Thread Yann Ylavic
OK, thanks Daniel.

On Fri, Dec 5, 2014 at 1:41 PM, Daniel Gruno humbed...@apache.org wrote:
 I'm working on that right now, Yann :)

 With regards,
 Daniel.

 On 2014-12-05 13:40, Yann Ylavic wrote:

 On Fri, Dec 5, 2014 at 8:57 AM,  yla...@apache.org wrote:

 Author: ylavic
 Date: Fri Dec  5 07:57:57 2014
 New Revision: 1643179

 URL: http://svn.apache.org/viewvc?rev=1643179view=rev

 The URL used here seems to have changed since recent upgrade (was
 httpd://svn.a.o/r[rev] before).
 The previous one looked more generic IMHO, less dependant on the SVN
 viewer (would not break if the viewer changes some day).




Re: mod_proxy_fcgi issues

2014-12-05 Thread Jeff Trawick
On Thu, Dec 4, 2014 at 11:50 AM, Jeff Trawick traw...@gmail.com wrote:

 On Thu, Dec 4, 2014 at 10:38 AM, Eric Covener cove...@gmail.com wrote:

 forked from apachecon thread

 On Thu, Dec 4, 2014 at 10:23 AM, Jeff Trawick traw...@gmail.com wrote:
  On Thu, Dec 4, 2014 at 9:58 AM, Eric Covener cove...@gmail.com wrote:
 
  On Tue, Dec 2, 2014 at 4:14 PM, Jim Riggs apache-li...@riggs.me
 wrote:
   P.S. mod_proxy_balancer - mod_proxy_fcgi - php-fpm is really fun
 and
   interesting too! ;-)
 
  mod_proxy_fcgi seems to need a bit of work from what I have been
  seeing in bugzilla and IRC.  I hope to spend a little time on the code
  and doc, but not being an actual user of it I don't know how far I
  will really get before being distracted.
 
 
  This is very important stuff IMO.
 
  I know we don't do the coordination thing around here, but if the work
 was
  organized to some extent, perhaps 3-4 people could easily share the
 work???
  (bite sized chunks of the development:  simple reproducers, doc, code,
  review, whatever)
 
  Besides searching through Bugzilla and summarizing each mod_proxy_fcgi
 bug
  and ranking by apparent severity, number of users involved in the bug
  discussion, etc., what else should I put on a Wiki page?  E.g., do you
 have
  an idea of what needs to be improved in the doc?

 I don't have much more than what amounts to the summary/initial poking
 around in the bugzillas.  I had the wiki thought too -- bullets there
 are much easie than trying to reabsorb the PRs each time.

 - examples need to account for php-fpm (how URLs and or paths are passed)
 - fixes for CGI variables in different configurations (sethandler vs.
 proxypass)
 -- fixup r-filename right before adding CGI vars, maybe directory walk
 -- path info calculation probably needs multiple modes.  Maybe expr based?


 FWIW, every time I see the PATH_INFO questions I recall the nginx
 configuration (the script vars provided are those defined in the
 configuration, with some expression support); we need general CGISetVar
 var expr that sets or overrides script variables in common code (like
 CGIPassAuth) so that it works with the many modules that interface with
 scripts.



 - further doc for worker matching stuff with ProxySet
 - provide a convenience/less verbose directive to configure SetHandler
 +  a backend worker
 -- doc SetHandler advantages
 - change compile-time diag stuff to trace8
 - need to port mod_proxy_http or mod_fcgid body spooling / content
 length passing
 - would be nice to have a non php-fpm fastcgi server to sanity check
 with so we don't end up with too many php-fpm-isms
 - figure out / make sure balancer examples work with php-fpm and/or
 setHandler


 And although mod_proxy_fcgi is  the usual suspect, some of these are
 important issues with mod_proxy_scgi too.  (It is faster, and for some
 deployments there's no natural preference for FastCGI over SCGI.)

 Thanks for all the notes; I'll write this stuff up today.


Initial version at  https://wiki.apache.org/httpd/Development/mod_proxy_fcgi

I haven't integrated your list into the table yet
-- 
Born in Roswell... married an alien...
http://emptyhammock.com/


Re: svn commit: r1642154 - in /httpd/httpd/trunk: docs/manual/expr.xml include/ap_expr.h server/util_expr_eval.c server/util_expr_parse.y

2014-12-05 Thread Eric Covener
On Thu, Nov 27, 2014 at 8:46 AM,  jkal...@apache.org wrote:
 * ap_exr: Add replace(string, from, to) function.

Is it possible to evaluate this from ap_expr_str_exec()? I am stuck on
trying to get it to work. I think we cannot get to multi-valued
functions from  the %{func:arg} syntax used when starting at string.


Re: svn commit: r1643179 - in /httpd/httpd/trunk/server/mpm: prefork/prefork.c worker/worker.c

2014-12-05 Thread Daniel Gruno

All fixed now - took a bit of digging, but it works :)

On 2014-12-05 13:43, Yann Ylavic wrote:

OK, thanks Daniel.

On Fri, Dec 5, 2014 at 1:41 PM, Daniel Gruno humbed...@apache.org wrote:

I'm working on that right now, Yann :)

With regards,
Daniel.

On 2014-12-05 13:40, Yann Ylavic wrote:

On Fri, Dec 5, 2014 at 8:57 AM,  yla...@apache.org wrote:

Author: ylavic
Date: Fri Dec  5 07:57:57 2014
New Revision: 1643179

URL: http://svn.apache.org/viewvc?rev=1643179view=rev

The URL used here seems to have changed since recent upgrade (was
httpd://svn.a.o/r[rev] before).
The previous one looked more generic IMHO, less dependant on the SVN
viewer (would not break if the viewer changes some day).






Re: svn commit: r1642154 - in /httpd/httpd/trunk: docs/manual/expr.xml include/ap_expr.h server/util_expr_eval.c server/util_expr_parse.y

2014-12-05 Thread Jan Kaluža

On 12/05/2014 02:26 PM, Eric Covener wrote:

On Thu, Nov 27, 2014 at 8:46 AM,  jkal...@apache.org wrote:

* ap_exr: Add replace(string, from, to) function.


Is it possible to evaluate this from ap_expr_str_exec()?


Hm, it worked for me like this:

Require expr replace(%{REQUEST_METHOD},  E, O) == GOT

This internally uses ap_expr_str_exec().


I am stuck on trying to get it to work. I think we cannot get to multi-valued
functions from  the %{func:arg} syntax used when starting at string.


I think I'm lost here. Checking for ap_expr documentation, I don't see 
this syntax. Can you describe this more. I'm sorry, but was checking 
ap_expr for first time while doing this patch, so there might be things 
I overlooked.


Regards,
Jan Kaluza



Re: svn commit: r1642154 - in /httpd/httpd/trunk: docs/manual/expr.xml include/ap_expr.h server/util_expr_eval.c server/util_expr_parse.y

2014-12-05 Thread Eric Covener
On Fri, Dec 5, 2014 at 11:01 AM, Jan Kaluža jkal...@redhat.com wrote:
 On 12/05/2014 02:26 PM, Eric Covener wrote:

 On Thu, Nov 27, 2014 at 8:46 AM,  jkal...@apache.org wrote:

 * ap_exr: Add replace(string, from, to) function.


 Is it possible to evaluate this from ap_expr_str_exec()?


 Hm, it worked for me like this:

 Require expr replace(%{REQUEST_METHOD},  E, O) == GOT

I think this uses ap_expr_exec / aka boolean result:

static authz_status expr_check_authorization(request_rec *r,
 const char *require_line,
 const void *parsed_require_line)
{
const char *err = NULL;
const struct require_expr_info *info = parsed_require_line;
int rc = ap_expr_exec(r, info-expr, err);

if (rc  0) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02320)
  Error evaluating expression in 'Require expr': %s,
  err);
return AUTHZ_GENERAL_ERROR;
}
else if (rc == 0) {
if (info-want_user)
return AUTHZ_DENIED_NO_USER;
else
return AUTHZ_DENIED;
}
else {
return AUTHZ_GRANTED;
}
}


 This internally uses ap_expr_str_exec().

 I am stuck on trying to get it to work. I think we cannot get to
 multi-valued
 functions from  the %{func:arg} syntax used when starting at string.


 I think I'm lost here. Checking for ap_expr documentation, I don't see this
 syntax. Can you describe this more. I'm sorry, but was checking ap_expr for
 first time while doing this patch, so there might be things I overlooked.

I think it is the first function of its kind so it may not be easy.

When you actually want a string as the net result of an expression,
you start at string in ap_expr doc.

string  ::= stringpart
  | string stringpart

stringpart  ::= cstring
  | variable
  | rebackref

variable::= %{ varname }
  | %{ funcname : funcargs }

Full disclosure -- I don't understand this stuff so well, but I have
been learning on the job trying to make a dent in documenting some
different flavors of expressions in at least if and header set Foo
expr= so there is a starting point.


Re: svn commit: r1642154 - in /httpd/httpd/trunk: docs/manual/expr.xml include/ap_expr.h server/util_expr_eval.c server/util_expr_parse.y

2014-12-05 Thread Jan Kaluža

On 12/05/2014 05:09 PM, Eric Covener wrote:

On Fri, Dec 5, 2014 at 11:01 AM, Jan Kaluža jkal...@redhat.com wrote:

On 12/05/2014 02:26 PM, Eric Covener wrote:


On Thu, Nov 27, 2014 at 8:46 AM,  jkal...@apache.org wrote:


* ap_exr: Add replace(string, from, to) function.



Is it possible to evaluate this from ap_expr_str_exec()?



Hm, it worked for me like this:

Require expr replace(%{REQUEST_METHOD},  E, O) == GOT


I think this uses ap_expr_exec / aka boolean result:

static authz_status expr_check_authorization(request_rec *r,
  const char *require_line,
  const void *parsed_require_line)
{
 const char *err = NULL;
 const struct require_expr_info *info = parsed_require_line;
 int rc = ap_expr_exec(r, info-expr, err);

 if (rc  0) {
 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02320)
   Error evaluating expression in 'Require expr': %s,
   err);
 return AUTHZ_GENERAL_ERROR;
 }
 else if (rc == 0) {
 if (info-want_user)
 return AUTHZ_DENIED_NO_USER;
 else
 return AUTHZ_DENIED;
 }
 else {
 return AUTHZ_GRANTED;
 }
}



This internally uses ap_expr_str_exec().


I am stuck on trying to get it to work. I think we cannot get to
multi-valued
functions from  the %{func:arg} syntax used when starting at string.



I think I'm lost here. Checking for ap_expr documentation, I don't see this
syntax. Can you describe this more. I'm sorry, but was checking ap_expr for
first time while doing this patch, so there might be things I overlooked.


I think it is the first function of its kind so it may not be easy.

When you actually want a string as the net result of an expression,
you start at string in ap_expr doc.

string  ::= stringpart
   | string stringpart

stringpart  ::= cstring
   | variable
   | rebackref

variable::= %{ varname }
   | %{ funcname : funcargs }

Full disclosure -- I don't understand this stuff so well, but I have
been learning on the job trying to make a dent in documenting some
different flavors of expressions in at least if and header set Foo
expr= so there is a starting point.


I see what you mean now, thanks. I will need some time to actually think 
about possible solutions.


Right now, I'm curious why we can't add:

stringpart  ::= function

But there may be some problem with that I don't see right now. Well, I 
will try to play with it and let you know.


Jan Kaluza



Re: svn commit: r1642154 - in /httpd/httpd/trunk: docs/manual/expr.xml include/ap_expr.h server/util_expr_eval.c server/util_expr_parse.y

2014-12-05 Thread Yann Ylavic
On Thu, Nov 27, 2014 at 2:46 PM,  jkal...@apache.org wrote:
 Author: jkaluza
 Date: Thu Nov 27 13:46:11 2014
 New Revision: 1642154

 URL: http://svn.apache.org/r1642154
 Log:
 * ap_exr: Add replace(string, from, to) function.

Maybe it is worth noting (doc?) that from is a ap_strmatch() pattern
(with wildcards [*?]), hence eg.
replace(abc*def,  c*, gh) is abgh, and not abghef as one may expect.

Maybe then we should name this one replace_match(), and have replace()
(or replace_string) working on pure string patterns.
Likewise replace_regex(string, capture, substitution) would be nice to have.

Regards,
Yann.


Re: svn commit: r1642154 - in /httpd/httpd/trunk: docs/manual/expr.xml include/ap_expr.h server/util_expr_eval.c server/util_expr_parse.y

2014-12-05 Thread Yann Ylavic
On Fri, Dec 5, 2014 at 5:51 PM, Yann Ylavic ylavic@gmail.com wrote:
 replace(abc*def,  c*, gh) is abgh, and not abghef as one may expect.

s/abghef/abghdef/ above.


Re: svn commit: r1642154 - in /httpd/httpd/trunk: docs/manual/expr.xml include/ap_expr.h server/util_expr_eval.c server/util_expr_parse.y

2014-12-05 Thread Ruediger Pluem


On 12/05/2014 05:51 PM, Yann Ylavic wrote:
 On Thu, Nov 27, 2014 at 2:46 PM,  jkal...@apache.org wrote:
 Author: jkaluza
 Date: Thu Nov 27 13:46:11 2014
 New Revision: 1642154

 URL: http://svn.apache.org/r1642154
 Log:
 * ap_exr: Add replace(string, from, to) function.
 
 Maybe it is worth noting (doc?) that from is a ap_strmatch() pattern
 (with wildcards [*?]), hence eg.

Are you sure you aren't assuming apr_fnmatch instead of apr_strmatch?

Regards

Rüdiger



Re: svn commit: r1642154 - in /httpd/httpd/trunk: docs/manual/expr.xml include/ap_expr.h server/util_expr_eval.c server/util_expr_parse.y

2014-12-05 Thread Yann Ylavic
On Fri, Dec 5, 2014 at 9:05 PM, Ruediger Pluem rpl...@apache.org wrote:
 On 12/05/2014 05:51 PM, Yann Ylavic wrote:
 Maybe it is worth noting (doc?) that from is a ap_strmatch() pattern
 (with wildcards [*?]), hence eg.

 Are you sure you aren't assuming apr_fnmatch instead of apr_strmatch?

Doh! Absolutely.
I did not know apr_strmatch() actually, and read it as ap_strcmp_match()...
Nice function though, will use it more often :p

Just grep'ing strmatch now, I find this :

# server/util_expr_eval.c
static int op_strmatch(ap_expr_eval_ctx_t *ctx, const void *data,
   const char *arg1, const char *arg2)
{
return (APR_SUCCESS == apr_fnmatch(arg2, arg1, 0));
}

Quite confusing :)

Sorry for the noise,
regards,
Yann.


Re: mod_proxy_fcgi issues

2014-12-05 Thread Jeff Trawick
On Fri, Dec 5, 2014 at 7:45 AM, Jeff Trawick traw...@gmail.com wrote:

 On Thu, Dec 4, 2014 at 11:50 AM, Jeff Trawick traw...@gmail.com wrote:

 On Thu, Dec 4, 2014 at 10:38 AM, Eric Covener cove...@gmail.com wrote:

 forked from apachecon thread

 On Thu, Dec 4, 2014 at 10:23 AM, Jeff Trawick traw...@gmail.com wrote:
  On Thu, Dec 4, 2014 at 9:58 AM, Eric Covener cove...@gmail.com
 wrote:
 
  On Tue, Dec 2, 2014 at 4:14 PM, Jim Riggs apache-li...@riggs.me
 wrote:
   P.S. mod_proxy_balancer - mod_proxy_fcgi - php-fpm is really fun
 and
   interesting too! ;-)
 
  mod_proxy_fcgi seems to need a bit of work from what I have been
  seeing in bugzilla and IRC.  I hope to spend a little time on the code
  and doc, but not being an actual user of it I don't know how far I
  will really get before being distracted.
 
 
  This is very important stuff IMO.
 
  I know we don't do the coordination thing around here, but if the work
 was
  organized to some extent, perhaps 3-4 people could easily share the
 work???
  (bite sized chunks of the development:  simple reproducers, doc, code,
  review, whatever)
 
  Besides searching through Bugzilla and summarizing each mod_proxy_fcgi
 bug
  and ranking by apparent severity, number of users involved in the bug
  discussion, etc., what else should I put on a Wiki page?  E.g., do you
 have
  an idea of what needs to be improved in the doc?

 I don't have much more than what amounts to the summary/initial poking
 around in the bugzillas.  I had the wiki thought too -- bullets there
 are much easie than trying to reabsorb the PRs each time.

 - examples need to account for php-fpm (how URLs and or paths are passed)
 - fixes for CGI variables in different configurations (sethandler vs.
 proxypass)
 -- fixup r-filename right before adding CGI vars, maybe directory walk
 -- path info calculation probably needs multiple modes.  Maybe expr
 based?


 FWIW, every time I see the PATH_INFO questions I recall the nginx
 configuration (the script vars provided are those defined in the
 configuration, with some expression support); we need general CGISetVar
 var expr that sets or overrides script variables in common code (like
 CGIPassAuth) so that it works with the many modules that interface with
 scripts.



 - further doc for worker matching stuff with ProxySet
 - provide a convenience/less verbose directive to configure SetHandler
 +  a backend worker
 -- doc SetHandler advantages
 - change compile-time diag stuff to trace8
 - need to port mod_proxy_http or mod_fcgid body spooling / content
 length passing
 - would be nice to have a non php-fpm fastcgi server to sanity check
 with so we don't end up with too many php-fpm-isms
 - figure out / make sure balancer examples work with php-fpm and/or
 setHandler


 And although mod_proxy_fcgi is  the usual suspect, some of these are
 important issues with mod_proxy_scgi too.  (It is faster, and for some
 deployments there's no natural preference for FastCGI over SCGI.)

 Thanks for all the notes; I'll write this stuff up today.


 Initial version at
 https://wiki.apache.org/httpd/Development/mod_proxy_fcgi

 I haven't integrated your list into the table yet


Now that's cleaned up.

I guess PATH_INFO is the issue that affects the most people; thoughts?

I guess expression-based support for overriding the default PATH_INFO
calculation is the basis for solving the widest variety of problems with
any of the variables, though I don't know if we'll have the right string
operations available (e.g., substring of dynamic length); thoughts?