delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/10/12/05:31:18

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Fri, 12 Oct 2007 11:30:46 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: shmget() returns xx if current user is not a administrator
Message-ID: <20071012093046.GF20400@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <470F39C7 DOT 2010006 AT prologue DOT fr>
MIME-Version: 1.0
In-Reply-To: <470F39C7.2010006@prologue.fr>
User-Agent: Mutt/1.5.16 (2007-06-09)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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

instead.


Corinna

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

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019