24-Jun-99 11:44 you wrote:
> On Thu, Jun 24, 1999, Khimenko Victor wrote:
>> 22-Jun-99 15:03 you wrote:
>> > On Tue, Jun 22, 1999, GOMEZ Henri wrote:
>>
>> >> > > In /var/run directory, the httpd.mm.sem file is
>> >> > > owned by root. Mustn't it be by nobody ?
>> >> > > When I chown to nobody, seems to work normally.
>> >> >
>> >> [GOMEZ Henri] I could see there is 2 files in /var/run with .sem
>> >> extensions :
>> >>
>> >> httpd.mm.sem owned by root
>> >> ssl_scache.sem which is owned by nobody !
>> >>
>> >> [GOMEZ Henri] Who create httpd.mm.sem ?
>>
>> > httpd.mm.sem is the mutex lock for the MM library
>> > and ssl_scache.sem is the mutex lock of mod_ssl.
>> > But both should be owned by nobody, of course.
>>
>> With current version of EAPI httpd.mm.sem will be owned by root for sure.
>> This file is created via ap_init_alloc_shared from REALMAIN ...
>> WELL before switch from root to nobody. Before even config reading !
>> [...]
>> Is it really good place for this call ? Or may be we just need one more chown
>> somewhere ? In present state mod_ssl 2.3.5 + mm 1.0.7 need some punch on
>> startup and this is Bad Thing[tm].
> Yes, it _has_ to be exactly after the option parsing (to allow -d to change
> the MM paths) and before the config reading (to allow modules to store the
> config data already into shared memory pools). But you're right, a
> ap_mm_permission() call after config reading (where ap_user_id is available)
> is missing which does the chown! I append you a patch which I think will fix
> the problem for mod_ssl 2.3.6. Please try it out quickly and give me feedback
> whether it works also for you. Just apply it to the Apache source tree after
> mod_ssl was already applied.
It works great ! Of course I can not "just apply it" (I use my own version of
EAPI, you know :-) and it will not compile when applied (ap_user_id is not
available in alloc.c) but it's minor issues (still may be it's wise idea
to declare ap_user_id somewhere in alloc.c -- I declared it just before
ap_mm_permission call as `extern uid_t ap_user_id' -- and avoid bug reports
from innocent users).
P.S. May be better to use not only ap_user_id but ap_group_id as well ?
I doubt if such file (owned and writeable by `apache' but in group `root') is
usefull for any type of security attack on any system but still group `apache'
looks better to me, doesn't it ?
> Index: main/alloc.c
> ===================================================================
> RCS file: /e/modssl/cvs/mod_ssl/pkg.apache/src/main/alloc.c,v
> retrieving revision 1.2
> diff -u -r1.2 alloc.c
> --- main/alloc.c 1999/04/13 10:19:08 1.2
> +++ main/alloc.c 1999/06/24 09:41:11
> @@ -553,20 +553,31 @@
> }
> #if defined(EAPI)
> -void ap_init_alloc_shared(void)
> +void ap_init_alloc_shared(int early)
> {
> #if defined(EAPI_MM)
> int mm_size;
> char *mm_path;
> - mm_size = ap_mm_maxsize();
> - if (mm_size > EAPI_MM_CORE_MAXSIZE)
> - mm_size = EAPI_MM_CORE_MAXSIZE;
> - mm_path = ap_server_root_relative(permanent_pool, EAPI_MM_CORE_PATH);
> - if ((mm = ap_mm_create(mm_size, mm_path)) == NULL) {
> - fprintf(stderr, "Ouch! ap_mm_create() failed\n");
> - abort();
> - exit(1);
> + if (early) {
> + /* process very early on startup */
> + mm_size = ap_mm_maxsize();
> + if (mm_size > EAPI_MM_CORE_MAXSIZE)
> + mm_size = EAPI_MM_CORE_MAXSIZE;
> + mm_path = ap_server_root_relative(permanent_pool, EAPI_MM_CORE_PATH);
> + if ((mm = ap_mm_create(mm_size, mm_path)) == NULL) {
> + fprintf(stderr, "Ouch! ap_mm_create() failed\n");
> + abort();
> + exit(1);
> + }
> + }
> + else {
> + /* process a lot later on startup */
> +#ifdef WIN32
> + ap_mm_permission(mm, (_S_IREAD|_S_IWRITE), ap_user_id, -1);
> +#else
> + ap_mm_permission(mm, (S_IRUSR|S_IWUSR), ap_user_id, -1);
> +#endif
> }
> #endif /* EAPI_MM */
> return;
> Index: main/http_main.c
> ===================================================================
> RCS file: /e/modssl/cvs/mod_ssl/pkg.apache/src/main/http_main.c,v
> retrieving revision 1.22
> diff -u -r1.22 http_main.c
> --- main/http_main.c 1999/04/13 10:19:08 1.22
> +++ main/http_main.c 1999/06/24 09:36:46
> @@ -4661,12 +4661,16 @@
> #endif /* TPF */
> #ifdef EAPI
> - ap_init_alloc_shared();
> + ap_init_alloc_shared(TRUE);
> #endif
> ap_suexec_enabled = init_suexec();
> server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
> +#ifdef EAPI
> + ap_init_alloc_shared(FALSE);
> +#endif
> +
> if (configtestonly) {
> fprintf(stderr, "Syntax OK\n");
> exit(0);
> @@ -6045,7 +6049,7 @@
> }
> #ifdef EAPI
> - ap_init_alloc_shared();
> + ap_init_alloc_shared(TRUE);
> #endif
> if (!child && run_as_service) {
> @@ -6053,6 +6057,10 @@
> }
> server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
> +
> +#ifdef EAPI
> + ap_init_alloc_shared(FALSE);
> +#endif
> if (configtestonly) {
> fprintf(stderr, "Syntax OK\n");
> Index: include/alloc.h
> ===================================================================
> RCS file: /e/modssl/cvs/mod_ssl/pkg.apache/src/include/alloc.h,v
> retrieving revision 1.2
> diff -u -r1.2 alloc.h
> --- include/alloc.h 1999/04/13 10:18:27 1.2
> +++ include/alloc.h 1999/06/24 09:34:27
> @@ -96,7 +96,7 @@
> #if defined(EAPI)
> typedef enum { AP_POOL_RD, AP_POOL_RW } ap_pool_lock_mode;
> int ap_shared_pool_possible(void);
> -void ap_init_alloc_shared(void);
> +void ap_init_alloc_shared(int);
> API_EXPORT(pool *) ap_make_shared_sub_pool(pool *);
> API_EXPORT(int) ap_acquire_pool(pool *, ap_pool_lock_mode);
> API_EXPORT(int) ap_release_pool(pool *);
> ______________________________________________________________________
> Apache Interface to OpenSSL (mod_ssl) www.modssl.org
> User Support Mailing List [EMAIL PROTECTED]
> Automated List Manager [EMAIL PROTECTED]
______________________________________________________________________
Apache Interface to OpenSSL (mod_ssl) www.modssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]