|
Home > Archive > Unix Programming > May 2006 > shared memory problem
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
shared memory problem
|
|
| joaquin.hmarquez@gmail.com 2006-05-24, 7:16 pm |
| Hi,
Is it posible for a user _who is not the creator_ of a shared memory
segment delete it ?
For creating, the user A executes:
int iIpckey = 676767;
int shm_id = shmget( iIpckey, 100, IPC_CREAT | 0666);
I verify that it works with:
> ipcs
m 2229122 0x000a539f --rw-rw-rw- un4567 sytef
ok, and then, the user B tries to delete it with :
struct shmid_ds shm_desc;
int iIpckey = 676767;
int shm_id = shmget( iIpckey, 100, IPC_CREAT | 0666);
shmctl(shm_id, IPC_RMID, &shm_desc);
but it doesn't work (i think because user B is not the creator).
Can someone help me, please ?
Thanks in advance.
PS : I am working on AIX 5.3 and... sorry for my english :-)
| |
|
| joaquin.hmarquez@gmail.com wrote:
> Hi,
>
> Is it posible for a user _who is not the creator_ of a shared memory
> segment delete it ?
>
> For creating, the user A executes:
>
> int iIpckey = 676767;
> int shm_id = shmget( iIpckey, 100, IPC_CREAT | 0666);
>
> I verify that it works with:
>
> m 2229122 0x000a539f --rw-rw-rw- un4567 sytef
>
> ok, and then, the user B tries to delete it with :
>
> struct shmid_ds shm_desc;
> int iIpckey = 676767;
> int shm_id = shmget( iIpckey, 100, IPC_CREAT | 0666);
#include <errno.h>
if (shm_id == -) {
fprintf(stderr, "error = %d (%s)\n", errno, strerror(errno);
exit (1);
}
> shmctl(shm_id, IPC_RMID, &shm_desc);
>
> but it doesn't work (i think because user B is not the creator).
>
> Can someone help me, please ?
> Thanks in advance.
>
> PS : I am working on AIX 5.3 and... sorry for my english :-)
HTH,
AvK
| |
| Michael Kerrisk 2006-05-24, 7:16 pm |
| Joaquin,
>Is it posible for a user _who is not the creator_ of a shared memory
>segment delete it ?
To do an IPC_RMID, the calling process must either be privileged, or
have an effective UID matching either the owner or the creator UID of
the object.
(The owner is initially the same as the creator, but this can be
changed using shmctl(IPC_SET):
struct shmid_ds shmds;
shmctl(id, IPC_STAT, &shmds) /* Retrieve copy from kernel */
shmds.shm_perm.uid = newuid; /* Change owner UID field */
shmctl(id, IPC_SET, &shmds) /* Update kernel copy */
)
>PS : I am working on AIX 5.3
The above rule for IPC_RMID is the norm on most Unix systems.
> and... sorry for my english :-)
It worked fine for me ;-).
M
|
|
|
|
|