Re: need help to add per-user config to Apache::Test

2003-09-02 Thread Randy Kobes
On Tue, 2 Sep 2003, Stas Bekman wrote:

 Randy Kobes wrote:
[ ... ]
   sub filter_args {
   my($args, $wanted_args) = @_;
  +if (HAS_CONFIG) {
  +for (qw(group user apxs port httpd)) {
  +next unless defined $Apache::MyTestConfig-{$_};
  +unshift @$args, -$_, $Apache::MyTestConfig-{$_};
  +}
  +}

 may be it's better to do it at a later stage? this just
 used to generate t/TEST and similar scripts. If MyConfig
 has changed since t/TEST was generated the changes won't
 affect t/TEST.
[ .. ]

Thanks, Stas. You're right about the problems with $HOME,
and I'll take a more careful look at it, as well as your
other comments. In the meantime, here's something that
inserts the data at a later stage, and yet still can get
overridden by explicit arguments to t/TEST. In this
attempt, all the changes are made to Apache::TestRun.pm.
===
Index: TestRun.pm
===
RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm,v
retrieving revision 1.113
diff -u -r1.113 TestRun.pm
--- TestRun.pm  22 Jul 2003 11:21:36 -  1.113
+++ TestRun.pm  2 Sep 2003 22:31:40 -
@@ -11,10 +11,31 @@
 use Apache::TestHarness ();
 use Apache::TestTrace;

+require File::Spec;
+sub has_config {
+my $has_config = 0;
+# XXX $HOME isn't propagated in mod_perl
+if ($ENV{HOME}) {
+eval
+{require File::Spec-catfile($ENV{HOME},
+ '.apache-test',
+'TestConfigData.pm');};
+$has_config = 1 unless $@;
+}
+unless ($has_config) {
+eval {require Apache::TestConfigData;};
+$has_config = 1 unless $@;
+}
+return $has_config;
+}
+use constant HAS_CONFIG = has_config();
+
 use File::Find qw(finddepth);
-use File::Spec::Functions qw(catfile);
+use File::Spec::Functions qw(catfile catdir);
 use Getopt::Long qw(GetOptions);
+use File::Basename;
 use Config;
+use Symbol qw(gensym);

 use constant STARTUP_TIMEOUT = 300; # secs (good for extreme debug cases)
 use subs qw(exit_shell exit_perl);
@@ -23,7 +44,7 @@
 my %original_t_perms = ();

 my @std_run  = qw(start-httpd run-tests stop-httpd);
-my @others   = qw(verbose configure clean help ssl http11);
+my @others   = qw(verbose configure clean help ssl http11 save);
 my @flag_opts= (@std_run, @others);
 my @string_opts  = qw(order trace);
 my @ostring_opts = qw(proxy ping);
@@ -55,6 +76,7 @@
'ssl' = 'run tests through ssl',
'proxy'   = 'proxy requests (default proxy is localhost)',
'trace=T' = 'change tracing default to: warning, notice, info, 
debug, ...',
+   'save'= 'save test paramaters into Apache::TestConfigData',
(map { $_, \U$_\E url } @request_opts),
 );

@@ -509,6 +531,12 @@

 sub new_test_config {
 my $self = shift;
+if (HAS_CONFIG) {
+for (qw(httpd port user group apxs)) {
+next unless $Apache::TestConfigData-{$_};
+   $self-{conf_opts}-{$_} ||= $Apache::TestConfigData-{$_};
+}
+}
 Apache::TestConfig-new($self-{conf_opts});
 }

@@ -614,6 +642,10 @@
 $self-run_tests;

 $self-stop;
+
+$self-write_config() if
+($self-{opts}-{save} or not HAS_CONFIG);
+
 }

 my @oh = qw(jeez golly gosh darn shucks dangit rats nuts dangnabit crap);
@@ -915,6 +947,75 @@
 #require Carp;
 #Carp::cluck('exiting');
 CORE::exit $_[0];
