(2) Samba 3.0: profiling not working under Solaris
Pierre Belanger
pbelang1 at oss.cantel.rogers.com
Mon Jul 7 11:30:13 GMT 2003
After a few sip of coffee, I forgot to remove a check I made
when I first wrote this patch back in january, that I decided
to change last Friday and so on...
I still haven't received a copy of my previous message, I'm starting
to wonder if messages with an attached file are filtered?
Sorry,
Pierre B.
-------------- next part --------------
--- source/profile/profile.c.orig Mon Jul 7 06:47:23 2003
+++ source/profile/profile.c Mon Jul 7 07:08:15 2003
@@ -106,24 +106,38 @@
/* try to use an existing key */
shm_id = shmget(PROF_SHMEM_KEY, 0, 0);
- /* if that failed then create one. There is a race condition here
- if we are running from inetd. Bad luck. */
+ /* if that failed then create one. */
if (shm_id == -1) {
+
+ static BOOL redo = True;
+
if (read_only) return False;
shm_id = shmget(PROF_SHMEM_KEY, sizeof(*profile_h),
IPC_CREAT | IPC_EXCL | IPC_PERMS);
- }
-
- if (shm_id == -1) {
- DEBUG(0,("Can't create or use IPC area. Error was %s\n",
- strerror(errno)));
- return False;
+
+ if (shm_id == -1) {
+
+ /* Check if we might have run into a race condition when running
+ from inetd. Bad luck. */
+ if ((errno == EEXIST) && (redo == True)) {
+
+ /* Make sure we don't spin forever - prevent OS bug */
+ redo = False;
+ DEBUG(0,("Can't create or use IPC area. Error was %s\n",
+ strerror(errno)));
+ DEBUG(0,("Trying again to use IPC area.\n"));
+ goto again;
+ } else {
+ DEBUG(0,("Can't create or use IPC area. Error was %s\n",
+ strerror(errno)));
+ return False;
+ }
+ }
}
-
profile_h = (struct profile_header *)shmat(shm_id, 0,
read_only?SHM_RDONLY:0);
- if ((long)profile_p == -1) {
+ if ((long)profile_h == -1) {
DEBUG(0,("Can't attach to IPC area. Error was %s\n",
strerror(errno)));
return False;
@@ -136,8 +150,9 @@
return False;
}
- if (shm_ds.shm_perm.cuid != sec_initial_uid() || shm_ds.shm_perm.cgid != sec_initial_gid()) {
- DEBUG(0,("ERROR: we did not create the shmem (owned by another user)\n"));
+ if (shm_ds.shm_perm.cuid != getuid() ||
+ shm_ds.shm_perm.cgid != getgid()) {
+ DEBUG(0,("ERROR: we did not create the shmem (owned by uid/gid = %d/%d)\n", shm_ds.shm_perm.cuid, shm_ds.shm_perm.cgid));
return False;
}
More information about the samba-technical
mailing list