1 karl 1.12 //%2006////////////////////////////////////////////////////////////////////////
|
2 konrad.r 1.2 //
|
3 karl 1.5 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 konrad.r 1.2 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.5 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.7 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.12 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 konrad.r 1.2 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
20 //
21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34 konrad.r 1.2
35 ///////////////////////////////////////////////////////////////////////////////
|
36 kumpf 1.15 //
|
37 konrad.r 1.2 // This file has implementation for the providerDir property owner class.
38 //
39 ///////////////////////////////////////////////////////////////////////////////
40
41 #include <Pegasus/Common/Config.h>
42 #include <Pegasus/Common/Tracer.h>
43 #include <Pegasus/Common/FileSystem.h>
44 #include <Pegasus/Config/ConfigManager.h>
45 #include "ProviderDirPropertyOwner.h"
46
47
48 PEGASUS_NAMESPACE_BEGIN
49
50 ///////////////////////////////////////////////////////////////////////////////
51 // ProviderDirPropertyOwner
52 //
53 // When a new ProviderDir property is added, make sure to add the property name
54 // and the default attributes of that property in the table below.
55 ///////////////////////////////////////////////////////////////////////////////
56
57 static struct ConfigPropertyRow properties[] =
58 konrad.r 1.2 {
|
59 a.dunfey 1.16 #if defined(PEGASUS_OS_TYPE_WINDOWS)
|
60 konrad.r 1.6 {"providerDir", "lib;bin", IS_STATIC, 0, 0, IS_VISIBLE},
|
61 marek 1.11 #elif defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
62 {"providerDir", "lib:provider", IS_STATIC, 0, 0, IS_VISIBLE},
|
63 gs.keenan 1.13 #elif defined(PEGASUS_OS_VMS)
|
64 carson.hovey 1.17 {"providerDir", "/wbem_lib", IS_STATIC, 0, 0, IS_VISIBLE},
|
65 konrad.r 1.3 #else
|
66 konrad.r 1.6 {"providerDir", "lib", IS_STATIC, 0, 0, IS_VISIBLE},
|
67 konrad.r 1.3 #endif
|
68 konrad.r 1.2 };
69
70 const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
71
72
73 /** Constructors */
74 ProviderDirPropertyOwner::ProviderDirPropertyOwner()
75 {
76 _providerDir = new ConfigProperty;
77 }
78
79 /** Destructor */
80 ProviderDirPropertyOwner::~ProviderDirPropertyOwner()
81 {
82 delete _providerDir;
83 }
84
85 /**
|
86 kumpf 1.15 Checks if the given directory is existing and writable
|
87 konrad.r 1.2 */
88 Boolean isProviderDirValid(const String& dirName)
89 {
|
90 marek 1.14 String path;
91 Uint32 pos=0;
92 Uint32 token=0;
93
94 // make multiple, relative paths absolute for check
95 String temp = ConfigManager::getHomedPath(dirName);
96 do
97 {
98 if (( pos = temp.find(FileSystem::getPathDelimiter())) == PEG_NOT_FOUND)
99 {
100 pos = temp.size();
101 token = 0;
|
102 kumpf 1.15 }
103 else
|
104 marek 1.14 {
105 token = 1;
106 }
107 path = temp.subString(0,pos);
108 if (!FileSystem::isDirectory(path))
109 {
110 Logger::put_l(Logger::ERROR_LOG,System::CIMSERVER,
111 Logger::SEVERE,
112 "$0 is not a directory!",
113 path);
114 return false;
115 }
116 if (!FileSystem::canRead(path))
117 {
118 Logger::put_l(Logger::ERROR_LOG,System::CIMSERVER,
119 Logger::SEVERE,
120 "Cannot $0 is not readable!",
121 path);
122 return false;
123 }
124 #ifndef PEGASUS_OS_ZOS
125 marek 1.14 if (FileSystem::canWrite(path))
126 {
127 Logger::put_l(Logger::ERROR_LOG,System::CIMSERVER,
128 Logger::WARNING,
129 "$0 is writeable! Possible security risk.",
130 path);
131 }
|
132 marek 1.11 #endif
|
133 kumpf 1.15 temp.remove(0,pos+token);
|
134 marek 1.14 }
|
135 kumpf 1.15 while ( temp.size() > 0 );
|
136 konrad.r 1.2 return true;
137 }
|
138 kumpf 1.15
|
139 konrad.r 1.2 /**
|
140 kumpf 1.15 Initialize the config properties.
|
141 konrad.r 1.2 */
142 void ProviderDirPropertyOwner::initialize()
143 {
144 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
145 {
146 //
147 // Initialize the properties with default values
148 //
149 if (String::equalNoCase(properties[i].propertyName, "providerDir"
150 ))
151 {
152 _providerDir->propertyName = properties[i].propertyName;
153 _providerDir->defaultValue = properties[i].defaultValue;
154 _providerDir->currentValue = properties[i].defaultValue;
155 _providerDir->plannedValue = properties[i].defaultValue;
156 _providerDir->dynamic = properties[i].dynamic;
157 _providerDir->domain = properties[i].domain;
158 _providerDir->domainSize = properties[i].domainSize;
159 _providerDir->externallyVisible = properties[i].externallyVisible;
160 }
161 }
162 konrad.r 1.2 }
163
164 struct ConfigProperty* ProviderDirPropertyOwner::_lookupConfigProperty(
|
165 aruran.ms 1.10 const String& name) const
|
166 konrad.r 1.2 {
167 if (String::equalNoCase(_providerDir->propertyName, name))
168 {
169 return _providerDir;
170 }
171 else
172 {
173 throw UnrecognizedConfigProperty(name);
174 }
175 }
176
|
177 kumpf 1.15 /**
178 Get information about the specified property.
|
179 konrad.r 1.2 */
180 void ProviderDirPropertyOwner::getPropertyInfo(
|
181 kumpf 1.15 const String& name,
|
182 vijay.eli 1.9 Array<String>& propertyInfo) const
|
183 konrad.r 1.2 {
184 propertyInfo.clear();
|
185 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
186 konrad.r 1.2
187 propertyInfo.append(configProperty->propertyName);
188 propertyInfo.append(configProperty->defaultValue);
189 propertyInfo.append(configProperty->currentValue);
190 propertyInfo.append(configProperty->plannedValue);
191 if (configProperty->dynamic)
192 {
193 propertyInfo.append(STRING_TRUE);
194 }
195 else
196 {
197 propertyInfo.append(STRING_FALSE);
198 }
199 if (configProperty->externallyVisible)
200 {
201 propertyInfo.append(STRING_TRUE);
202 }
203 else
204 {
205 propertyInfo.append(STRING_FALSE);
206 }
207 konrad.r 1.2 }
208
209
210 /**
|
211 kumpf 1.15 Get default value of the specified property.
|
212 konrad.r 1.2 */
|
213 vijay.eli 1.9 String ProviderDirPropertyOwner::getDefaultValue(const String& name) const
|
214 konrad.r 1.2 {
|
215 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
216 vijay.eli 1.9
|
217 konrad.r 1.2 return configProperty->defaultValue;
218 }
219
|
220 kumpf 1.15 /**
221 Get current value of the specified property.
|
222 konrad.r 1.2 */
|
223 vijay.eli 1.9 String ProviderDirPropertyOwner::getCurrentValue(const String& name) const
|
224 konrad.r 1.2 {
|
225 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
226 vijay.eli 1.9
|
227 konrad.r 1.2 return configProperty->currentValue;
228 }
229
|
230 kumpf 1.15 /**
231 Get planned value of the specified property.
|
232 konrad.r 1.2 */
|
233 vijay.eli 1.9 String ProviderDirPropertyOwner::getPlannedValue(const String& name) const
|
234 konrad.r 1.2 {
|
235 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
236 vijay.eli 1.9
|
237 konrad.r 1.2 return configProperty->plannedValue;
238 }
239
|
240 kumpf 1.15 /**
241 Init current value of the specified property to the specified value.
|
242 konrad.r 1.2 */
243 void ProviderDirPropertyOwner::initCurrentValue(
|
244 kumpf 1.15 const String& name,
|
245 konrad.r 1.2 const String& value)
246 {
247 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
248 configProperty->currentValue = value;
249 }
250
251
|
252 kumpf 1.15 /**
253 Init planned value of the specified property to the specified value.
|
254 konrad.r 1.2 */
255 void ProviderDirPropertyOwner::initPlannedValue(
|
256 kumpf 1.15 const String& name,
|
257 konrad.r 1.2 const String& value)
258 {
259 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
260 configProperty->plannedValue = value;
261 }
262
|
263 kumpf 1.15 /**
264 Update current value of the specified property to the specified value.
|
265 konrad.r 1.2 */
266 void ProviderDirPropertyOwner::updateCurrentValue(
|
267 kumpf 1.15 const String& name,
268 const String& value)
|
269 konrad.r 1.2 {
270 //
271 // make sure the property is dynamic before updating the value.
272 //
273 if (!isDynamic(name))
274 {
|
275 kumpf 1.15 throw NonDynamicConfigProperty(name);
|
276 konrad.r 1.2 }
277
278 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
279 configProperty->currentValue = value;
280 }
281
282
|
283 kumpf 1.15 /**
284 Update planned value of the specified property to the specified value.
|
285 konrad.r 1.2 */
286 void ProviderDirPropertyOwner::updatePlannedValue(
|
287 kumpf 1.15 const String& name,
|
288 konrad.r 1.2 const String& value)
289 {
290 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
291 configProperty->plannedValue = value;
292 }
293
|
294 kumpf 1.15 /**
295 Checks to see if the given value is valid or not.
|
296 konrad.r 1.2 */
|
297 kumpf 1.15 Boolean ProviderDirPropertyOwner::isValid(
298 const String& name,
299 const String& value) const
|
300 konrad.r 1.2 {
301
302 if (!isProviderDirValid( value ))
303 {
304 throw InvalidPropertyValue(name, value);
305 }
|
306 kumpf 1.15
|
307 konrad.r 1.2 return true;
308 }
309
|
310 kumpf 1.15 /**
311 Checks to see if the specified property is dynamic or not.
|
312 konrad.r 1.2 */
|
313 vijay.eli 1.9 Boolean ProviderDirPropertyOwner::isDynamic(const String& name) const
|
314 konrad.r 1.2 {
|
315 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
316 vijay.eli 1.9
|
317 kumpf 1.15 return (configProperty->dynamic == IS_DYNAMIC);
|
318 konrad.r 1.2 }
319
320
321 PEGASUS_NAMESPACE_END
|