Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: (qmail 74266 invoked from network); 26 Apr 2009 21:54:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 26 Apr 2009 21:54:00 -0000 Received: (qmail 53819 invoked by uid 500); 26 Apr 2009 21:53:59 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 53738 invoked by uid 500); 26 Apr 2009 21:53:59 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 53716 invoked by uid 99); 26 Apr 2009 21:53:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 Apr 2009 21:53:59 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of yokawasa@gmail.com designates 74.125.46.155 as permitted sender) Received: from [74.125.46.155] (HELO yw-out-1718.google.com) (74.125.46.155) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 Apr 2009 21:53:51 +0000 Received: by yw-out-1718.google.com with SMTP id 9so1174515ywk.84 for ; Sun, 26 Apr 2009 14:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=SY1xyfh3v9LrJ+RJAaJGRvm2Yi/mtlypc7iDDLqktL0=; b=xevZvBX7MRsYaDxn8f1fOl11Q/MZLEQGHqAHWa6Srhu7+z7iyo/Lj4RWilNqJZtbO8 yj7BGAlK9yx9dfttb7G2+XdVYm829lmX54MNw1R+QvXyQ6/HCsbcjU8okHVLP5xc6x2f KMntZftEUUcEj7bk0hD71ZFIW+W3M258EzF2I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=k6s+2lKBocvWY/BbOjGG8X7r39G8AeR7UYAnsZSCq4XVpT9TC74OK1k1GxXlcaYl3p 53V0PoybToCb1D5MCgrM4EaCD/ZbwiZFWkXEf5N2c+uAagLHNpJ9/i/5QlrGH/uF6or3 45ZmGb1f//etcunX30V+8OhU02Ygb+Xq7leBY= MIME-Version: 1.0 Received: by 10.151.129.5 with SMTP id g5mr7506960ybn.220.1240782810009; Sun, 26 Apr 2009 14:53:30 -0700 (PDT) In-Reply-To: <4404d1f60903202257s526b0365v9cfcf0b9dcb062ff@mail.gmail.com> References: <4404d1f60903202257s526b0365v9cfcf0b9dcb062ff@mail.gmail.com> Date: Mon, 27 Apr 2009 06:53:29 +0900 Message-ID: <2d2004750904261453ma99d04bk19d2c4fbd14eb663@mail.gmail.com> Subject: Re: apr_global_mutex_lock() failing with "permission denied" From: Yoichi Kawasaki To: modules-dev@httpd.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Hi Elison. 2009/3/21 Elison Smith : > I am using shared memory to share some data between my module instances i= n > Apache child processes, and apr_global_mutex_t =A0to achieve > mutually-exclusive reads and writes. > > In a post_config_hook, I create the mutex using apr_global_mutex_create() > and then reopen it inside each child process by calling > apr_global_mutex_child_init() inside a child_init hook. > > However, when I try to grab the lock inside a child, the operation fails > with a "permission denied". For the lock file, I =A0am using "/tmp/tmp" w= hich > is a file writeable by all. > > Any clues? > the platform on which your module runs is unix? There should be such a permission problem if the parent process starts as root while child processes as user/group that you specify in apache configuration file. In that case, use unixd_set_global_mutex_perms in child_init hook, after apr_global_mutex_create just like this below: ** code snippet from mod_rewrite.c ------------------------------------------------------------------------- #ifdef AP_NEED_SET_MUTEX_PERMS #include "unixd.h" #endif ... /* create the lockfile */ rc =3D apr_global_mutex_create(&rewrite_mapr_lock_acquire, lockname, APR_LOCK_DEFAULT, p); if (rc !=3D APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_CRIT, rc, s, "mod_rewrite: Parent could not create RewriteLock " "file %s", lockname); return rc; } #ifdef AP_NEED_SET_MUTEX_PERMS rc =3D unixd_set_global_mutex_perms(rewrite_mapr_lock_acquire); if (rc !=3D APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_CRIT, rc, s, "mod_rewrite: Parent could not set permissions " "on RewriteLock; check User and Group directives"); return rc; } #endif ------------------------------------------------------------------------- you should also see unixd.h (/path-to-apache/include/unixd.h) ------------------------------------------------------------------------- /** * One of the functions to set mutex permissions should be called in * the parent process on platforms that switch identity when the * server is started as root. * If the child init logic is performed before switching identity * (e.g., MPM setup for an accept mutex), it should only be called * for SysV semaphores. Otherwise, it is safe to call it for all * mutex types. */ AP_DECLARE(apr_status_t) unixd_set_proc_mutex_perms(apr_proc_mutex_t *pmute= x); AP_DECLARE(apr_status_t) unixd_set_global_mutex_perms(apr_global_mutex_t *gmutex); AP_DECLARE(apr_status_t) unixd_accept(void **accepted, ap_listen_rec *lr, apr_pool_t *ptrans); ------------------------------------------------------------------------- good luck! Yoichi --=20 --=20 Yoichi Kawasaki