You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by David Wortham <dj...@gmail.com> on 2007/04/05 03:38:27 UTC

Apache Logs Directory

Sorry for such a simple question, but I have not been able to find the
answer yet.

Is there a function in APR to retrieve the default Apache logs directory?

When my module starts up, it needs to create cache files if they don't
already exist (which happens before directives are traversed).  I have a
directive to accept a custom logs directory (which seems to work fine), but
I would like my module to be able to work (as in: not attempt to write to a
directory which doesn't exist) without any necessary directives.  Any
ideas?  Anyone know of an existing module which may have the code I want?

I'm already in the process of doing lstat-related testing to ensure I'm not
trying to write to a directory which doesn't exist.

My module is coded in C running under Apache 2.0.54 on Linux and I am hoping
to keep it platform-independent.

Thanks in advance,
Dave
-- 
David Wortham
Senior Web Applications Developer
Unspam Technologies, Inc.

Re: Apache Logs Directory

Posted by Azazel <az...@azazel.net>.
J. Daniel Rotenberg said:
> In this situation I would use something like
> ap_server_root_relative() and prepend the 'logs' part to whatever your
> cache file name is. I'm not positive that this guarantees that you get
> an existing directory, though.
>
> Your safest bet is to retain your directive but make it optional. Set
> a default location with the above when you create your config, and
> then if the user sets a different directory in which to store the
> files, you just reset it to that. If you test the directory before you
> continue, you should be ok.

The default run-time directory is defined by DEFAULT_REL_RUNTIMEDIR.

mod_cgid, for example, sets the default file-name for its socket using
this, but allows it to be overridden in the config file using
ap_server_root_relative.  See the set_script_socket function in
${APACHE_SRC}/modules/generators/mod_cgid.c

Az.
-- 
+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+
 www: http://www.azazel.net/
 pgp: http://www.azazel.net/~azazel/az_key.asc
+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+


Re: Apache Logs Directory

Posted by "J. Daniel Rotenberg" <jo...@gmail.com>.
In this situation I would use something like
ap_server_root_relative() and prepend the 'logs' part to whatever your
cache file name is. I'm not positive that this guarantees that you get
an existing directory, though.

Your safest bet is to retain your directive but make it optional. Set
a default location with the above when you create your config, and
then if the user sets a different directory in which to store the
files, you just reset it to that. If you test the directory before you
continue, you should be ok.

Josh

On 4/5/07, David Wortham <dj...@gmail.com> wrote:
> In reference to my last question (about finding a suitable cache-file
> directory), I found this function in the httpd-2.2.x source:
> apr_temp_dir_get(char** temp_dir, apr_pool t* p).
>
> Has anyone used this function or does anyone know if it is (or is not) fully
> supported by all apache implementations?  Is it guaranteed to return a
> writeable directory?
>
> Thanks,
> Dave
>
>
>
>
>
> On 4/4/07, David Wortham <dj...@gmail.com> wrote:
> >
> > Sorry for such a simple question, but I have not been able to find the
> > answer yet.
> >
> > Is there a function in APR to retrieve the default Apache logs directory?
> >
> > When my module starts up, it needs to create cache files if they don't
> > already exist (which happens before directives are traversed).  I have a
> > directive to accept a custom logs directory (which seems to work fine), but
> > I would like my module to be able to work (as in: not attempt to write to a
> > directory which doesn't exist) without any necessary directives.  Any
> > ideas?  Anyone know of an existing module which may have the code I want?
> >
> > I'm already in the process of doing lstat-related testing to ensure I'm
> > not trying to write to a directory which doesn't exist.
> >
> > My module is coded in C running under Apache 2.0.54 on Linux and I am
> > hoping to keep it platform-independent.
> >
> > Thanks in advance,
> > Dave
> > --
> > David Wortham
> > Senior Web Applications Developer
> > Unspam Technologies, Inc.
>
>
>
>
> --
> David Wortham
> Senior Web Applications Developer
> Unspam Technologies, Inc.
> 1901 Prospector Dr. #30
> Park City, UT 84060
> (435) 513-0672
>

Re: Apache Logs Directory

Posted by David Wortham <dj...@gmail.com>.
In reference to my last question (about finding a suitable cache-file
directory), I found this function in the httpd-2.2.x source:
apr_temp_dir_get(char** temp_dir, apr_pool t* p).

Has anyone used this function or does anyone know if it is (or is not) fully
supported by all apache implementations?  Is it guaranteed to return a
writeable directory?

Thanks,
Dave





On 4/4/07, David Wortham <dj...@gmail.com> wrote:
>
> Sorry for such a simple question, but I have not been able to find the
> answer yet.
>
> Is there a function in APR to retrieve the default Apache logs directory?
>
> When my module starts up, it needs to create cache files if they don't
> already exist (which happens before directives are traversed).  I have a
> directive to accept a custom logs directory (which seems to work fine), but
> I would like my module to be able to work (as in: not attempt to write to a
> directory which doesn't exist) without any necessary directives.  Any
> ideas?  Anyone know of an existing module which may have the code I want?
>
> I'm already in the process of doing lstat-related testing to ensure I'm
> not trying to write to a directory which doesn't exist.
>
> My module is coded in C running under Apache 2.0.54 on Linux and I am
> hoping to keep it platform-independent.
>
> Thanks in advance,
> Dave
> --
> David Wortham
> Senior Web Applications Developer
> Unspam Technologies, Inc.




-- 
David Wortham
Senior Web Applications Developer
Unspam Technologies, Inc.
1901 Prospector Dr. #30
Park City, UT 84060
(435) 513-0672