Как разрешить IIS APPPOOL \ DefaultAppPool записывать в точку монтирования C: \ inetpub \ wwwroot - PullRequest
0 голосов
/ 22 января 2019

Я создаю новую композицию Windows Docker, которая использует образ microsoft / aspnet: 4.6.2 .Я использую том для c: \ inetpub \ wwwroot , который сопоставлен с C: \ site \ Default на хост-сервере.

Работающий ASP.Сетевой файл успешно извлекает файлы, но файлы при создании / записи файлов.Я получаю следующее исключение: System.IO.IOException: 'Trying to write to forbidden path: C:\inetpub\WWWRoot\agenda.css.'

Я попробовал следующее:

  • Установить полный доступ для всех к C: \ site \ Default на хост-сервере

  • Добавить все права, используя icacls (см. файл docker ниже).Вот вывод для (Get-acl c:\inetpub\wwwroot\).Access:

    FileSystemRights  : FullControl
    AccessControlType : Allow
    IdentityReference : Everyone
    IsInherited       : False
    InheritanceFlags  : ContainerInherit, ObjectInherit
    PropagationFlags  : None
    
    FileSystemRights  : ReadAndExecute, Synchronize
    AccessControlType : Allow
    IdentityReference : BUILTIN\IIS_IUSRS
    IsInherited       : False
    InheritanceFlags  : None
    PropagationFlags  : None
    
    FileSystemRights  : -1610612736
    AccessControlType : Allow
    IdentityReference : BUILTIN\IIS_IUSRS
    IsInherited       : False
    InheritanceFlags  : ContainerInherit, ObjectInherit
    PropagationFlags  : InheritOnly
    
    FileSystemRights  : FullControl
    AccessControlType : Allow
    IdentityReference : IIS APPPOOL\DefaultAppPool
    IsInherited       : False
    InheritanceFlags  : ContainerInherit, ObjectInherit
    PropagationFlags  : None
    
    FileSystemRights  : FullControl
    AccessControlType : Allow
    IdentityReference : NT SERVICE\TrustedInstaller
    IsInherited       : True
    InheritanceFlags  : None
    PropagationFlags  : None
    
    FileSystemRights  : 268435456
    AccessControlType : Allow
    IdentityReference : NT SERVICE\TrustedInstaller
    IsInherited       : True
    InheritanceFlags  : ContainerInherit, ObjectInherit
    PropagationFlags  : InheritOnly
    
    FileSystemRights  : FullControl
    AccessControlType : Allow
    IdentityReference : NT AUTHORITY\SYSTEM
    IsInherited       : True
    InheritanceFlags  : None
    PropagationFlags  : None
    
    FileSystemRights  : 268435456
    AccessControlType : Allow
    IdentityReference : NT AUTHORITY\SYSTEM
    IsInherited       : True
    InheritanceFlags  : ContainerInherit, ObjectInherit
    PropagationFlags  : InheritOnly
    
    FileSystemRights  : FullControl
    AccessControlType : Allow
    IdentityReference : BUILTIN\Administrators
    IsInherited       : True
    InheritanceFlags  : None
    PropagationFlags  : None
    
    FileSystemRights  : 268435456
    AccessControlType : Allow
    IdentityReference : BUILTIN\Administrators
    IsInherited       : True
    InheritanceFlags  : ContainerInherit, ObjectInherit
    PropagationFlags  : InheritOnly
    
    FileSystemRights  : ReadAndExecute, Synchronize
    AccessControlType : Allow
    IdentityReference : BUILTIN\Users
    IsInherited       : True
    InheritanceFlags  : None
    PropagationFlags  : None
    
    FileSystemRights  : -1610612736
    AccessControlType : Allow
    IdentityReference : BUILTIN\Users
    IsInherited       : True
    InheritanceFlags  : ContainerInherit, ObjectInherit
    PropagationFlags  : InheritOnly
    
    FileSystemRights  : 268435456
    AccessControlType : Allow
    IdentityReference : CREATOR OWNER
    IsInherited       : True
    InheritanceFlags  : ContainerInherit, ObjectInherit
    PropagationFlags  : InheritOnly
    
  • Я использовал ProcMon на хост-сервере и не смог увидеть ни одной записи при попытке записать файл

Файлы Docker

docker-compose:

services:
  core:
    image: core
    build:
      context: .
      dockerfile: ./core/dockerfile
    volumes:
      - C:/site/Default/:c:/inetpub/wwwroot:rw
    ports:
      - "8000:80"
      - "4020-4024:4020-4024"
    environment:
      DatabaseType: SqlServer
      ConnectionString: Server=sqldata;User ID=sa;Password=pAssword123;Database=Default;MultipleActiveResultSets=True
    depends_on:
      - sqldata

  sqldata:
    ...

dockerfile:

FROM microsoft/aspnet:4.6.2

# Also tried the bellow command with /l
RUN icacls --% "C:\inetpub\wwwroot" /grant Everyone:(OI)(CI)F /t

1 Ответ

0 голосов
/ 06 февраля 2019

По некоторым причинам IUSR имеет права на запись в любое место в папках контейнера (отображается или нет), кроме C:\inetpub\wwwroot.IIS предотвращает запись в этот конкретный путь.

Я закончил тем, что создал приложение, которое использует другой физический путь из файла Docker, и теперь все работает как ожидалось:

FROM microsoft/aspnet:4.6.2

RUN C:\Windows\system32\inetsrv\appcmd.exe set app \"Default Web Site/\" /physicalPath:C:\SomeOtherMountPoint
...