From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f8c9b,1d64a7fe5aec5d17 X-Google-Attributes: gidf8c9b,public X-Google-Thread: fee84,1d64a7fe5aec5d17 X-Google-Attributes: gidfee84,public From: Scott Moore Subject: Re: POSIX.4 Semaphore questions Date: 1997/11/19 Message-ID: <34732680.197D@us.ibm.com>#1/1 X-Deja-AN: 290808574 References: <3471B707.77EA@us.ibm.com> <3472C81E.1D889693@zko.dec.com> Organization: IBM Rochester MN Newsgroups: comp.unix.questions,comp.unix.osf.osf1 Dave Butenhof wrote: > This is a fascinating issue, but, unfortunately, the standard isn't going > to help you much here. I suspect that any restriction of permissions with > semaphores is going to be fairly non-portable. That is kinda what I thought. It seems like the standard is VERY brief about permissions, other than they can be specified when creating a semaphore, and the sem_open() can fail with EACCESS (But it does not mention the circumstances that it can fail with EACCESS! Does it fail if the caller only has read, or only has write? Or does it require both to do the sem_open? I guess that this is implementation specific...). A lot of good that does us!! > POSIX doesn't say what access is required to open a semaphore. It does > allow sem_open to return EACCES if "the permissions specified by oflag are > denied". (Which is a typo, in any case, since it is mode, not oflag, that > specifies permissions.) That implies that, if your second open were > sem_open("/mysem", O_CREAT, 0606, 0), it would fail with EACCES because the > original creator hadn't allowed write access to other users. > > I can't imagine that you'd be able to open a semaphore without read > permission, and you certainly couldn't do anything with it. There are no > "pure write" operations on a semaphore -- only "read" and "modify" > operations (which would require a read followed by a write). Good point! But on system V semaphores, you only need write access to decrement a semaphore, but this is a "read" and "modify" operation as well. Yet another gripe on Sys V IPC. %^). Sajjad- It is recommended that you specify the macro's for permissions. It is possible that the implementation does not have the octal representation for the permissions (I don't know of an implementation, but I'm sure one rebel platform exists!) Thank you for the answers guys! Scott