title: Python access denied to mmap file created by local system
body: <p>I'm trying to access a memory mapped file created by SYSTEM from another user.
  I'm running a windows service using a python frozen exe. the service is run as local SYSTEM. In the service I create a mmap file (using python mmap module)
  I later create another process under a logged in user, and try to access the mmap file, but get an</p>
  
  <blockquote>
    <p>WindowsError: [Error 5] Access is denied</p>
  </blockquote>
  
  <p>I was able to simplify the problem to the following:</p>
  
  <p>Run python as local system using </p>
  
  <pre><code>PsExec.exe -i -s -d python
  </code></pre>
  
  <p>create a memory mapped file - </p>
  
  <pre><code>mmap_file = mmap.mmap(-1, 1024, tagname='Global\\test', access=mmap.ACCESS_WRITE)
  </code></pre>
  
  <p>Now, open a python console from the user cmd (just run python)
  and try to open the same mmap file using </p>
  
  <pre><code>mmap_file = mmap.mmap(-1, 1024, tagname='Global\\test', access=mmap.ACCESS_WRITE)
  </code></pre>
  
  <p>again, the same </p>
  
  <blockquote>
    <p>WindowsError: [Error 5] Access is denied</p>
  </blockquote>
  
  <p>The code works if I just run it from two different python consoles running as the same user.</p>
  
  <p>How can I change the permissions on the mmap file so it can be accessed by users other than SYSTEM?</p>
  
  <p>Using python 2.7.10 Windows 7</p>
  
  <p>The actual code I'm using in the service to run the process</p>
  
  <pre><code>appName = 'script.exe'
  commandLine = 'script.exe'
  session_id = 1 
  security_token = win32ts.WTSQueryUserToken(session_id)
  processAttributes = None
  threadAttributes = None
  bInheritHandles = 0
  dwCreationFlags = win32process.DETACHED_PROCESS 
  newEnvironment = None 
  currentDirectory = None
  startupinfo = win32process.STARTUPINFO()
  startupinfo.lpDesktop = "winsta0\default"
  process = win32process.CreateProcessAsUser(security_token, appName , commandLine , processAttributes , threadAttributes , bInheritHandles , dwCreationFlags , newEnvironment , currentDirectory , startupinfo )
  </code></pre>