Bug 74485 - Existing semaphore (0) is modified at Apache 1.3.23-14 startup
Existing semaphore (0) is modified at Apache 1.3.23-14 startup
Status: CLOSED DUPLICATE of bug 74496
Product: Red Hat Linux
Classification: Retired
Component: apache (Show other bugs)
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Nalin Dahyabhai
Brian Brock
Depends On: 74496
  Show dependency treegraph
Reported: 2002-09-25 02:42 EDT by Dave Kelly
Modified: 2007-04-18 12:46 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-09-29 04:09:56 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Dave Kelly 2002-09-25 02:42:32 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)

Description of problem:
When my Linux server boots up, my application (Samsung Contact) is started 
first. This creates 2 semaphores with id=0 and id=32769.

When Apache starts up, it changes the permissions on semaphore 0 from 
666 to 600 and ownership from openmail to apache. This causes errors to be 
generated within Samsung Contact because a daemon can no longer operate on the 
semaphore it created.

If Samsung Contact is stopped and restarted, it's semaphores are created with 
non-zero ids and subsequent restarts of Apache do not cause a problem.

A strace on /usr/sbin/httpd shows that there are 3 calls to semctl to change 
the ownership. However, within the strace, there are only ever 2 semgets. 
Somehow, the daemon is also calling semctl on semaphore 0.

Trying to track this down with the 1.3.23-14 source RPM, there is no code that 
matches the behaviour seen in the strace.

There are 2 calls to semctl for each semid: 1 to with IPC_STAT and 1 with 
IP_SET where the permissions and ownership are changed.

There are calls to semctl in http_main.c but they do not match up with the 
strace output.

Attempting to compile the source with debugging symbols turned on does not seem 
to reproduce the problem. (Help would be appreciated on enabling debugging 
successfully :-) )

Compiling the source from the SRPM, will reproduce the problem.

We are also seeing that after Apache has been shut down, the semaphores it 
created are being left.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1) Stop Apache or boot up without Apache running.
2) Create a semaphore using the attached C program. If this is run just after 
boot up, it should have id 0. If not, modify the program so that semid=0 when 
the call to semctl with IPC_SET is made.
3) Run ipcs -s to confirm the permissions and ownership.
4) Start up Apache.
5) Run ipcs -s to see that the permissions and ownership of semaphore 0 have 

Expected Results:  Apache should not be "stomping" over an existing semaphore.

Additional info:

#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>

#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
	/* union semun is defined by including <sys/sem.h> */
	/* according to X/OPEN we have to define it ourselves */
union semun {
	int val;                  /* value for SETVAL */
	struct semid_ds *buf;     /* buffer for IPC_STAT, IPC_SET */
	unsigned short *array;    /* array for GETALL, SETALL */
	/* Linux specific part: */
	struct seminfo *__buf;    /* buffer for IPC_INFO */

int main(int argc, char *argv[])
		int semid;
		char c;
		union semun arg;
		struct semid_ds buf;

		semid = semget(IPC_PRIVATE, 1, IPC_CREAT | 0666);

		buf.sem_perm.uid = 100;
		buf.sem_perm.gid = 11;
		arg.buf = &buf;
		semctl(semid,1, IPC_SET, arg);

//		semctl(semid, 1, IPC_RMID);


Comment 1 Joe Orton 2002-12-03 04:51:15 EST

*** This bug has been marked as a duplicate of 74496 ***

Note You need to log in before you can comment on or make changes to this bug.