1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
#include "precomp.h"
// sql queries
static LPCWSTR vcsWebDirQuery7 = L"SELECT `Web_`, `WebDir`, `Component_`, `Path`, `DirProperties_`, `Application_`"
L"FROM `Wix4IIsWebDir`";
enum eWebDirQuery { wdqWeb = 1, wdqWebDir, wdqComponent , wdqPath, wdqProperties, wdqApplication, wdqInstalled, wdqAction };
// prototypes
static HRESULT AddWebDirToList(SCA_WEBDIR7** ppswdList);
UINT __stdcall ScaWebDirsRead7(
__in SCA_WEB7* pswList,
__in WCA_WRAPQUERY_HANDLE hUserQuery,
__in WCA_WRAPQUERY_HANDLE /*hWebBaseQuery*/,
__in WCA_WRAPQUERY_HANDLE hWebDirPropQuery,
__in WCA_WRAPQUERY_HANDLE hWebAppQuery,
__in WCA_WRAPQUERY_HANDLE hWebAppExtQuery,
__inout LPWSTR *ppwzCustomActionData,
__out SCA_WEBDIR7** ppswdList
)
{
HRESULT hr = S_OK;
MSIHANDLE hRec;
LPWSTR pwzData = NULL;
SCA_WEBDIR7* pswd;
WCA_WRAPQUERY_HANDLE hWrapQuery = NULL;
hr = WcaBeginUnwrapQuery(&hWrapQuery, ppwzCustomActionData);
ExitOnFailure(hr, "Failed to unwrap query for ScaWebDirsRead7");
if (0 == WcaGetQueryRecords(hWrapQuery))
{
WcaLog(LOGMSG_VERBOSE, "Skipping ScaInstallWebDirs7() because IIsWebDir table not present");
ExitFunction1(hr = S_FALSE);
}
// loop through all the web directories
while (S_OK == (hr = WcaFetchWrappedRecord(hWrapQuery, &hRec)))
{
hr = AddWebDirToList(ppswdList);
ExitOnFailure(hr, "failed to add web dir to list");
pswd = *ppswdList;
ExitOnNull(pswd, hr, E_INVALIDARG, "No web dir provided");
// get component install state
hr = WcaGetRecordString(hRec, wdqComponent, &pwzData);
ExitOnFailure(hr, "Failed to get Component for WebDirs");
hr = ::StringCchCopyW(pswd->wzComponent, countof(pswd->wzComponent), pwzData);
ExitOnFailure(hr, "Failed to copy component string to webdir object");
hr = WcaGetRecordInteger(hRec, wdqInstalled, (int *)&pswd->isInstalled);
ExitOnFailure(hr, "Failed to get Component installed state for webdir");
hr = WcaGetRecordInteger(hRec, wdqAction, (int *)&pswd->isAction);
ExitOnFailure(hr, "Failed to get Component action state for webdir");
hr = WcaGetRecordString(hRec, wdqWeb, &pwzData);
ExitOnFailure(hr, "Failed to get Web for WebDir");
// get the web key
hr = ScaWebsGetBase7(pswList, pwzData, pswd->wzWebSite, countof(pswd->wzWebSite));
if (S_FALSE == hr)
{
hr = HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
ExitOnFailure(hr, "Failed to get base of web for WebDir");
}
ExitOnFailure(hr, "Failed to format webdir root string");
hr = WcaGetRecordString(hRec, wdqPath, &pwzData);
ExitOnFailure(hr, "Failed to get Path for WebDir");
hr = ::StringCchCopyW(pswd->wzPath, countof(pswd->wzPath), pwzData);
ExitOnFailure(hr, "Failed to copy path for WebDir");
// get the directory properties for this web
hr = WcaGetRecordString(hRec, wdqProperties, &pwzData);
ExitOnFailure(hr, "Failed to get security identifier for WebDir");
if (*pwzData)
{
hr = ScaGetWebDirProperties(pwzData, hUserQuery, hWebDirPropQuery, &pswd->swp);
ExitOnFailure(hr, "Failed to get properties for WebDir");
pswd->fHasProperties = TRUE;
}
// get the application information for this web directory
hr = WcaGetRecordString(hRec, wdqApplication, &pwzData);
ExitOnFailure(hr, "Failed to get application identifier for WebDir");
if (*pwzData)
{
hr = ScaGetWebApplication(NULL, pwzData, hWebAppQuery, hWebAppExtQuery, &pswd->swapp);
ExitOnFailure(hr, "Failed to get application for WebDir");
pswd->fHasApplication = TRUE;
}
}
if (E_NOMOREITEMS == hr)
{
hr = S_OK;
}
ExitOnFailure(hr, "Failure while processing WebDirs");
LExit:
WcaFinishUnwrapQuery(hWrapQuery);
ReleaseStr(pwzData);
return hr;
}
HRESULT ScaWebDirsInstall7(SCA_WEBDIR7* pswdList, SCA_APPPOOL * psapList)
{
HRESULT hr = S_OK;
SCA_WEBDIR7* pswd = pswdList;
while (pswd)
{
// if we are installing the web site
if (WcaIsInstalling(pswd->isInstalled, pswd->isAction))
{
hr = ScaWriteConfigID(IIS_WEBDIR);
ExitOnFailure(hr, "Failed to write WebDir ID");
hr = ScaWriteConfigID(IIS_CREATE);
ExitOnFailure(hr, "Failed to write WebDir action ID");
hr = ScaWriteConfigString(pswd->wzWebSite);
ExitOnFailure(hr, "Failed to write WebDir site");
hr = ScaWriteConfigString(pswd->wzPath);
ExitOnFailure(hr, "Failed to write WebDir path");
// get the security information for this web
if (pswd->fHasProperties)
{
ScaWriteWebDirProperties7(pswd->wzWebSite, pswd->wzPath, &pswd->swp);
ExitOnFailure(hr, "Failed to write properties for WebDir");
}
// get the application information for this web directory
if (pswd->fHasApplication)
{
hr = ScaWriteWebApplication7(pswd->wzWebSite, pswd->wzPath, &pswd->swapp, psapList);
ExitOnFailure(hr, "Failed to write application for WebDir");
}
}
pswd = pswd->pswdNext;
}
LExit:
return hr;
}
HRESULT ScaWebDirsUninstall7(SCA_WEBDIR7* pswdList)
{
HRESULT hr = S_OK;
SCA_WEBDIR7* pswd = pswdList;
while (pswd)
{
if (WcaIsUninstalling(pswd->isInstalled, pswd->isAction))
{
hr = ScaWriteConfigID(IIS_WEBDIR);
ExitOnFailure(hr, "Failed to write WebDir ID");
hr = ScaWriteConfigID(IIS_DELETE);
ExitOnFailure(hr, "Failed to write WebDir action ID");
hr = ScaWriteConfigString(pswd->wzWebSite);
ExitOnFailure(hr, "Failed to write WebDir site");
hr = ScaWriteConfigString(pswd->wzPath);
ExitOnFailure(hr, "Failed to write WebDir path");
}
pswd = pswd->pswdNext;
}
LExit:
return hr;
}
void ScaWebDirsFreeList7(SCA_WEBDIR7* pswdList)
{
SCA_WEBDIR7* pswdDelete = pswdList;
while (pswdList)
{
pswdDelete = pswdList;
pswdList = pswdList->pswdNext;
MemFree(pswdDelete);
}
}
static HRESULT AddWebDirToList(SCA_WEBDIR7** ppswdList)
{
HRESULT hr = S_OK;
SCA_WEBDIR7* pswd = static_cast<SCA_WEBDIR7*>(MemAlloc(sizeof(SCA_WEBDIR7), TRUE));
ExitOnNull(pswd, hr, E_OUTOFMEMORY, "failed to allocate element for web dir list");
pswd->pswdNext = *ppswdList;
*ppswdList = pswd;
LExit:
return hr;
}
|