This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: shmget() returns xx if current user is not a administrator

On Oct 12 11:09, patrick ficheux wrote:
> In SANE (scanner project), the backend for snapscan failed to call shmget() 
> with error EACCES (Permission denied) if the current user isn't 
> administrator.
> When I'am logged as windows administrator, shmget() is called successfully
> In both case, the env. variable CYGWIN exists and this value is 
> CYGWIN=server
> cygserver is installed and runs
> Is it possible to call shmget() without administrator's privileges ?
> In this case, what kind of privileges a user must have ? and how to set 
> those privileges ?
> Thanks
> extract from snapscan backend
> #ifndef SHM_R
> #define SHM_R 0
> #endif
> #ifndef SHM_W
> #define SHM_W 0
> #endif

This is the problem.  SHM_R and SHM_W are not defined on Cygwin.
These flags are not defined by POSIX and relying on them as above is
non-portable.  As a result, you create a shared mem region with
permission bits set to 000.

>    int shm_id = shmget (IPC_PRIVATE, shm_size, IPC_CREAT | SHM_R | SHM_W);

Try something like

     #include <sys/stat.h>
     int shm_id = shmget (IPC_PRIVATE, shm_size, IPC_CREAT | S_IRWXU);



Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]