1 karl 1.45 //%2004////////////////////////////////////////////////////////////////////////
|
2 mike 1.13 //
|
3 karl 1.45 // 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 karl 1.35 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.45 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 mike 1.13 //
10 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
11 mike 1.14 // of this software and associated documentation files (the "Software"), to
12 // deal in the Software without restriction, including without limitation the
13 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
14 mike 1.13 // sell copies of the Software, and to permit persons to whom the Software is
15 // furnished to do so, subject to the following conditions:
|
16 karl 1.45 //
|
17 mike 1.14 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
18 mike 1.13 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
19 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
20 mike 1.14 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
23 mike 1.13 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 //
26 //==============================================================================
27 //
28 // Author: Mike Brasher (mbrasher@bmc.com)
29 //
|
30 r.kieninger 1.44 // Modified By:
|
31 mike 1.15 // Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)
|
32 mike 1.13 //
|
33 david 1.32 // Modified By: Dave Rosckes (rosckes@us.ibm.com)
|
34 r.kieninger 1.44 // Robert Kieninger, IBM (kieningr@de.ibm.com) for Bug#667
|
35 david 1.32 //
|
36 mike 1.13 //%/////////////////////////////////////////////////////////////////////////////
37
38 #ifndef Pegasus_System_h
39 #define Pegasus_System_h
40
41 #include <Pegasus/Common/Config.h>
42 #include <Pegasus/Common/String.h>
|
43 kumpf 1.26 #include <Pegasus/Common/Linkage.h>
|
44 david 1.32 #include <Pegasus/Common/Logger.h>
|
45 kumpf 1.36 #include <sys/stat.h>
|
46 mike 1.13
|
47 kumpf 1.37
|
48 kumpf 1.38 #if defined(PEGASUS_OS_TYPE_WINDOWS)
|
49 kumpf 1.37 #ifndef mode_t
|
50 kumpf 1.38 typedef unsigned long mode_t;
|
51 kumpf 1.37 #endif
52 #endif
53
|
54 konrad.r 1.41
|
55 kumpf 1.17 //
56 // Protocal Type
57 //
58 #define TCP "tcp"
59
|
60 mike 1.13 PEGASUS_NAMESPACE_BEGIN
61
|
62 kumpf 1.23
|
63 mike 1.13 /** This is an opaque type which is used to represent dynamic library
64 handles returned by the System::loadDynamicLibrary() method and
65 accepted by the System::loadDynamicProcedure() method.
66 */
67 typedef struct DynamicLibraryHandle_* DynamicLibraryHandle;
68
69 /** This is an opaque type which is returned by System::loadDynamicSymbol().
70 Values of this type may be casted to the appropriate target type.
71 */
|
72 kv.le 1.43 #if !defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && !defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM) && !defined(PEGASUS_PLATFORM_AIX_RS_IBMCXX)
|
73 r.kieninger 1.44 typedef struct DynamicSymbolHandle_* DynamicSymbolHandle;
74 #else
75 extern "C" {typedef int (* DynamicSymbolHandle)(void);}
76 #endif
|
77 sage 1.20
|
78 mike 1.14
|
79 david 1.32
|
80 mike 1.13 /** The System class defines wrappers for operating system related calls.
81 These are only placed here if they are extremely light. These are
82 usually just direct wrappers which map more or less one to one to the
83 underlying function.
84 */
85 class PEGASUS_COMMON_LINKAGE System
86 {
87 public:
88 /** getCurrentTime - Gets the current time as seconds and milliseconds
89 into the provided variables using system functions.
90 @param seconds Return for the seconds component of the time.
91 @param milliseconds Return for the milliseconds component of the time.
92 @return The value is returned in the parameters.
93 The time returned is as defined in number of seconds and milliseconds
94 since 00:00 Coordinated Universal Time (UTC), January 1, 1970,
|
95 mike 1.14
|
96 mike 1.13 */
97 static void getCurrentTime(Uint32& seconds, Uint32& milliseconds);
98
99 /** getCurrentASCIITime Gets time/date in a fixed format. The format is
100 YY MM DD-HH:MM:SS
|
101 marek 1.45.2.2 @return Returns String with the ASCII time date.
|
102 mike 1.13 */
103 static String getCurrentASCIITime();
104
105 static void sleep(Uint32 seconds);
106
107 static Boolean exists(const char* path);
108
109 static Boolean canRead(const char* path);
110
111 static Boolean canWrite(const char* path);
112
113 static Boolean getCurrentDirectory(char* path, Uint32 size);
114
115 static Boolean isDirectory(const char* path);
116
117 static Boolean changeDirectory(const char* path);
118
119 static Boolean makeDirectory(const char* path);
120
121 static Boolean getFileSize(const char* path, Uint32& size);
122
123 mike 1.13 static Boolean removeDirectory(const char* path);
124
125 static Boolean removeFile(const char* path);
126
127 static Boolean renameFile(const char* oldPath, const char* newPath);
128
|
129 mike 1.21 static Boolean copyFile(const char* fromPath, const char* toPath);
130
|
131 konrad.r 1.33 /** Unix issue:<br><br><b>RTLD_<bah></b> issue. Currently Pegasus uses RTLD_NOW during
|
132 marek 1.45.2.2 loading of the library if supported by OS. Previous to 2.2, Pegasus used RTLD_GLOBAL on Linux
133 - that behaviour is now deprecated.
|
134 konrad.r 1.33 */
|
135 mike 1.13 static DynamicLibraryHandle loadDynamicLibrary(const char* fileName);
136
|
137 mike 1.15 static void unloadDynamicLibrary(DynamicLibraryHandle libraryHandle);
|
138 mike 1.14
|
139 mike 1.13 static String dynamicLoadError(void);
140
141 static DynamicSymbolHandle loadDynamicSymbol(
|
142 marek 1.45.2.2 DynamicLibraryHandle libraryHandle,
143 const char* symbolName);
|
144 mike 1.13
145 static String getHostName();
|
146 kumpf 1.22 static String getFullyQualifiedHostName ();
147 static String getSystemCreationClassName ();
|
148 kumpf 1.17
|
149 r.kieninger 1.44 static Uint32 _acquireIP(const char* hostname);
150
|
151 kumpf 1.17 static Uint32 lookupPort(
152 const char * serviceName,
153 Uint32 defaultPort);
|
154 mike 1.14
|
155 kumpf 1.24 static String getEffectiveUserName();
|
156 mike 1.14
157 /**
158 This function is used to input a password with echo disabled.
159 The function reads up to a newline and returns a password of at most
160 8 characters.
161
162 @param prompt String containing the message prompt to be displayed
163 @return password obtained from the user
164 */
165 static String getPassword(const char* prompt);
166
167 /**
|
168 r.kieninger 1.44 This function is used to encrypt the user's password.
|
169 mike 1.14 The encryption is compatible with Apache's password file (generated using
170 the htpasswd command )
171
172 @param password Password to be encrypted.
173 @param salt Two character string chosen from the set [a-zA-Z0-9./].
174
175 @return Encrypted password.
176 */
177 static String encryptPassword(const char* password, const char* salt);
178
179 /**
|
180 r.kieninger 1.44 This function is used to verify whether specified user is a user
|
181 mike 1.14 on the local system.
182
183 @param userName User name to be verified.
184
185 @return true if the username is valid, else false
186 */
|
187 kumpf 1.28 static Boolean isSystemUser(const char* userName);
|
188 mike 1.14
189 /**
|
190 kumpf 1.24 Checks whether the given user is a privileged user.
|
191 mike 1.14
|
192 kumpf 1.18 @param userName User name to be checked.
193 @return true if the user is a privileged user, else false
|
194 mike 1.14 */
|
195 kumpf 1.24 static Boolean isPrivilegedUser(const String userName);
|
196 mike 1.14
|
197 kumpf 1.16 /**
|
198 kumpf 1.19 This function returns the privileged user name on the system.
199
200 @return the privileged user name
201 */
202 static String getPrivilegedUserName();
203
204 /**
|
205 kumpf 1.39 This function is used to verify whether the specified user is a member
206 of the specified user group.
207
208 @param userName User name to be verified.
209
210 @param groupName User group name.
211
212 @return true if the user is a member of the user group,
213 false otherwise.
214
215 @throw InternalSystemError - If there is an error
216 accessing the specified user or group information.
217 */
218 static Boolean isGroupMember(const char* userName, const char* groupName);
219
220 /**
|
221 kumpf 1.16 This function is used to get the process ID of the calling process.
222
223 @return Process ID
224 */
225 static Uint32 getPID();
226
|
227 mike 1.21 static Boolean truncateFile(const char* path, size_t newSize);
|
228 kumpf 1.23
|
229 kumpf 1.29 /** Compare two strings but ignore any case differences.
230 This method is provided only because some platforms lack a strcasecmp
231 function in the standard library.
232 */
233 static Sint32 strcasecmp(const char* s1, const char* s2);
|
234 r.kieninger 1.44
|
235 tony 1.30 /** Return just the file or directory name from the path into basename.
236 This method returns a file or directory name at the end of a path.
237 The path can be relative or absolute. If the path is the root,
|
238 r.kieninger 1.44 then empty string is returned.
|
239 tony 1.30 */
|
240 kumpf 1.31 static char *extract_file_name(const char *fullpath, char *basename);
|
241 tony 1.30
242 /** Return just the pathname into dirname. The fullpath can be relative
243 or absolute. This method returns a path minus the file or
244 directory name at the end of a supplied path (fullpath).
245 If the fullpath is the root, then fullpath is returned.
246 The resulting path will contain a trailing slash unless fullpath is
247 a file or directory name, in which case, just the file or directory
|
248 r.kieninger 1.44 name is returned.
|
249 tony 1.30 */
|
250 kumpf 1.31 static char *extract_file_path(const char *fullpath, char *dirname);
|
251 tony 1.30
252 // Is absolute path?
|
253 kumpf 1.31 static Boolean is_absolute_path(const char *path);
|
254 kumpf 1.36
255 /** Changes file permissions on the given file.
256 @param path path of the file.
|
257 r.kieninger 1.44 @param mode the bit-wise inclusive OR of the values for the desired
|
258 kumpf 1.36 permissions.
259 @return true on success, false on error and errno is set appropriately.
260 */
261 static Boolean changeFilePermissions(const char* path, mode_t mode);
|
262 kumpf 1.29
|
263 kumpf 1.40 /**
264 Flag indicating whether shared libraries are loaded with the
265 BIND_VERBOSE option.
266
267 THIS FLAG IS USED ON HP-UX ONLY.
268 */
|
269 kumpf 1.23 static Boolean bindVerbose;
|
270 david 1.32
271 /** This function is an abstraction for the openlog interface used in the Logger
272 class. Each platform intending to use system logs should support this interface
273 */
274 static void openlog(const String);
275
276 /** This function is an abstraction for the syslog interface used in the Logger
277 class. Each platform intending to use system logs should support this interface
278 */
279 static void syslog(Uint32, const char *);
280
281 /** This function is an abstraction for the closelog interface used in the Logger
282 class. Each platform intending to use system logs should support this interface
283 */
284 static void closelog();
285
286 // System ID constants for Logger::put and Logger::trace
287 static const String CIMSERVER;
|
288 tony 1.34
289 // System ID constants for Logger::put and Logger::trace
290 static const String CIMLISTENER;
|
291 mike 1.13 };
292
293 PEGASUS_NAMESPACE_END
294
295 #endif /* Pegasus_System_h */
|