Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

shared memory problem
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 :-)


Report this thread to moderator Post Follow-up to this message
Old Post
joaquin.hmarquez@gmail.com
05-25-06 12:04 AM


Re: shared memory problem
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

Report this thread to moderator Post Follow-up to this message
Old Post
moi
05-25-06 12:04 AM


Re: shared memory problem
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

Report this thread to moderator Post Follow-up to this message
Old Post
Michael Kerrisk
05-25-06 12:04 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:19 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.