getting permission denied with shmat() as non-root

2011-08-27 Thread Timothy Stotts
I am writing software that will execute on a customized Debian Linux and
also on an embedded POSIX system. On the embedded system, I execute the
code as root. On the Debian system, I execute the code as my non-root
user account. This is the normal usage of the application.

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. The embedded system does not have shm_open(),
otherwise I would use that.

/proc/config.gz reveals that SYSVIPC is indeed compiled into the Linux
kernel of the Debian system.

How can I diagnose the program on the Debian system?
I read on the Internet that this may have something to do with Linux
Capabilities settings?



-- 
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/1314492281.1835.12.camel@pedahzur



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

2011-08-29 Thread Timothy Stotts
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 . 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 
> 
> 



-- 
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/1314656509.2359.5.camel@pedahzur