+}
+
+sub write_config {
+my $self = shift;
+my $dir;
+for (@INC) {
+my $candidate = catfile($_, 'Apache', 'Test.pm');
+if (-e $candidate) {
+$dir = dirname($candidate);
+last;
+}
+}
+unless (-w $dir) {
+$dir = catdir($ENV{HOME}, '.apache-test');
+unless (-d $dir) {
+mkdir $dir or do {
+warn Cannot mkdir $dir: $!;
+return;
+};
+}
+}
+
+my $fh = Symbol::gensym();
+my $file = catfile($dir, 'TestConfigData.pm');
+unless (open($fh, $file)) {
+warn Cannot open $file: $!;
+return;
+}
+warn Writing $file \n;
+my $vars = $self-{test_config}-{vars};
+my $config_dump;
+for (qw(group user apxs port httpd)) {
+next unless $vars-{$_};
+$config_dump .= qq{'$_' = } . qq{'$vars-{$_}',\n};
+}
+
+my $pkg =  EOC;
+package Apache::TestConfigData;
+\$Apache::TestConfigData = {
+$config_dump
+};
+1;
+
+=head1 NAME
+
+Apache::TestConfigData - Configuration file for Apache::Test
+
+=cut
+EOC
+print $fh $pkg;
+close $fh;
+my $test = catdir($vars-{top_dir}, 'blib/lib/Apache');
+if (-e catfile($test, 'Test.pm')) {
+my $fh = Symbol::gensym();
+my $file = catfile($test, 'TestConfigData.pm');
+if (-e $file) {
+unlink $file or do {
+warn 

Re: need help to add per-user config to Apache::Test

2003-09-02 Thread Stas Bekman
Randy Kobes wrote:
[ trimmed mod_perl mailing list from cc ]
On Fri, 29 Aug 2003, Randy Kobes wrote:

On Thu, 28 Aug 2003, Stas Bekman wrote:

Several people have asked for having a new feature in
Apache::Test: they want to configure it once (where the
server, apxs, etx are) and run Apache::Test without
needing to pass any arguments. Matt suggested that it
should remember the values passed the first time it's used
and then re-use them. However on a system with several
users and different preferences, this won't work.
Therefore we need to be able to support per-user
preferences. CPAN.pm's setup seems to provide a good
solution to the same problem (CPAN/Config.pm and
~user/.cpan/CPAN/Config.pm). So I thought that someone
would like to port the functionality from CPAN.pm to
Apache::Test and send the patches here. It's all pure
perl, so you have no excuses that it's XS/C ;)
I have a mostly functional version of this, save for
the ability to use a $HOME/.apache-test/Config.pm, which
shouldn't be too hard to add. I'll try to finish it
off this weekend.

A stab at this follows ... It's rough, as I wanted to
make sure this was on the right track; basically, what's
supposed to happen is
- if a Apache::MyTestConfig is found, use the values for
Apache::TestMyConfig? so that we keep all Apache/Test*.pm and it's My Config, 
not My Test... but see below

apxs, httpd, user, group, and port stored in there. These
values get overridden if they appear as arguments to 'perl
Makefile.PL'.
which embeds them in t/TEST, so in effect if they are passed to the code that 
runs a subclass of Apache::TestRun

- if no Apache::MyTestConfig is present, or a '-save'
option is passed to 'perl t/TEST', Apache::MyTestConfig
is created, and then installed.
- the location of Apache::MyTestConfig is, first of all,
under $HOME/.apache-test/, or if this is not present,
under the system @INC.
If it's under system-wide @INC, it probably should be called My because it's 
not user specific (I'm trying to mimic CPAN.pm here. BTW, I haven't been using 
CPANPLUS, how do they do it?) But then it'll collide with the existing 
Apache/TestConfig.pm. So may be we just have Apache/TestConfigData.pm (or 
something like that) and then we don't need My at all, as we will just look 
first under $HOME/.apache-test and then under @INC?

I think when Apache::Test is installed, the config data module should go into 
@INC's location. when it's used for the first time it should go into 
$HOME/.apache-test/.

Won't ~/.apache-test have probs on some filesystems? Is it a safe path?
I'm not sure I'm putting the values of
Apache::MyTestConfig in the right, or best, place;
I haven't tested it extensively, as my linux box
is a live server.
=
Index: TestConfig.pm
===
RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm,v
retrieving revision 1.171
diff -u -r1.171 TestConfig.pm
--- TestConfig.pm   13 Aug 2003 19:02:51 -  1.171
+++ TestConfig.pm   1 Sep 2003 03:51:13 -
@@ -3,6 +3,22 @@
 use strict;
 use warnings FATAL = 'all';
+require File::Spec;
+sub has_config {
+my $has_config = 0;
+if ($ENV{HOME}) {
+eval
+{require File::Spec-catfile($ENV{HOME},
+ '.apache-test', 'MyTestConfig.pm');};
That won't work when invoked from the server side, since HOME isn't normally 
propogated. Probably need to detect whether we are running under mod_perl 2.0 
and then retrieve the username the server is running under, but wait, normally 
it runs under 'nobody' or a such, so it won't have this setup...

in any case for now you probably need to check first whether $ENV{HOME} exists 
and put some XXX to fix it later so it'll work under mod_perl as well...

@@ -24,8 +40,8 @@
 use File::Path ();
 use File::Spec::Functions qw(catfile abs2rel splitdir canonpath
  catdir file_name_is_absolute);
-use Cwd qw(fastcwd);
+use Cwd qw(fastcwd);
weird...
 use Apache::TestConfigPerl ();
 use Apache::TestConfigParse ();
 use Apache::TestTrace;
@@ -34,6 +50,8 @@
 use vars qw(%Usage);
+use constant HAS_CONFIG = has_config();
+
 %Usage = (
top_dir   = 'top-level directory (default is $PWD)',
t_dir = 'the t/ test directory (default is $top_dir/t)',
@@ -72,6 +90,12 @@
 sub filter_args {
 my($args, $wanted_args) = @_;
+if (HAS_CONFIG) {
+for (qw(group user apxs port httpd)) {
+next unless defined $Apache::MyTestConfig-{$_};
+unshift @$args, -$_, $Apache::MyTestConfig-{$_};
+}
+}
may be it's better to do it at a later stage? this just used to generate 
t/TEST and similar scripts. If MyConfig has changed since t/TEST was generated 
the changes won't affect t/TEST.

 my(@pass, %keep);
 my @filter = @$args;
Index: TestRun.pm

Re: Time for 2.2?

2003-09-02 Thread Astrid Keßler
 Just to prevent any misunderstandings: are we talking about a 2.2
 *alpha* or *beta* release here, or what will it be called? If it's in
 any way marked as *unstable*, then a clear +1 from my side. The recent
 changes are definitely worth to get tested in the wild, IMHO.

 The alphas/betas will be called 2.1.x.  2.2.0 wouldn't be released until
 2.1.x releases were declared stable.  So, basically, yes.

+1 from me

Kess


Re: Time for 2.2?

2003-09-02 Thread Justin Erenkrantz
David Reid wrote:
 Seems like a plan.

 Do we then migrate from 2.0 to 2.2 for our *stable* tree? Some extra
 clarification might be nice...

Well, as Cliff pointed out, we would start issuing releases under the 2.1
moniker.  Then, when we're all feeling warm and fuzzy about 2.1, we'll
call it 2.2, and open APACHE_2_2_BRANCH.  HEAD would then become 2.3. 
APACHE_2_0_BRANCH would still be open.

Ideally, we'd recommend that 2.0 users migrate to 2.2 because it's
'stable' and has more feature, blah, blah, blah.

And, to re-iterate, I forsee this process taking a few months.  -- justin


Re: [PROPOSAL] Remove ap_*_client_block in 2.1 series

2003-09-02 Thread Justin Erenkrantz
--On Sunday, August 31, 2003 11:27 PM +0100 Nick Kew [EMAIL PROTECTED] wrote:

AIUI 2.1 is supposed to be a minimal change from 2.0.  This proposal
will break (an unknown number of) 2.0 modules.  Last time I looked,
No one ever said 2.2 is supposed to be a minimal change.  =)

The point of making a number of 2.1 releases before 2.2 is to allow time for 
module writers to adjust to the new API in whatever way they need to.  IMHO, 
this was our mistake last time - we released a 2.0 GA release before we had 
the API 'finalized,' and didn't allow gestation for module writers to adapt to 
the new 2.0 API.

Once we do a 2.1 RC, the API will be fixed, and there will be a few months (?) 
for module writers to get ready.  (Compare with Linux 2.4 and 2.6 kernel 
drivers.)

it was the only *documented* API for reading input data.  IMO better
to mark it as deprecated, but leave it in until something is
*expected* to break third-party modules (like 1.3-2.0 did).
ap_get_brigade() is the recommended approach and has been available for the 
entire 2.0 series and is fully documented.  We haven't been explicit that 
ap_*_client_block should be removed, but I've posted on this list several 
times how to take an old module using the ap_*_client_block API and switch it 
to equivalent ap_get_brigade logic.

Regardless, I would expect in a 2.1 RC or 2.2 release, we would have an 
'upgrading' guide to explain how to switch code using ap_*_client_block to 
ap_get_brigade.

Note, in this particular case, if you switch your module to using 
ap_get_brigade(), you'll be backwards source-compatible with 2.0 and 2.1/2.2. 
And, 2.0 will have ap_*_client_block forever.  ;-)

What about that other inconsistency: the difference between
ap_rputs/family in Handlers and ap_fputs/etc in Filters?  The subtle
difference to the arguments to these is - erm - annoying!
ISTR there was a vote before my time on this issue.  Anyone?  -- justin


Re: [Fwd: Possible security flaw! (Format BUG)]

2003-09-02 Thread Ben Laurie
Ranier Vilela wrote:

 Sorry, the mpm_common.c.diff was empty.
 
 
 
 
 --- mpm_common.c  2003-08-31 06:06:25.0 -0300
 +++ mpm_common_old.c  2003-08-31 05:57:14.0 -0300
 @@ -808,7 +808,7 @@
  
  if (!strcmp(dash_k_arg, restart)) {
  if (!running) {
 -printf(%s\n, httpd not running, trying to start);
 +printf(httpd not running, trying to start\n);
  }
  else {
  *exit_status = send_signal(otherpid, SIGHUP);
 @@ -818,7 +818,7 @@
  
  if (!strcmp(dash_k_arg, graceful)) {
  if (!running) {
 -printf(%s\n, httpd not running, trying to start);
 +printf(httpd not running, trying to start\n);
  }
  else {
  *exit_status = send_signal(otherpid, SIGUSR1);

That's backwards. In any case, there is no flaw here, but it would be
more efficient to replace printf with puts (and lose the trailing
newline, of course).

Cheers,

Ben.

-- 
http://www.apache-ssl.org/ben.html   http://www.thebunker.net/

There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit. - Robert Woodruff




Re: Spam Using SMTP Over HTTP-Proxy

2003-09-02 Thread Chris Knight
Joshua Slive wrote:

I think we've done pretty-much all we can.  I wouldn't mind putting a
little note on the httpd.apache.org homepage saying Have you secured your
proxy? and point to the correct docs.
 

What about sending a warning message to stderr/error_log upon startup if 
the proxy is not access controlled?

...HTTPS proxying is even worse and could be used to mount a variety of 
TCP attacks.



Re: Time for 2.2?

2003-09-02 Thread Stas Bekman
Well, as Cliff pointed out, we would start issuing releases under the 2.1
moniker.  Then, when we're all feeling warm and fuzzy about 2.1, we'll
call it 2.2, and open APACHE_2_2_BRANCH.  HEAD would then become 2.3. 
APACHE_2_0_BRANCH would still be open.
Before 2.2 is even considered shouldn't all the outstanding design issues be 
fixed first? e.g. there are at least several design problems with filters.

__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: Time for 2.2?

2003-09-02 Thread Justin Erenkrantz
--On Tuesday, September 02, 2003 13:40:23 -0700 Stas Bekman 
[EMAIL PROTECTED] wrote:

Before 2.2 is even considered shouldn't all the outstanding design issues
be fixed first? e.g. there are at least several design problems with
filters.
Aren't you just talking about the fact that it's not a doubly-linked list? 
This leads to the oddness when removing the first connection filter, right?

I wouldn't call that a design flaw.  It's a revert of a prior commit that 
removed DLLs.  -- justin


Re: Time for 2.2?

2003-09-02 Thread Stas Bekman
Justin Erenkrantz wrote:
--On Tuesday, September 02, 2003 13:40:23 -0700 Stas Bekman 
[EMAIL PROTECTED] wrote:

Before 2.2 is even considered shouldn't all the outstanding design issues
be fixed first? e.g. there are at least several design problems with
filters.


Aren't you just talking about the fact that it's not a doubly-linked 
list? This leads to the oddness when removing the first connection 
filter, right?

I wouldn't call that a design flaw.  It's a revert of a prior commit 
that removed DLLs.  -- justin
I remember you told me that rbb removed it because it didn't quite work, no?

Another problem with filters design is the init_filter function. I forgot the 
details, I hope Geoff can give them, as he has messed with it.

Yet another issue was with the filters in sub-requests. I don't remember if it 
was completely resolved (copying the stack...)

__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com