Bug 245319 - mq_open does not honor its mode argument
Summary: mq_open does not honor its mode argument
Status: Closed Works As Intended
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 12.1-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-03 15:47 UTC by Dave S.
Modified: 2020-04-06 01:51 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dave S. 2020-04-03 15:47:02 UTC
Here is the code:

void  openMsgQueue(void)
{
    mode_t           mode = S_IRUSR | S_IWUSR |
                            S_IRGRP | S_IWGRP |
                            S_IROTH | S_IWOTH;
    struct mq_attr   attributes;

    bzero(&attributes, sizeof(attributes));
    attributes.mq_maxmsg = 100;
    attributes.mq_msgsize = MSG_MAX_SIZE;
    mqid = mq_open(QUEUE_NAME, O_RDONLY | O_CREAT, mode, attributes);
    if ((mqd_t) -1 == mqid)
    {
        err(1, "mq_open");
    }
}

Obviously, MSG_MAX_SIZE and QUEUE_NAME are defined elsewhere.

After running this function for the first time, the QUEUE_NAME was created, but the permissions on the queue were:
-rw-r--r--

Since I specified that every user should have "rw" access, but it didn't happen, I had to use chmod so other users could send messages to this queue.
Comment 1 Jason A. Harmening freebsd_committer 2020-04-03 22:18:53 UTC
This behavior is consistent with the default umask(2) setting of 022.  What happens if you change that?
Comment 2 Dave S. 2020-04-06 01:51:18 UTC
You're right.  My bad.  I should have thought of that.