[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: getting permission denied with shmat() as non-root

Thanks Peter. That was the tip I needed for debugging the program on the
Debian system. ipcs(1), when run as the same user as the program, did
not show any shared memory being created. However, running ipcs(1) as
root showed the memory being created by the non-root user with
permissions of 0000. Obviously, it should be 0660 or something similar,
so I corrected the issue by or'ing the permissions with the create flags
as the last argument to the function shmget(). Cheers.

Timothy Stotts

On Sun, 2011-08-28 at 21:11 +1000, Peter Miller wrote:
> On Sat, 2011-08-27 at 20:44 -0400, Timothy Stotts wrote:
> > I am using ftok(), shmget(), shmat() to obtain a small quantity of
> > shared memory for the application. As root, the shmat() function
> > succeeds on the embedded system. However, on the Debian system the
> > shmat() function returns -1 with an error code of EACCES, indicating
> > permission denied.
> This means that the shared memory exists, or you would get EINVAL.
> The ipcs command may be used to list information about shared memory,
> and other ipc facilities.  Try using ipcs(1) to see if there is a an
> owner and/or permissions mismatch for the shmid you are using.
> -- 
> Peter Miller <pmiller@opensource.org.au>

Reply to: