echo off
rem 2.02.  version fixing Q00739421 - SSL Doesn't work on CallPilot 2.0 - Cannot Log in to CallPilot Manager
rem called from PermFix_standalone.vbs
rem parameters:
rem %1 web anonymous users group
rem %2 root of web folders  :\InetPub
rem %3 autoaddfilespath :\InetPub\wwwroot\cpmgr\AutoAddFiles
rem %4 upload path :\InetPub\wwwroot\cpmgr\Upload
rem %5 SSLPath :\InetPub\wwwroot\cpmgr\SSL
rem %6 OptionsPath :\InetPub\wwwroot\cpmgr\Preferences\Options

title PermFix
echo Adjusting permissions on folders for standalone CallPilot Manager, please wait ...

rem Create a file to answer Yes to a prompt from the cacls command
mkdir c:\temp >NUL 2>NUL
echo Y>C:\temp\yesfile.txt"

rem To allow SSL downloading of certificate, we currently need to be able to execute cmd.exe
cacls %WINDIR%\System32\cmd.exe /E /G %1:R >NUL

rem To allow IIS logging, give anonymous users change access to IIS www log folder
cacls %WINDIR%\System32\LogFiles\W3SVC1 /T /E /P %1:C >NUL

rem Now tighten up access to web folders
cacls %2 /T /P Administrators:F <C:\temp\yesfile.txt >NUL 2>NUL
cacls %2 /T /E /G System:F >NUL 2>NUL
cacls %2 /T /E /G Everyone:R >NUL 2>NUL

rem Now relax restrictions as necessary for certain CallPilot features to work
cacls %3 /T /E /P %1:C >NUL 2>NUL
cacls %4 /T /E /P %1:C >NUL 2>NUL
cacls %5 /T /E /P Everyone:F>NUL 2>NUL
cacls %5 /T /E /P %1:F >NUL 2>NUL
cacls %6 /T /E /P %1:C >NUL 2>NUL

rem Delete temp file
del C:\temp\yesfile.txt >NUL 2>NUL

rem removing the certificates 
RMDIR /S /Q %5\Certificates  >NUL 2>NUL
