00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00035 #include "OW_config.h"
00036 #ifdef OW_THREADS_RUN_AS_USER
00037
00038 #include "OW_ProviderProxies.hpp"
00039 #include "OW_ProviderEnvironmentIFC.hpp"
00040 #include "OW_CIMValue.hpp"
00041 #include "OW_Logger.hpp"
00042 #include "OW_CIMClass.hpp"
00043 #include "OW_CIMInstance.hpp"
00044 #include "OW_CIMObjectPath.hpp"
00045 #include "OW_RepositoryIFC.hpp"
00046 #include "OW_OperationContext.hpp"
00047 #include "OW_CIMOMHandleIFC.hpp"
00048 #include "OW_CIMProperty.hpp"
00049 #include "OW_CIMQualifierType.hpp"
00050 #include "OW_CIMQualifierEnumeration.hpp"
00051 #include "OW_CIMQualifier.hpp"
00052 #include "OW_CIMMethod.hpp"
00053 #include "OW_CIMParameter.hpp"
00054 #include "OW_CIMFeatures.hpp"
00055
00056 #ifdef OW_GNU_LINUX
00057 #ifdef OW_HAVE_PWD_H
00058 #include <pwd.h>
00059 #endif
00060 #ifdef OW_HAVE_UNISTD_H
00061 #include <unistd.h>
00062 #endif
00063 #ifdef OW_HAVE_SYS_TYPES_H
00064 #include <sys/types.h>
00065 #endif
00066 #endif
00067
00068 namespace OW_NAMESPACE
00069 {
00070
00071 using namespace WBEMFlags;
00072
00073 #if defined(OW_GNU_LINUX)
00074 #define RUID_MANAGER_FACTORY RUIDManager um(m_cimomuid, m_useruid)
00075 #define UID_MANAGER_FACTORY UIDManager um(m_useruid, m_cimomuid)
00076 #define PROXY_ENV_FACTORY proxyEnv(env, m_cimomuid, m_useruid)
00077 #elif defined(OW_NETWARE)
00078 #define RUID_MANAGER_FACTORY RUIDManager um(m_nwi)
00079 #define UID_MANAGER_FACTORY UIDManager um(m_nwi)
00080 #define PROXY_ENV_FACTORY proxyEnv(env, m_nwi)
00081 #endif
00082
00083 namespace
00084 {
00085 #if defined (OW_GNU_LINUX)
00086 class UIDManager
00087 {
00088 public:
00089 UIDManager(uid_t tempUid, uid_t resetUid)
00090 : m_resetUid(resetUid)
00091 , m_uidsDiffer(tempUid != resetUid)
00092 {
00093 if (m_uidsDiffer)
00094 {
00095 ::seteuid(tempUid);
00096 }
00097 }
00098
00099 ~UIDManager()
00100 {
00101 if (m_uidsDiffer)
00102 {
00103 ::setuid(m_resetUid);
00104 }
00105 }
00106
00107 private:
00108 uid_t m_resetUid;
00109 bool m_uidsDiffer;
00110 };
00111
00112 class RUIDManager
00113 {
00114 public:
00115 RUIDManager(uid_t tempUid, uid_t resetUid)
00116 : m_resetUid(resetUid)
00117 , m_uidsDiffer(tempUid != resetUid)
00118 {
00119 if (m_uidsDiffer)
00120 {
00121 ::setuid(tempUid);
00122 }
00123 }
00124
00125 ~RUIDManager()
00126 {
00127 if (m_uidsDiffer)
00128 {
00129 ::seteuid(m_resetUid);
00130 }
00131 }
00132
00133 private:
00134 uid_t m_resetUid;
00135 bool m_uidsDiffer;
00136 };
00137 #elif defined (OW_NETWARE)
00138 class UIDManager
00139 {
00140 public:
00141 UIDManager(NetwareIdentityRef nwi)
00142 : m_nwi(nwi)
00143 {
00144 if(m_nwi)
00145 {
00146 m_nwi->setContextToUser();
00147 }
00148 }
00149
00150 ~UIDManager()
00151 {
00152 if(m_nwi)
00153 {
00154 m_nwi->setContextToAdmin();
00155 }
00156 }
00157
00158 private:
00159 NetwareIdentityRef m_nwi;
00160 };
00161
00162 class RUIDManager
00163 {
00164 public:
00165 RUIDManager(NetwareIdentityRef nwi)
00166 : m_nwi(nwi)
00167 {
00168 if (m_nwi)
00169 {
00170 m_nwi->setContextToAdmin();
00171 }
00172 }
00173
00174 ~RUIDManager()
00175 {
00176 if (m_nwi)
00177 {
00178 m_nwi->setContextToUser();
00179 }
00180 }
00181
00182 private:
00183 NetwareIdentityRef m_nwi;
00184 };
00185 #endif
00186
00187
00188 class ProxyCIMOMHandle : public CIMOMHandleIFC
00189 {
00190 public:
00191
00192 #if defined(OW_GNU_LINUX)
00193 ProxyCIMOMHandle(CIMOMHandleIFCRef ch, uid_t cimomuid, uid_t useruid)
00194 : CIMOMHandleIFC()
00195 , m_ch(ch)
00196 , m_cimomuid(cimomuid)
00197 , m_useruid(useruid)
00198 #elif defined (OW_NETWARE)
00199 ProxyCIMOMHandle(CIMOMHandleIFCRef ch, NetwareIdentityRef nwi)
00200 : CIMOMHandleIFC()
00201 , m_ch(ch)
00202 , m_nwi(nwi)
00203 #endif
00204 {
00205 }
00206
00207 virtual void close()
00208 {
00209 RUID_MANAGER_FACTORY;
00210 m_ch->close();
00211 }
00212
00213 virtual void enumClass(const String& ns, const String& className,
00214 CIMClassResultHandlerIFC& result, EDeepFlag deep,
00215 ELocalOnlyFlag localOnly, EIncludeQualifiersFlag includeQualifiers,
00216 EIncludeClassOriginFlag includeClassOrigin)
00217 {
00218 RUID_MANAGER_FACTORY;
00219 m_ch->enumClass(ns, className, result, deep, localOnly,
00220 includeQualifiers, includeClassOrigin);
00221 }
00222
00223 virtual void enumClassNames(const String& ns, const String& className,
00224 StringResultHandlerIFC& result, EDeepFlag deep)
00225 {
00226 RUID_MANAGER_FACTORY;
00227 m_ch->enumClassNames(ns, className, result, deep);
00228 }
00229
00230 virtual void enumInstances(const String& ns,
00231 const String& className, CIMInstanceResultHandlerIFC& result,
00232 EDeepFlag deep, ELocalOnlyFlag localOnly,
00233 EIncludeQualifiersFlag includeQualifiers,
00234 EIncludeClassOriginFlag includeClassOrigin,
00235 const StringArray* propertyList)
00236 {
00237 RUID_MANAGER_FACTORY;
00238 m_ch->enumInstances(ns, className, result, deep, localOnly,
00239 includeQualifiers, includeClassOrigin, propertyList);
00240 }
00241
00242 virtual void enumInstanceNames(const String& ns,
00243 const String& className, CIMObjectPathResultHandlerIFC& result)
00244 {
00245 RUID_MANAGER_FACTORY;
00246 m_ch->enumInstanceNames(ns, className, result);
00247 }
00248
00249 virtual CIMClass getClass(const String& ns, const String& className,
00250 ELocalOnlyFlag localOnly, EIncludeQualifiersFlag includeQualifiers,
00251 EIncludeClassOriginFlag includeClassOrigin,
00252 const StringArray* propertyList)
00253 {
00254 RUID_MANAGER_FACTORY;
00255 return m_ch->getClass(ns, className, localOnly,
00256 includeQualifiers, includeClassOrigin, propertyList);
00257 }
00258
00259 virtual CIMInstance getInstance(const String& ns,
00260 const CIMObjectPath& instanceName, ELocalOnlyFlag localOnly,
00261 EIncludeQualifiersFlag includeQualifiers,
00262 EIncludeClassOriginFlag includeClassOrigin,
00263 const StringArray* propertyList)
00264 {
00265 RUID_MANAGER_FACTORY;
00266 return m_ch->getInstance(ns, instanceName, localOnly,
00267 includeQualifiers, includeClassOrigin, propertyList);
00268 }
00269
00270 virtual CIMValue invokeMethod(const String& ns,
00271 const CIMObjectPath& path, const String& methodName,
00272 const CIMParamValueArray& inParams, CIMParamValueArray& outParams)
00273 {
00274 RUID_MANAGER_FACTORY;
00275 return m_ch->invokeMethod(ns, path, methodName, inParams,
00276 outParams);
00277 }
00278
00279 virtual CIMQualifierType getQualifierType(const String& ns,
00280 const String& qualifierName)
00281 {
00282 RUID_MANAGER_FACTORY;
00283 return m_ch->getQualifierType(ns, qualifierName);
00284 }
00285
00286 #ifndef OW_DISABLE_QUALIFIER_DECLARATION
00287
00288 virtual void setQualifierType(const String& ns,
00289 const CIMQualifierType& qualifierType)
00290 {
00291 RUID_MANAGER_FACTORY;
00292 m_ch->setQualifierType(ns, qualifierType);
00293 }
00294
00295 virtual void deleteQualifierType(const String& ns,
00296 const String& qualName)
00297 {
00298 RUID_MANAGER_FACTORY;
00299 m_ch->deleteQualifierType(ns, qualName);
00300 }
00301
00302 virtual void enumQualifierTypes(const String& ns,
00303 CIMQualifierTypeResultHandlerIFC& result)
00304 {
00305 RUID_MANAGER_FACTORY;
00306 m_ch->enumQualifierTypes(ns, result);
00307 }
00308
00309 virtual CIMQualifierTypeEnumeration enumQualifierTypesE(
00310 const String& ns)
00311 {
00312 RUID_MANAGER_FACTORY;
00313 return m_ch->enumQualifierTypesE(ns);
00314 }
00315
00316 virtual CIMQualifierTypeArray enumQualifierTypesA(const String& ns)
00317 {
00318 RUID_MANAGER_FACTORY;
00319 return m_ch->enumQualifierTypesA(ns);
00320 }
00321
00322 #endif // #ifndef OW_DISABLE_QUALIFIER_DECLARATION
00323
00324 #ifndef OW_DISABLE_SCHEMA_MANIPULATION
00325
00326 virtual void modifyClass(const String& ns, const CIMClass& cimClass)
00327 {
00328 RUID_MANAGER_FACTORY;
00329 m_ch->modifyClass(ns, cimClass);
00330 }
00331
00332 virtual void createClass(const String& ns, const CIMClass& cimClass)
00333 {
00334 RUID_MANAGER_FACTORY;
00335 m_ch->createClass(ns, cimClass);
00336 }
00337
00338 virtual void deleteClass(const String& ns, const String& className)
00339 {
00340 RUID_MANAGER_FACTORY;
00341 m_ch->deleteClass(ns, className);
00342 }
00343
00344 #endif // #ifndef OW_DISABLE_SCHEMA_MANIPULATION
00345
00346 #ifndef OW_DISABLE_INSTANCE_MANIPULATION
00347
00348 virtual void modifyInstance(const String& ns,
00349 const CIMInstance& modifiedInstance,
00350 EIncludeQualifiersFlag includeQualifiers,
00351 const StringArray* propertyList)
00352 {
00353 RUID_MANAGER_FACTORY;
00354 m_ch->modifyInstance(ns, modifiedInstance, includeQualifiers,
00355 propertyList);
00356 }
00357
00358 virtual CIMObjectPath createInstance(const String& ns,
00359 const CIMInstance& instance)
00360 {
00361 RUID_MANAGER_FACTORY;
00362 return m_ch->createInstance(ns, instance);
00363 }
00364
00365 virtual void deleteInstance(const String& ns,
00366 const CIMObjectPath& path)
00367 {
00368 RUID_MANAGER_FACTORY;
00369 m_ch->deleteInstance(ns, path);
00370 }
00371
00372 #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00373 virtual void setProperty(const String& ns,
00374 const CIMObjectPath& instanceName, const String& propertyName,
00375 const CIMValue& newValue)
00376 {
00377 RUID_MANAGER_FACTORY;
00378 m_ch->setProperty(ns, instanceName, propertyName, newValue);
00379 }
00380 #endif // #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00381
00382
00383 #endif // #ifndef OW_DISABLE_INSTANCE_MANIPULATION
00384
00385 #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00386 virtual CIMValue getProperty(const String& ns,
00387 const CIMObjectPath& instanceName, const String& propertyName)
00388 {
00389 RUID_MANAGER_FACTORY;
00390 return m_ch->getProperty(ns, instanceName, propertyName);
00391 }
00392 #endif // #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00393
00394 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00395
00396 virtual void associatorNames(const String& ns,
00397 const CIMObjectPath& objectName,
00398 CIMObjectPathResultHandlerIFC& result, const String& assocClass,
00399 const String& resultClass, const String& role,
00400 const String& resultRole)
00401 {
00402 RUID_MANAGER_FACTORY;
00403 m_ch->associatorNames(ns, objectName, result, assocClass,
00404 resultClass, role, resultRole);
00405 }
00406
00407 virtual void associators(const String& ns,
00408 const CIMObjectPath& path, CIMInstanceResultHandlerIFC& result,
00409 const String& assocClass,
00410 const String& resultClass,
00411 const String& role,
00412 const String& resultRole,
00413 EIncludeQualifiersFlag includeQualifiers,
00414 EIncludeClassOriginFlag includeClassOrigin,
00415 const StringArray* propertyList)
00416 {
00417 RUID_MANAGER_FACTORY;
00418 m_ch->associators(ns, path, result, assocClass, resultClass,
00419 role, resultRole, includeQualifiers, includeClassOrigin,
00420 propertyList);
00421 }
00422
00423 virtual void associatorsClasses(const String& ns,
00424 const CIMObjectPath& path, CIMClassResultHandlerIFC& result,
00425 const String& assocClass, const String& resultClass,
00426 const String& role, const String& resultRole,
00427 EIncludeQualifiersFlag includeQualifiers,
00428 EIncludeClassOriginFlag includeClassOrigin,
00429 const StringArray* propertyList)
00430 {
00431 RUID_MANAGER_FACTORY;
00432 m_ch->associatorsClasses(ns, path, result, assocClass, resultClass,
00433 role, resultRole, includeQualifiers, includeClassOrigin,
00434 propertyList);
00435 }
00436
00437 virtual void referenceNames(const String& ns, const CIMObjectPath& path,
00438 CIMObjectPathResultHandlerIFC& result, const String& resultClass,
00439 const String& role)
00440 {
00441 RUID_MANAGER_FACTORY;
00442 m_ch->referenceNames(ns, path, result, resultClass, role);
00443 }
00444
00445 virtual void references(const String& ns, const CIMObjectPath& path,
00446 CIMInstanceResultHandlerIFC& result, const String& resultClass,
00447 const String& role, EIncludeQualifiersFlag includeQualifiers,
00448 EIncludeClassOriginFlag includeClassOrigin,
00449 const StringArray* propertyList)
00450 {
00451 RUID_MANAGER_FACTORY;
00452 m_ch->references(ns, path, result, resultClass, role,
00453 includeQualifiers, includeClassOrigin, propertyList);
00454 }
00455
00456 virtual void referencesClasses(const String& ns,
00457 const CIMObjectPath& path, CIMClassResultHandlerIFC& result,
00458 const String& resultClass, const String& role,
00459 EIncludeQualifiersFlag includeQualifiers,
00460 EIncludeClassOriginFlag includeClassOrigin,
00461 const StringArray* propertyList)
00462 {
00463 RUID_MANAGER_FACTORY;
00464 m_ch->referencesClasses(ns, path, result, resultClass, role,
00465 includeQualifiers, includeClassOrigin, propertyList);
00466 }
00467
00468 #endif // #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00469
00470 virtual void execQuery(const String& ns,
00471 CIMInstanceResultHandlerIFC& result, const String& query,
00472 const String& queryLanguage)
00473 {
00474 RUID_MANAGER_FACTORY;
00475 m_ch->execQuery(ns, result, query, queryLanguage);
00476 }
00477
00478 virtual CIMFeatures getServerFeatures()
00479 {
00480 RUID_MANAGER_FACTORY;
00481 return m_ch->getServerFeatures();
00482 }
00483
00484 virtual void exportIndication(const CIMInstance& instance,
00485 const String& instNS)
00486 {
00487 RUID_MANAGER_FACTORY;
00488 m_ch->exportIndication(instance, instNS);
00489 }
00490
00491 private:
00492
00493 CIMOMHandleIFCRef m_ch;
00494 #if defined (OW_GNU_LINUX)
00495 uid_t m_cimomuid;
00496 uid_t m_useruid;
00497 #elif defined (OW_NETWARE)
00498 NetwareIdentityRef m_nwi;
00499 #endif
00500 };
00501
00502
00503 class ProxyRepository : public RepositoryIFC
00504 {
00505 public:
00506 #if defined (OW_GNU_LINUX)
00507 ProxyRepository(RepositoryIFCRef prep, uid_t cimomuid, uid_t useruid)
00508 : RepositoryIFC()
00509 , m_prep(prep)
00510 , m_cimomuid(cimomuid)
00511 , m_useruid(useruid)
00512 #elif defined (OW_NETWARE)
00513 ProxyRepository(RepositoryIFCRef prep, NetwareIdentityRef nwi)
00514 : RepositoryIFC()
00515 , m_prep(prep)
00516 , m_nwi(nwi)
00517 #endif
00518 {
00519 }
00520
00521 virtual void open(const String &path)
00522 {
00523 RUID_MANAGER_FACTORY;
00524 m_prep->open(path);
00525 }
00526 virtual void close()
00527 {
00528 RUID_MANAGER_FACTORY;
00529 m_prep->close();
00530 }
00531 virtual void init(const ServiceEnvironmentIFCRef& env)
00532 {
00533 m_prep->init(env);
00534 }
00535 virtual void shutdown()
00536 {
00537 m_prep->shutdown();
00538 }
00539 virtual ServiceEnvironmentIFCRef getEnvironment() const
00540 {
00541
00542 return ServiceEnvironmentIFCRef(0);
00543 }
00544 #if !defined(OW_DISABLE_INSTANCE_MANIPULATION) && !defined(OW_DISABLE_NAMESPACE_MANIPULATION)
00545 virtual void createNameSpace(const String &ns,
00546 OperationContext &context)
00547 {
00548 RUID_MANAGER_FACTORY;
00549 m_prep->createNameSpace(ns, context);
00550 }
00551 virtual void deleteNameSpace(const String &ns,
00552 OperationContext &context)
00553 {
00554 RUID_MANAGER_FACTORY;
00555 m_prep->deleteNameSpace(ns, context);
00556 }
00557 #endif
00558
00559 #ifndef OW_DISABLE_QUALIFIER_DECLARATION
00560 virtual void enumQualifierTypes(const String &ns,
00561 CIMQualifierTypeResultHandlerIFC &result, OperationContext &context)
00562 {
00563 RUID_MANAGER_FACTORY;
00564 m_prep->enumQualifierTypes(ns, result, context);
00565 }
00566 virtual void deleteQualifierType(const String &ns,
00567 const String &qualName, OperationContext &context)
00568 {
00569 RUID_MANAGER_FACTORY;
00570 m_prep->deleteQualifierType(ns, qualName, context);
00571 }
00572 virtual void setQualifierType(const String &ns,
00573 const CIMQualifierType &qt, OperationContext &context)
00574 {
00575 RUID_MANAGER_FACTORY;
00576 m_prep->setQualifierType(ns, qt, context);
00577 }
00578 #endif
00579
00580 virtual void enumNameSpace(StringResultHandlerIFC &result,
00581 OperationContext &context)
00582 {
00583 RUID_MANAGER_FACTORY;
00584 m_prep->enumNameSpace(result, context);
00585
00586 }
00587 virtual CIMQualifierType getQualifierType(const String &ns,
00588 const String &qualifierName, OperationContext &context)
00589 {
00590 RUID_MANAGER_FACTORY;
00591 return m_prep->getQualifierType(ns, qualifierName, context);
00592 }
00593 #ifndef OW_DISABLE_SCHEMA_MANIPULATION
00594 virtual CIMClass deleteClass(const String &ns, const String &className,
00595 OperationContext &context)
00596 {
00597 RUID_MANAGER_FACTORY;
00598 return m_prep->deleteClass(ns, className, context);
00599 }
00600 virtual void createClass(const String &ns, const CIMClass &cimClass,
00601 OperationContext &context)
00602 {
00603 RUID_MANAGER_FACTORY;
00604 m_prep->createClass(ns, cimClass, context);
00605 }
00606 virtual CIMClass modifyClass(const String &ns, const CIMClass &cc,
00607 OperationContext &context)
00608 {
00609 RUID_MANAGER_FACTORY;
00610 return m_prep->modifyClass(ns, cc, context);
00611 }
00612 #endif
00613
00614 virtual CIMClass getClass(const String &ns, const String &className,
00615 ELocalOnlyFlag localOnly,
00616 EIncludeQualifiersFlag includeQualifiers,
00617 EIncludeClassOriginFlag includeClassOrigin,
00618 const StringArray *propertyList, OperationContext &context)
00619 {
00620 RUID_MANAGER_FACTORY;
00621 return m_prep->getClass(ns, className, localOnly,
00622 includeQualifiers, includeClassOrigin, propertyList, context);
00623 }
00624 virtual void enumClassNames(const String &ns, const String &className,
00625 StringResultHandlerIFC &result, EDeepFlag deep,
00626 OperationContext &context)
00627 {
00628 RUID_MANAGER_FACTORY;
00629 m_prep->enumClassNames(ns, className, result, deep, context);
00630 }
00631 virtual void enumInstances(const String &ns, const String &className,
00632 CIMInstanceResultHandlerIFC &result, EDeepFlag deep,
00633 ELocalOnlyFlag localOnly,
00634 EIncludeQualifiersFlag includeQualifiers,
00635 EIncludeClassOriginFlag includeClassOrigin,
00636 const StringArray *propertyList,
00637 EEnumSubclassesFlag enumSubclasses,
00638 OperationContext &context)
00639 {
00640 RUID_MANAGER_FACTORY;
00641 m_prep->enumInstances(ns, className, result, deep, localOnly,
00642 includeQualifiers, includeClassOrigin, propertyList,
00643 enumSubclasses, context);
00644 }
00645 virtual void enumClasses(const String &ns, const String &className,
00646 CIMClassResultHandlerIFC &result, EDeepFlag deep,
00647 ELocalOnlyFlag localOnly,
00648 EIncludeQualifiersFlag includeQualifiers,
00649 EIncludeClassOriginFlag includeClassOrigin,
00650 OperationContext &context)
00651 {
00652 RUID_MANAGER_FACTORY;
00653 m_prep->enumClasses(ns, className, result, deep, localOnly,
00654 includeQualifiers, includeClassOrigin, context);
00655 }
00656 #ifndef OW_DISABLE_INSTANCE_MANIPULATION
00657 virtual CIMInstance deleteInstance(const String &ns,
00658 const CIMObjectPath &cop, OperationContext &context)
00659 {
00660 RUID_MANAGER_FACTORY;
00661 return m_prep->deleteInstance(ns, cop, context);
00662 }
00663 virtual CIMObjectPath createInstance(const String &ns,
00664 const CIMInstance &ci, OperationContext &context)
00665 {
00666 RUID_MANAGER_FACTORY;
00667 return m_prep->createInstance(ns, ci, context);
00668 }
00669 virtual CIMInstance modifyInstance(const String &ns,
00670 const CIMInstance &modifiedInstance,
00671 EIncludeQualifiersFlag includeQualifiers,
00672 const StringArray *propertyList, OperationContext &context)
00673 {
00674 RUID_MANAGER_FACTORY;
00675 return m_prep->modifyInstance(ns, modifiedInstance,
00676 includeQualifiers, propertyList, context);
00677 }
00678 #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00679 virtual void setProperty(const String &ns, const CIMObjectPath &name,
00680 const String &propertyName, const CIMValue &cv,
00681 OperationContext &context)
00682 {
00683 RUID_MANAGER_FACTORY;
00684 m_prep->setProperty(ns, name, propertyName, cv, context);
00685 }
00686 #endif // #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00687
00688 #endif
00689 virtual void enumInstanceNames(const String &ns,
00690 const String &className, CIMObjectPathResultHandlerIFC &result,
00691 EDeepFlag deep, OperationContext &context)
00692 {
00693 RUID_MANAGER_FACTORY;
00694 m_prep->enumInstanceNames(ns, className, result, deep, context);
00695 }
00696
00697 virtual CIMInstance getInstance(const String &ns,
00698 const CIMObjectPath &instanceName,
00699 ELocalOnlyFlag localOnly, EIncludeQualifiersFlag includeQualifiers,
00700 EIncludeClassOriginFlag includeClassOrigin,
00701 const StringArray *propertyList, OperationContext &context)
00702 {
00703 RUID_MANAGER_FACTORY;
00704 return m_prep->getInstance(ns, instanceName, localOnly,
00705 includeQualifiers, includeClassOrigin, propertyList, context);
00706 }
00707 #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00708 virtual CIMValue getProperty(const String &ns,
00709 const CIMObjectPath &name, const String &propertyName,
00710 OperationContext &context)
00711 {
00712 RUID_MANAGER_FACTORY;
00713 return m_prep->getProperty(ns, name, propertyName, context);
00714 }
00715 #endif // #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00716
00717 virtual CIMValue invokeMethod(const String &ns,
00718 const CIMObjectPath &path, const String &methodName,
00719 const CIMParamValueArray &inParams, CIMParamValueArray &outParams,
00720 OperationContext &context)
00721 {
00722 RUID_MANAGER_FACTORY;
00723 return m_prep->invokeMethod(ns, path, methodName, inParams,
00724 outParams, context);
00725 }
00726
00727 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00728 virtual void associatorsClasses(const String &ns,
00729 const CIMObjectPath &path, CIMClassResultHandlerIFC &result,
00730 const String &assocClass, const String &resultClass,
00731 const String &role, const String &resultRole,
00732 EIncludeQualifiersFlag includeQualifiers,
00733 EIncludeClassOriginFlag includeClassOrigin,
00734 const StringArray *propertyList, OperationContext &context)
00735 {
00736 RUID_MANAGER_FACTORY;
00737 m_prep->associatorsClasses(ns, path, result, assocClass,
00738 resultClass, role, resultRole, includeQualifiers,
00739 includeClassOrigin, propertyList, context);
00740 }
00741 virtual void referenceNames(const String &ns,
00742 const CIMObjectPath &path, CIMObjectPathResultHandlerIFC &result,
00743 const String &resultClass, const String &role,
00744 OperationContext &context)
00745 {
00746 RUID_MANAGER_FACTORY;
00747 m_prep->referenceNames(ns, path, result, resultClass, role,
00748 context);
00749 }
00750 virtual void associatorNames(const String &ns,
00751 const CIMObjectPath &path, CIMObjectPathResultHandlerIFC &result,
00752 const String &assocClass, const String &resultClass,
00753 const String &role, const String &resultRole,
00754 OperationContext &context)
00755 {
00756 RUID_MANAGER_FACTORY;
00757 m_prep->associatorNames(ns, path, result, assocClass, resultClass,
00758 role, resultRole, context);
00759 }
00760 virtual void associators(const String &ns, const CIMObjectPath &path,
00761 CIMInstanceResultHandlerIFC &result, const String &assocClass,
00762 const String &resultClass, const String &role,
00763 const String &resultRole, EIncludeQualifiersFlag includeQualifiers,
00764 EIncludeClassOriginFlag includeClassOrigin,
00765 const StringArray *propertyList, OperationContext &context)
00766 {
00767 RUID_MANAGER_FACTORY;
00768 m_prep->associators(ns, path, result, assocClass, resultClass,
00769 role, resultRole, includeQualifiers, includeClassOrigin,
00770 propertyList, context);
00771 }
00772 virtual void references(const String &ns, const CIMObjectPath &path,
00773 CIMInstanceResultHandlerIFC &result, const String &resultClass,
00774 const String &role, EIncludeQualifiersFlag includeQualifiers,
00775 EIncludeClassOriginFlag includeClassOrigin,
00776 const StringArray *propertyList, OperationContext &context)
00777 {
00778 RUID_MANAGER_FACTORY;
00779 m_prep->references(ns, path, result, resultClass, role,
00780 includeQualifiers, includeClassOrigin, propertyList, context);
00781 }
00782 virtual void referencesClasses(const String &ns,
00783 const CIMObjectPath &path, CIMClassResultHandlerIFC &result,
00784 const String &resultClass, const String &role,
00785 EIncludeQualifiersFlag includeQualifiers,
00786 EIncludeClassOriginFlag includeClassOrigin,
00787 const StringArray *propertyList, OperationContext &context)
00788 {
00789 RUID_MANAGER_FACTORY;
00790 m_prep->referencesClasses(ns, path, result, resultClass, role,
00791 includeQualifiers, includeClassOrigin, propertyList, context);
00792 }
00793 #endif
00794 virtual void execQuery(const String &ns,
00795 CIMInstanceResultHandlerIFC &result, const String &query,
00796 const String &queryLanguage, OperationContext &context)
00797 {
00798 RUID_MANAGER_FACTORY;
00799 m_prep->execQuery(ns, result, query, queryLanguage, context);
00800 }
00801 virtual void beginOperation(EOperationFlag op,
00802 OperationContext &context)
00803 {
00804 RUID_MANAGER_FACTORY;
00805 m_prep->beginOperation(op, context);
00806 }
00807 virtual void endOperation(EOperationFlag op, OperationContext &context,
00808 EOperationResultFlag result)
00809 {
00810 RUID_MANAGER_FACTORY;
00811 m_prep->endOperation(op, context, result);
00812 }
00813
00814 private:
00815
00816 RepositoryIFCRef m_prep;
00817 #if defined(OW_GNU_LINUX)
00818 uid_t m_cimomuid;
00819 uid_t m_useruid;
00820 #elif defined(OW_NETWARE)
00821 NetwareIdentityRef m_nwi;
00822 #endif
00823 };
00824
00825 class ProxyEnvironment : public ProviderEnvironmentIFC
00826 {
00827 public:
00828 #if defined(OW_GNU_LINUX)
00829 ProxyEnvironment(const ProviderEnvironmentIFCRef& env, uid_t cimomuid,
00830 uid_t useruid)
00831 : ProviderEnvironmentIFC()
00832 , m_cimomuid(cimomuid)
00833 , m_useruid(useruid)
00834 #elif defined(OW_NETWARE)
00835 ProxyEnvironment(const ProviderEnvironmentIFCRef& env, NetwareIdentityRef nwi)
00836 : ProviderEnvironmentIFC()
00837 , m_nwi(nwi)
00838 #endif
00839 , m_env(env)
00840 {}
00841
00842 virtual String getConfigItem(const String &name,
00843 const String& defRetVal="") const
00844 {
00845 return m_env->getConfigItem(name, defRetVal);
00846 }
00847 virtual StringArray getMultiConfigItem(const String &itemName,
00848 const StringArray& defRetVal, const char* tokenizeSeparator) const
00849 {
00850 return m_env->getMultiConfigItem(itemName, defRetVal, tokenizeSeparator);
00851 }
00852
00853 virtual CIMOMHandleIFCRef getCIMOMHandle() const
00854 {
00855 #if defined(OW_GNU_LINUX)
00856 return CIMOMHandleIFCRef(new ProxyCIMOMHandle(
00857 m_env->getCIMOMHandle(), m_cimomuid, m_useruid));
00858 #elif defined(OW_NETWARE)
00859 return CIMOMHandleIFCRef(new ProxyCIMOMHandle(
00860 m_env->getCIMOMHandle(), m_nwi));
00861 #endif
00862 }
00863
00864 virtual CIMOMHandleIFCRef getRepositoryCIMOMHandle() const
00865 {
00866 #if defined(OW_GNU_LINUX)
00867 return CIMOMHandleIFCRef(new ProxyCIMOMHandle(
00868 m_env->getRepositoryCIMOMHandle(), m_cimomuid, m_useruid));
00869 #elif defined(OW_NETWARE)
00870 return CIMOMHandleIFCRef(new ProxyCIMOMHandle(
00871 m_env->getRepositoryCIMOMHandle(), m_nwi));
00872 #endif
00873 }
00874
00875 virtual RepositoryIFCRef getRepository() const
00876 {
00877 #if defined(OW_GNU_LINUX)
00878 return RepositoryIFCRef(new ProxyRepository(
00879 m_env->getRepository(), m_cimomuid, m_useruid));
00880 #elif defined(OW_NETWARE)
00881 return RepositoryIFCRef(new ProxyRepository(
00882 m_env->getRepository(), m_nwi));
00883 #endif
00884 }
00885
00886 virtual LoggerRef getLogger() const
00887 {
00888 return m_env->getLogger();
00889 }
00890
00891 virtual LoggerRef getLogger(const String& componentName) const
00892 {
00893 return m_env->getLogger(componentName);
00894 }
00895
00896 virtual String getUserName() const
00897 {
00898 return m_env->getUserName();
00899 }
00900
00901 virtual OperationContext& getOperationContext()
00902 {
00903 return m_env->getOperationContext();
00904 }
00905
00906 virtual ProviderEnvironmentIFCRef clone() const
00907 {
00908
00909
00910
00911 return m_env->clone();
00912 }
00913
00914 private:
00915
00916 #if defined(OW_GNU_LINUX)
00917 uid_t m_cimomuid;
00918 uid_t m_useruid;
00919 #elif defined(OW_NETWARE)
00920 NetwareIdentityRef m_nwi;
00921 #endif
00922 ProviderEnvironmentIFCRef m_env;
00923 };
00924
00925 #if defined (OW_GNU_LINUX)
00926 void getUIDS(const ProviderEnvironmentIFCRef& env,
00927 uid_t& cimomuid, uid_t& useruid)
00928 {
00929 cimomuid = ::getuid();
00930 useruid = cimomuid;
00931
00932 String wk = env->getOperationContext().getStringDataWithDefault(
00933 OperationContext::CURUSER_UIDKEY);
00934 if (!wk.empty())
00935 {
00936 useruid = wk.toUInt32();
00937 return;
00938 }
00939 String userName = env->getUserName();
00940
00941 long pwnbufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
00942 char buf[pwnbufsize];
00943 struct passwd pw;
00944 struct passwd* ppw = 0;
00945 int rv = ::getpwnam_r(userName.c_str(), &pw, buf, pwnbufsize, &ppw);
00946 if (rv == 0 && ppw)
00947 {
00948 useruid = pw.pw_uid;
00949 }
00950 }
00951
00952 inline ProviderEnvironmentIFCRef
00953 proxyEnv(const ProviderEnvironmentIFCRef& env, uid_t cimomuid,
00954 uid_t useruid)
00955 {
00956 return ProviderEnvironmentIFCRef(new ProxyEnvironment(env, cimomuid,
00957 useruid));
00958 }
00959
00960 #elif defined(OW_NETWARE)
00961 NetwareIdentityRef getNWI(const ProviderEnvironmentIFCRef& env)
00962 {
00963 OperationContext::DataRef data = env->getOperationContext().getData(NOVELL_IDENTITY_KEY);
00964 if (data)
00965 {
00966 NetwareIdentityRef nwi = data.cast_to<NetwareIdentity>();
00967 return nwi;
00968 }
00969 return NetwareIdentityRef(0);
00970 }
00971
00972 inline ProviderEnvironmentIFCRef
00973 proxyEnv(const ProviderEnvironmentIFCRef& env, NetwareIdentityRef nwi)
00974 {
00975 return ProviderEnvironmentIFCRef(new ProxyEnvironment(env, nwi));
00976 }
00977
00978 #endif
00979
00980 }
00981
00983 InstanceProviderProxy::InstanceProviderProxy(InstanceProviderIFCRef pProv,
00984 const ProviderEnvironmentIFCRef& env)
00985 : InstanceProviderIFC()
00986 , m_pProv(pProv)
00987 #if defined(OW_GNU_LINUX)
00988 , m_cimomuid(0)
00989 , m_useruid(0)
00990 {
00991 getUIDS(env, m_cimomuid, m_useruid);
00992 #elif defined(OW_NETWARE)
00993 , m_nwi(0)
00994 {
00995 m_nwi = getNWI(env);
00996 #endif
00997 }
00998
01000 void
01001 InstanceProviderProxy::enumInstanceNames(
01002 const ProviderEnvironmentIFCRef& env,
01003 const String& ns,
01004 const String& className,
01005 CIMObjectPathResultHandlerIFC& result,
01006 const CIMClass& cimClass )
01007 {
01008 UID_MANAGER_FACTORY;
01009 m_pProv->enumInstanceNames(PROXY_ENV_FACTORY, ns,
01010 className, result, cimClass);
01011 }
01012
01014 void
01015 InstanceProviderProxy::enumInstances(
01016 const ProviderEnvironmentIFCRef& env,
01017 const String& ns,
01018 const String& className,
01019 CIMInstanceResultHandlerIFC& result,
01020 ELocalOnlyFlag localOnly,
01021 EDeepFlag deep,
01022 EIncludeQualifiersFlag includeQualifiers,
01023 EIncludeClassOriginFlag includeClassOrigin,
01024 const StringArray* propertyList,
01025 const CIMClass& requestedClass,
01026 const CIMClass& cimClass )
01027 {
01028 UID_MANAGER_FACTORY;
01029 m_pProv->enumInstances(PROXY_ENV_FACTORY, ns, className,
01030 result, localOnly, deep, includeQualifiers, includeClassOrigin,
01031 propertyList, requestedClass, cimClass);
01032 }
01033
01035 CIMInstance
01036 InstanceProviderProxy::getInstance(
01037 const ProviderEnvironmentIFCRef& env,
01038 const String& ns,
01039 const CIMObjectPath& instanceName,
01040 ELocalOnlyFlag localOnly,
01041 EIncludeQualifiersFlag includeQualifiers,
01042 EIncludeClassOriginFlag includeClassOrigin,
01043 const StringArray* propertyList,
01044 const CIMClass& cimClass )
01045 {
01046 UID_MANAGER_FACTORY;
01047 return m_pProv->getInstance(PROXY_ENV_FACTORY, ns,
01048 instanceName, localOnly, includeQualifiers, includeClassOrigin,
01049 propertyList, cimClass);
01050 }
01051
01052 #ifndef OW_DISABLE_INSTANCE_MANIPULATION
01053
01055 CIMObjectPath
01056 InstanceProviderProxy::createInstance(
01057 const ProviderEnvironmentIFCRef& env,
01058 const String& ns,
01059 const CIMInstance& cimInstance )
01060 {
01061 UID_MANAGER_FACTORY;
01062 return m_pProv->createInstance(PROXY_ENV_FACTORY, ns,
01063 cimInstance);
01064 }
01065
01067 void
01068 InstanceProviderProxy::modifyInstance(
01069 const ProviderEnvironmentIFCRef& env,
01070 const String& ns,
01071 const CIMInstance& modifiedInstance,
01072 const CIMInstance& previousInstance,
01073 EIncludeQualifiersFlag includeQualifiers,
01074 const StringArray* propertyList,
01075 const CIMClass& theClass)
01076 {
01077 UID_MANAGER_FACTORY;
01078 m_pProv->modifyInstance(PROXY_ENV_FACTORY, ns,
01079 modifiedInstance, previousInstance, includeQualifiers, propertyList,
01080 theClass);
01081 }
01082
01084 void
01085 InstanceProviderProxy::deleteInstance(
01086 const ProviderEnvironmentIFCRef& env,
01087 const String& ns,
01088 const CIMObjectPath& cop)
01089 {
01090 UID_MANAGER_FACTORY;
01091 m_pProv->deleteInstance(PROXY_ENV_FACTORY, ns, cop);
01092 }
01093
01094 #endif // #ifndef OW_DISABLE_INSTANCE_MANIPULATION
01095
01097 SecondaryInstanceProviderProxy::SecondaryInstanceProviderProxy(SecondaryInstanceProviderIFCRef pProv,
01098 const ProviderEnvironmentIFCRef& env)
01099 : SecondaryInstanceProviderIFC()
01100 , m_pProv(pProv)
01101 #if defined(OW_GNU_LINUX)
01102 , m_cimomuid(0)
01103 , m_useruid(0)
01104 {
01105 getUIDS(PROXY_ENV_FACTORY, m_cimomuid, m_useruid);
01106 #elif defined(OW_NETWARE)
01107 , m_nwi(0)
01108 {
01109 m_nwi = getNWI(PROXY_ENV_FACTORY);
01110 #endif
01111 }
01112
01114 void
01115 SecondaryInstanceProviderProxy::filterInstances(
01116 const ProviderEnvironmentIFCRef &env, const String &ns,
01117 const String &className, CIMInstanceArray &instances,
01118 ELocalOnlyFlag localOnly, EDeepFlag deep,
01119 EIncludeQualifiersFlag includeQualifiers,
01120 EIncludeClassOriginFlag includeClassOrigin,
01121 const StringArray *propertyList, const CIMClass &requestedClass,
01122 const CIMClass &cimClass)
01123 {
01124 UID_MANAGER_FACTORY;
01125 m_pProv->filterInstances(env, ns, className, instances, localOnly, deep, includeQualifiers, includeClassOrigin, propertyList, requestedClass, cimClass);
01126 }
01127
01128 #ifndef OW_DISABLE_INSTANCE_MANIPULATION
01129
01130 void
01131 SecondaryInstanceProviderProxy::createInstance(const ProviderEnvironmentIFCRef &env, const String &ns, const CIMInstance &cimInstance)
01132 {
01133 UID_MANAGER_FACTORY;
01134 m_pProv->createInstance(env, ns, cimInstance);
01135 }
01136
01138 void
01139 SecondaryInstanceProviderProxy::modifyInstance(
01140 const ProviderEnvironmentIFCRef &env, const String &ns,
01141 const CIMInstance &modifiedInstance, const CIMInstance &previousInstance,
01142 EIncludeQualifiersFlag includeQualifiers,
01143 const StringArray *propertyList, const CIMClass &theClass)
01144 {
01145 UID_MANAGER_FACTORY;
01146 m_pProv->modifyInstance(env, ns, modifiedInstance, previousInstance, includeQualifiers, propertyList, theClass);
01147 }
01148
01150 void
01151 SecondaryInstanceProviderProxy::deleteInstance(const ProviderEnvironmentIFCRef &env, const String &ns, const CIMObjectPath &cop)
01152 {
01153 UID_MANAGER_FACTORY;
01154 m_pProv->deleteInstance(env, ns, cop);
01155 }
01156 #endif // #ifndef OW_DISABLE_INSTANCE_MANIPULATION
01157
01158
01160 MethodProviderProxy::MethodProviderProxy(MethodProviderIFCRef pProv,
01161 const ProviderEnvironmentIFCRef& env)
01162 : MethodProviderIFC()
01163 , m_pProv(pProv)
01164 #if defined(OW_GNU_LINUX)
01165 , m_cimomuid(0)
01166 , m_useruid(0)
01167 {
01168 getUIDS(PROXY_ENV_FACTORY, m_cimomuid, m_useruid);
01169 #elif defined(OW_NETWARE)
01170 , m_nwi(0)
01171 {
01172 m_nwi = getNWI(PROXY_ENV_FACTORY);
01173 #endif
01174 }
01175
01177 CIMValue
01178 MethodProviderProxy::invokeMethod(
01179 const ProviderEnvironmentIFCRef& env,
01180 const String& ns,
01181 const CIMObjectPath& path,
01182 const String& methodName,
01183 const CIMParamValueArray& in,
01184 CIMParamValueArray& out )
01185 {
01186 UID_MANAGER_FACTORY;
01187 return m_pProv->invokeMethod(PROXY_ENV_FACTORY, ns,
01188 path, methodName, in, out);
01189 }
01190
01191 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
01192
01194 AssociatorProviderProxy::AssociatorProviderProxy(
01195 AssociatorProviderIFCRef pProv, const ProviderEnvironmentIFCRef& env)
01196 : AssociatorProviderIFC()
01197 , m_pProv(pProv)
01198 #if defined(OW_GNU_LINUX)
01199 , m_cimomuid(0)
01200 , m_useruid(0)
01201 {
01202 getUIDS(PROXY_ENV_FACTORY, m_cimomuid, m_useruid);
01203 #elif defined(OW_NETWARE)
01204 , m_nwi(0)
01205 {
01206 m_nwi = getNWI(PROXY_ENV_FACTORY);
01207 #endif
01208 }
01209
01211 void
01212 AssociatorProviderProxy::associators(
01213 const ProviderEnvironmentIFCRef& env,
01214 CIMInstanceResultHandlerIFC& result,
01215 const String& ns,
01216 const CIMObjectPath& objectName,
01217 const String& assocClass,
01218 const String& resultClass,
01219 const String& role,
01220 const String& resultRole,
01221 EIncludeQualifiersFlag includeQualifiers,
01222 EIncludeClassOriginFlag includeClassOrigin,
01223 const StringArray* propertyList)
01224 {
01225 UID_MANAGER_FACTORY;
01226 m_pProv->associators(PROXY_ENV_FACTORY, result, ns,
01227 objectName, assocClass, resultClass, role, resultRole,
01228 includeQualifiers, includeClassOrigin, propertyList);
01229 }
01230
01232 void
01233 AssociatorProviderProxy::associatorNames(
01234 const ProviderEnvironmentIFCRef& env,
01235 CIMObjectPathResultHandlerIFC& result,
01236 const String& ns,
01237 const CIMObjectPath& objectName,
01238 const String& assocClass,
01239 const String& resultClass,
01240 const String& role,
01241 const String& resultRole )
01242 {
01243 UID_MANAGER_FACTORY;
01244 m_pProv->associatorNames(PROXY_ENV_FACTORY, result, ns,
01245 objectName, assocClass, resultClass, role, resultRole);
01246 }
01247
01249 void
01250 AssociatorProviderProxy::references(
01251 const ProviderEnvironmentIFCRef& env,
01252 CIMInstanceResultHandlerIFC& result,
01253 const String& ns,
01254 const CIMObjectPath& objectName,
01255 const String& resultClass,
01256 const String& role,
01257 EIncludeQualifiersFlag includeQualifiers,
01258 EIncludeClassOriginFlag includeClassOrigin,
01259 const StringArray* propertyList)
01260 {
01261 UID_MANAGER_FACTORY;
01262 m_pProv->references(PROXY_ENV_FACTORY, result, ns,
01263 objectName, resultClass, role, includeQualifiers, includeClassOrigin,
01264 propertyList);
01265 }
01266
01268 void
01269 AssociatorProviderProxy::referenceNames(
01270 const ProviderEnvironmentIFCRef& env,
01271 CIMObjectPathResultHandlerIFC& result,
01272 const String& ns,
01273 const CIMObjectPath& objectName,
01274 const String& resultClass,
01275 const String& role )
01276 {
01277 UID_MANAGER_FACTORY;
01278 m_pProv->referenceNames(PROXY_ENV_FACTORY, result, ns,
01279 objectName, resultClass, role);
01280 }
01281
01282 #endif // OW_DISABLE_ASSOCIATION_TRAVERSAL
01283
01284 }
01285
01286 #endif // OW_THREADS_RUN_AS_USER
01287
01288
01289