Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.unix.programmer > #643

Re: mq_open - permission denied

From Rainer Weikusat <rweikusat@mssgmbh.com>
Newsgroups comp.unix.programmer
Subject Re: mq_open - permission denied
Date 2011-05-23 11:14 +0100
Message-ID <87aaed7mh1.fsf@sapphire.mobileactivedefense.com> (permalink)
References <eaaa82e5-3018-4b6b-876e-68ebd13270a2@f11g2000vbx.googlegroups.com> <87d3jaa2mk.fsf@sapphire.mobileactivedefense.com> <70bcc640-5ac0-4e7c-8db6-4fb8aeef8912@w21g2000yqm.googlegroups.com>

Show all headers | View raw


gogol <eromascanu@gmail.com> writes:
> On May 22, 4:42 pm, Rainer Weikusat <rweiku...@mssgmbh.com> wrote:
>> gogol <eromasc...@gmail.com> writes:

[...]

>> > errno = 0;
>> > mqd_t msgQ = mq_open(
>> >    mqname, /* message queue name */
>> >    O_RDWR | O_NONBLOCK | O_CREAT | O_EXCL, /* oflag */
>> >    S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH |
>> > S_IWOTH | S_IXOTH, /* mode */
>> >    &attr); /* attributes */

[...]

>> > The request handler attempts to open that (existing) messaege queue
>> > with:
>>
>> > mqd_t msgQ = mq_open(
>> >    mqname,               /* message queue name */
>> >    O_RDWR | O_NONBLOCK); /* mode */
>>
>> > The attempt to open the existing message queue fails with errno=13 -
>> > permission denied.

[...]

>> Assuming that x is your> input value, the value which gets applied
>> is actually
>>
>>         x & ~umask
>>
>> and umask will usually by 022 or 002, cause the group write and other
>> write bits to be disabled.

[...]

> I tried to create a message queue in Apache main init process, and
> open it within an app process. That works. The problem is that the
> request handler process (a child process of Apache main process)
> cannot open the message queue,

As I already wrote: Most likely, your problem is that the 'other
write' permission bit you gave in the mq_open call used to create the
message queue got disabled because the umask setting of the apache
process requested this to be done. Provided this was actually the case
(apache inherits the umask from the shell it was started from), you
could change the umask before creating the message queue, eg, by doing
something like this:

	mode_t omask;

        omask = umask(0);	/* use permissions as specified */
        mq_t = mq_open(...);
        umask(omask);

Back to comp.unix.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

mq_open - permission denied gogol <eromascanu@gmail.com> - 2011-05-21 06:53 -0700
  Re: mq_open - permission denied Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-05-22 21:42 +0100
    Re: mq_open - permission denied gogol <eromascanu@gmail.com> - 2011-05-22 14:42 -0700
      Re: mq_open - permission denied Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-05-23 11:14 +0100
        Re: mq_open - permission denied gogol <eromascanu@gmail.com> - 2011-05-23 06:15 -0700
          Re: mq_open - permission denied Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-05-23 15:19 +0100
            Re: mq_open - permission denied gogol <eromascanu@gmail.com> - 2011-05-23 16:34 -0700
          Re: mq_open - permission denied scott@slp53.sl.home (Scott Lurndal) - 2011-05-23 16:34 +0000
            Re: mq_open - permission denied gogol <eromascanu@gmail.com> - 2011-05-23 12:28 -0700
              Re: mq_open - permission denied Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-05-24 11:29 +0100
        Re: mq_open - permission denied gogol <eromascanu@gmail.com> - 2011-05-23 06:18 -0700

csiph-web