shared memory problem
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > shared memory problem




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    shared memory problem  
joaquin.hmarquez@gmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-25-06 12:16 AM

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 :-)






[ Post a follow-up to this message ]



    Re: shared memory problem  
moi


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-25-06 12:16 AM

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





[ Post a follow-up to this message ]



    Re: shared memory problem  
Michael Kerrisk


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-25-06 12:16 AM

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





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 10:40 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register