1 mike 1.2 //%2006////////////////////////////////////////////////////////////////////////
2 //
3 // 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 // IBM Corp.; EMC Corporation, The Open Group.
7 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
11 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
13 //
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 r.kieninger 1.8 //
|
21 mike 1.2 // 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 kumpf 1.4 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
|
35 mike 1.2 # define _OPEN_SYS_EXT
36 # include <sys/ps.h>
|
37 r.kieninger 1.8 # include <sys/__messag.h>
|
38 mike 1.2 #elif defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM)
39 # include <fcntl.h>
40 # include <qycmutilu2.H>
41 # include <unistd.cleinc>
42 # include "qycmmsgclsMessage.H" // ycmMessage class
43 # include "OS400SystemState.h" // OS400LoadDynamicLibrary, etc
44 # include "EBCDIC_OS400.h"
45 #elif defined(PEGASUS_OS_VMS)
|
46 carson.hovey 1.3 # include <descrip.h> // $DESCRIPTOR
47 # include <iodef.h> // IO$_SENSEMODE
48 # include <ttdef.h> // TT$M_NOBRDCST
49 # include <tt2def.h> // TT2$M_PASTHRU
|
50 mike 1.2 # include <starlet.h>
51 #endif
52
53 #include <unistd.h>
54 #include <dirent.h>
55 #include <pwd.h>
56 #include <grp.h>
57 #include <errno.h>
58
59 #if defined(PEGASUS_OS_SOLARIS)
60 # include <string.h>
61 #endif
62
|
63 carson.hovey 1.3 #if !defined(PEGASUS_OS_VMS) && \
64 !defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && \
|
65 mike 1.2 !defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM) && \
66 !defined(PEGASUS_PLATFORM_DARWIN_PPC_GNU)
67 # include <crypt.h>
68 #endif
69
70 #include "Network.h"
71
72 #if defined(PEGASUS_USE_SYSLOGS)
73 # include <syslog.h>
74 #endif
75
76 #include <sys/stat.h>
77 #include <sys/types.h>
78 #include <cstdio>
79 #include <time.h>
80 #include <sys/time.h>
81 #include "System.h"
82 #include <Pegasus/Common/Tracer.h>
83 #include <Pegasus/Common/InternalException.h>
84 #include <Pegasus/Common/Mutex.h>
85
86 mike 1.2 #if defined(PEGASUS_OS_LSB)
87 # include <termios.h>
88 # include <stdio.h>
89 # include <stdlib.h>
90 #endif
91
92 #include "Once.h"
93
94 PEGASUS_NAMESPACE_BEGIN
95
96 //==============================================================================
97 //
98 // QlgPath (PEGASUS_OS_OS400 only)
99 //
100 //==============================================================================
101
102 #ifdef PEGASUS_OS_OS400
103
104 struct QlgPath
105 {
106 QlgPath(const char* path);
107 mike 1.2 operator Qlg_Path_Name_T*() { return &qlg_struct; }
108 Qlg_Path_Name_T qlg_struct;
109 const char* pn;
110 };
111
112 QlgPath::QlgPath(const char* path) : pn(path)
113 {
114 memset((void*)&qlg_struct, 0, sizeof(Qlg_Path_Name_T));
115 qlg_struct.CCSID = 1208;
116 #pragma convert(37)
117 memcpy(qlg_struct.Country_ID,"US",2);
118 memcpy(qlg_struct.Language_ID,"ENU",3);
119 #pragma convert(0)
120 qlg_struct.Path_Type = QLG_PTR_SINGLE;
121 qlg_struct.Path_Length = strlen(path);
122 qlg_struct.Path_Name_Delimiter[0] = '/';
123 }
124
125 #endif /* PEGASUS_OS_OS400 */
126
127 //==============================================================================
128 mike 1.2 //
129 // System
130 //
131 //==============================================================================
132
133 // System ID constants for Logger::put and Logger::trace
134 #if defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM)
135 const String System::CIMSERVER = "qycmcimom"; // Server system ID
136 #else
137 const String System::CIMSERVER = "cimserver"; // Server system ID
138 #endif
139
140 void System::getCurrentTime(Uint32& seconds, Uint32& milliseconds)
141 {
142 timeval tv;
143 gettimeofday(&tv, 0);
144 seconds = Uint32(tv.tv_sec);
145 milliseconds = Uint32(tv.tv_usec) / 1000;
146 }
147
148 void System::getCurrentTimeUsec(Uint32& seconds, Uint32& microseconds)
149 mike 1.2 {
150 timeval tv;
151 gettimeofday(&tv, 0);
152 seconds = Uint32(tv.tv_sec);
153 microseconds = Uint32(tv.tv_usec);
154 }
155
156 String System::getCurrentASCIITime()
157 {
158 char str[50];
159 time_t rawTime;
160 struct tm tmBuffer;
161
162 time(&rawTime);
163 strftime(str, 40,"%m/%d/%Y-%T", localtime_r(&rawTime, &tmBuffer));
164 return String(str);
165 }
166
167 static inline void _sleep_wrapper(Uint32 seconds)
168 {
169 sleep(seconds);
170 mike 1.2 }
171
172 void System::sleep(Uint32 seconds)
173 {
174 _sleep_wrapper(seconds);
175 }
176
177 Boolean System::exists(const char* path)
178 {
179 #if defined(PEGASUS_OS_OS400)
180 return QlgAccess(QlgPath(path), F_OK) == 0;
181 #else
182 return access(path, F_OK) == 0;
183 #endif
184 }
185
186 Boolean System::canRead(const char* path)
187 {
188 #if defined(PEGASUS_OS_OS400)
189 return QlgAccess(QlgPath(path), R_OK) == 0;
190 #else
191 mike 1.2 return access(path, R_OK) == 0;
192 #endif
193 }
194
195 Boolean System::canWrite(const char* path)
196 {
197 #if defined(PEGASUS_OS_OS400)
198 return QlgAccess(QlgPath(path), W_OK) == 0;
199 #else
200 return access(path, W_OK) == 0;
201 #endif
202 }
203
204 Boolean System::getCurrentDirectory(char* path, Uint32 size)
205 {
206 #if defined(PEGASUS_OS_OS400)
207 return QlgGetcwd(QlgPath(path), size) == 0;
208 #else
209 return getcwd(path, size) != NULL;
210 #endif
211 }
212 mike 1.2
213 Boolean System::isDirectory(const char* path)
214 {
215 struct stat st;
216
217 #if defined(PEGASUS_OS_OS400)
218 if (QlgStat(QlgPath(path), &st) != 0)
219 return false;
220 #else
221 if (stat(path, &st) != 0)
222 return false;
223 #endif
224 return S_ISDIR(st.st_mode);
225 }
226
227 Boolean System::changeDirectory(const char* path)
228 {
229 #if defined(PEGASUS_OS_OS400)
230 return QlgChdir(QlgPath(path)) == 0;
231 #else
232 return chdir(path) == 0;
233 mike 1.2 #endif
234 }
235
236 Boolean System::makeDirectory(const char* path)
237 {
238 #if defined(PEGASUS_OS_OS400)
239 return QlgMkdir(QlgPath(path), 0777) == 0;
240 #else
241 return mkdir(path, 0777) == 0;
242 #endif
243
244 }
245
246 Boolean System::getFileSize(const char* path, Uint32& size)
247 {
248 struct stat st;
249
250 #if defined(PEGASUS_OS_OS400)
251 if (QlgStat(QlgPath(path), &st) != 0)
252 return false;
253 #else
254 mike 1.2 if (stat(path, &st) != 0)
255 return false;
256 #endif
257
258 size = st.st_size;
259 return true;
260 }
261
262 Boolean System::removeDirectory(const char* path)
263 {
264 #if defined(PEGASUS_OS_OS400)
265 return QlgRmdir(QlgPath(path)) == 0;
266 #else
267 return rmdir(path) == 0;
268 #endif
269 }
270
271 Boolean System::removeFile(const char* path)
272 {
273 #if defined(PEGASUS_OS_OS400)
274 return QlgUnlink(QlgPath(path)) == 0;
275 mike 1.2 #else
276 return unlink(path) == 0;
277 #endif
278 }
279
280 Boolean System::renameFile(const char* oldPath, const char* newPath)
281 {
282 #if defined(PEGASUS_OS_OS400)
283 if (QlgLink(QlgPath(oldPath), QlgPath(newPath)) != 0)
284 return false;
285
286 return QlgUnlink(QlgPath(oldPath)) == 0;
|
287 carson.hovey 1.5 #elif defined(PEGASUS_OS_VMS)
|
288 carson.hovey 1.3 // Note: link() on OpenVMS has a different meaning so rename is used.
289 // unlink() is a synonym for remove() so it can be used.
|
290 mike 1.2 if (rename(oldPath, newPath) != 0)
291 return false;
292
293 return true;
294 #else
295 if (link(oldPath, newPath) != 0)
296 return false;
297
298 return unlink(oldPath) == 0;
299 #endif
300 }
301
302 String System::getHostName()
303 {
304 static char _hostname[PEGASUS_MAXHOSTNAMELEN + 1];
305 static MutexType _mutex = PEGASUS_MUTEX_INITIALIZER;
306
307 // Use double-checked locking pattern to avoid overhead of
308 // mutex on subsequenct calls.
309
310 if (_hostname[0] == '\0')
311 mike 1.2 {
312 mutex_lock(&_mutex);
313
314 if (_hostname[0] == '\0')
315 {
316 gethostname(_hostname, sizeof(_hostname));
317 _hostname[sizeof(_hostname)-1] = 0;
318 #if defined(PEGASUS_OS_OS400)
319 EtoA(_hostname);
320 #endif
321 }
322
323 mutex_unlock(&_mutex);
324 }
325
326 return _hostname;
327 }
328
329 static int _getHostByName(
|
330 r.kieninger 1.8 const char* hostName,
331 char* hostNameOut,
|
332 mike 1.2 size_t hostNameOutSize)
333 {
334 struct hostent *hostEntry;
335
336 #if defined(PEGASUS_OS_LINUX)
337
338 char hostEntryBuffer[8192];
339 struct hostent hostEntryStruct;
340 int hostEntryErrno;
341
342 gethostbyname_r(
343 hostName,
344 &hostEntryStruct,
345 hostEntryBuffer,
346 sizeof(hostEntryBuffer),
347 &hostEntry,
348 &hostEntryErrno);
349
350 #elif defined(PEGASUS_OS_SOLARIS)
351
352 char hostEntryBuffer[8192];
353 mike 1.2 struct hostent hostEntryStruct;
354 int hostEntryErrno;
355
356 hostEntry = gethostbyname_r(
357 hostName,
358 &hostEntryStruct,
359 hostEntryBuffer,
360 sizeof(hostEntryBuffer),
361 &hostEntryErrno);
362
363 #else /* default */
364
365 hostEntry = gethostbyname(hostName);
366
367 #endif
368
369 if (hostEntry)
370 {
371 strncpy(hostNameOut, hostEntry->h_name, hostNameOutSize - 1);
372 return 0;
373 }
374 mike 1.2
375 return -1;
376 }
377
378 String System::getFullyQualifiedHostName ()
379 {
380 #if defined(PEGASUS_OS_ZOS)
381
382 char hostName[PEGASUS_MAXHOSTNAMELEN + 1];
383 String fqName;
384 struct addrinfo *resolv;
385 struct addrinfo hint;
386 struct hostent *he;
387 // receive short name of the local host
388 if (gethostname(hostName, PEGASUS_MAXHOSTNAMELEN) != 0)
389 {
390 return String::EMPTY;
391 }
392 resolv = new struct addrinfo;
393 hint.ai_flags = AI_CANONNAME;
394 hint.ai_family = AF_UNSPEC; // any family
395 mike 1.2 hint.ai_socktype = 0; // any socket type
396 hint.ai_protocol = 0; // any protocol
397 int success = getaddrinfo(hostName,
398 NULL,
399 &hint,
400 &resolv);
401 if (success==0)
402 {
403 // assign fully qualified hostname
404 fqName.assign(resolv->ai_canonname);
405 } else
406 {
407 if ((he = gethostbyname(hostName)))
408 {
409 strcpy (hostName, he->h_name);
410 }
411 // assign hostName
412 // if gethostbyname was successful assign that result
413 // else assign unqualified hostname
414 fqName.assign(hostName);
415 }
416 mike 1.2 freeaddrinfo(resolv);
417 delete resolv;
418
419 return fqName;
420
421 #else /* !PEGASUS_OS_ZOS */
422
423 char hostName[PEGASUS_MAXHOSTNAMELEN + 1];
424
425 if (gethostname(hostName, sizeof(hostName)) != 0)
426 return String::EMPTY;
427
428 hostName[sizeof(hostName)-1] = 0;
429
430 _getHostByName(hostName, hostName, sizeof(hostName));
431
432 # if defined(PEGASUS_OS_OS400)
433 EtoA(hostName);
434 # endif
435
436 return String(hostName);
437 mike 1.2
438 #endif /* !PEGASUS_OS_ZOS */
439 }
440
441 String System::getSystemCreationClassName ()
442 {
443 //
444 // The value returned should match the value of the CreationClassName key
445 // property used in the instrumentation of the CIM_ComputerSystem class
446 // as determined by the provider for the CIM_ComputerSystem class
447 //
448 return "CIM_ComputerSystem";
449 }
450
451 Uint32 System::lookupPort(
452 const char * serviceName,
453 Uint32 defaultPort)
454 {
455 Uint32 localPort;
456
457 struct servent *serv;
458 mike 1.2
459 //
460 // Get wbem-local port from /etc/services
461 //
462
463 #if defined(PEGASUS_OS_SOLARIS)
464 # define SERV_BUFF_SIZE 1024
465 struct servent serv_result;
466 char buf[SERV_BUFF_SIZE];
467
468 if ( (serv = getservbyname_r(serviceName, TCP, &serv_result,
469 buf, SERV_BUFF_SIZE)) != NULL )
470 #elif defined(PEGASUS_OS_OS400)
471 struct servent serv_result;
472 serv = &serv_result;
473 struct servent_data buf;
474 memset(&buf, 0x00, sizeof(struct servent_data));
475
476 char srvnameEbcdic[256];
477 strcpy(srvnameEbcdic, serviceName);
478 AtoE(srvnameEbcdic);
479 mike 1.2
480 char tcpEbcdic[64];
481 strcpy(tcpEbcdic, TCP);
482 AtoE(tcpEbcdic);
483
484 if ( (getservbyname_r(srvnameEbcdic, tcpEbcdic, &serv_result,
485 &buf)) == 0 )
486 #else // PEGASUS_OS_SOLARIS
487 if ( (serv = getservbyname(serviceName, TCP)) != NULL )
488 #endif // PEGASUS_OS_SOLARIS
489 {
490 localPort = htons((uint16_t)serv->s_port);
491 }
492 else
493 {
494 localPort = defaultPort;
495 }
496
497 return localPort;
498 }
499
500 mike 1.2 #if defined(PEGASUS_OS_LSB)
501
502 /*
503 getpass equivalent.
504 Adapted from example implementation described in GLIBC documentation
505 (http://www.dusek.ch/manual/glibc/libc_32.html) and
506 "Advanced Programming in the UNIX Environment" by Richard Stevens,
507 pg. 350.
508
509 */
510 char *getpassword(const char *prompt)
511 {
512 const size_t MAX_PASS_LEN = 1024;
513 static char buf[MAX_PASS_LEN];
514 struct termios old, new_val;
515 char *ptr;
516 int c;
517
518 buf[0] = 0;
519
520 /* Turn echoing off and fail if we can't. */
521 mike 1.2 if (tcgetattr (fileno (stdin), &old) != 0)
522 return buf;
523 new_val = old;
524 new_val.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
525 if (tcsetattr (fileno (stdin), TCSAFLUSH, &new_val) != 0)
526 return buf;
527
528 /* Read the password. */
529 fputs (prompt, stdin);
530 ptr = buf;
531 while ( (c = getc(stdin)) != EOF && c != '\n') {
532 if (ptr < &buf[MAX_PASS_LEN])
533 *ptr++ = c;
534 }
535 *ptr = 0;
536 putc('\n', stdin);
537
538 /* Restore terminal. */
539 (void) tcsetattr (fileno (stdin), TCSAFLUSH, &old);
540 fclose(stdin);
541 return buf;
542 mike 1.2 }
543
544 #endif /* PEGASUS_OS_LSB */
545
546 String System::getPassword(const char* prompt)
547 {
548 #if defined(PEGASUS_OS_VMS)
549
550 struct
551 {
552 short int numbuf;
553 char frst_char;
554 char rsv1;
555 long rsv2;
556 }
557 tahead;
558
559 typedef struct
|
560 r.kieninger 1.8 { // I/O status block
561 short i_cond; // Condition value
562 short i_xfer; // Transfer count
563 long i_info; // Device information
|
564 mike 1.2 }
565 iosb;
566
567 typedef struct
|
568 r.kieninger 1.8 { // Terminal characteristics
569 char t_class; // Terminal class
570 char t_type; // Terminal type
571 short t_width; // Terminal width in characters
572 long t_mandl; // Terminal's mode and length
573 long t_extend; // Extended terminal characteristics
|
574 mike 1.2 }
575 termb;
576
577 termb otermb;
578 termb ntermb;
579
|
580 r.kieninger 1.8 static long ichan; // Gets channel number for TT:
|
581 mike 1.2
582 register int errorcode;
|
583 r.kieninger 1.8 int kbdflgs; // saved keyboard fd flags
584 int kbdpoll; // in O_NDELAY mode
585 int kbdqp = false; // there is a char in kbdq
586 int psize; // size of the prompt
|
587 mike 1.2
588 const size_t MAX_PASS_LEN = 32;
589 static char buf[MAX_PASS_LEN];
|
590 r.kieninger 1.8 char kbdq; // char we've already read
|
591 mike 1.2
592 iosb iostatus;
593
|
594 r.kieninger 1.8 static long termset[2] = { 0, 0 }; // No terminator
|
595 mike 1.2
|
596 r.kieninger 1.8 $DESCRIPTOR(inpdev, "TT"); // Terminal to use for input
|
597 mike 1.2
598 // Get a channel for the terminal
599
600 buf[0] = 0;
601
|
602 r.kieninger 1.8 errorcode = sys$assign(&inpdev, // Device name
603 &ichan, // Channel assigned
604 0, // request KERNEL mode access
605 0); // No mailbox assigned
|
606 mike 1.2
607 if (errorcode != SS$_NORMAL)
608 {
609 return buf;
610 }
611
612 // Read current terminal settings
613
|
614 r.kieninger 1.8 errorcode = sys$qiow(0, // Wait on event flag zero
615 ichan, // Channel to input terminal
616 IO$_SENSEMODE, // Function - Sense Mode
617 &iostatus, // Status after operation
618 0, 0, // No AST service
619 &otermb, // [P1] Address of Char Buffer
620 sizeof (otermb), // [P2] Size of Char Buffer
621 0, 0, 0, 0); // [P3] - [P6]
|
622 mike 1.2
623 if (errorcode != SS$_NORMAL)
624 {
625 return buf;
626 }
627
|
628 r.kieninger 1.8 // setup new settings
|
629 mike 1.2
630 ntermb = otermb;
631
|
632 r.kieninger 1.8 // turn on passthru and nobroadcast
|
633 mike 1.2
634 ntermb.t_extend |= TT2$M_PASTHRU;
635 ntermb.t_mandl |= TT$M_NOBRDCST;
636
|
637 r.kieninger 1.8 // Write out new terminal settings
|
638 mike 1.2
|
639 r.kieninger 1.8 errorcode = sys$qiow(0, // Wait on event flag zero
640 ichan, // Channel to input terminal
641 IO$_SETMODE, // Function - Set Mode
642 &iostatus, // Status after operation
643 0, 0, // No AST service
644 &ntermb, // [P1] Address of Char Buffer
645 sizeof (ntermb), // [P2] Size of Char Buffer
646 0, 0, 0, 0); // [P3] - [P6]
|
647 mike 1.2
648 if (errorcode != SS$_NORMAL)
649 {
650 return buf;
651 }
652
653 // Write a prompt, read characters from the terminal, performing no
654 // editing
655 // and doing no echo at all.
656
657 psize = strlen(prompt);
658
|
659 r.kieninger 1.8 errorcode = sys$qiow(0, // Event flag
660 ichan, // Input channel
|
661 mike 1.2 IO$_READPROMPT | IO$M_NOECHO | IO$M_NOFILTR |
662 IO$M_TRMNOECHO,
663 // Read with prompt, no echo, no translate, no
664 // termination character echo
|
665 r.kieninger 1.8 &iostatus, // I/O status block
666 NULL, // AST block (none)
667 0, // AST parameter
668 &buf, // P1 - input buffer
669 MAX_PASS_LEN, // P2 - buffer length
670 0, // P3 - ignored (timeout)
671 0, // P4 - ignored (terminator char set)
672 prompt, // P5 - prompt buffer
673 psize); // P6 - prompt size
|
674 mike 1.2
675 if (errorcode != SS$_NORMAL)
676 {
677 return buf;
678 }
679
|
680 r.kieninger 1.8 // Write out old terminal settings
681 errorcode = sys$qiow(0, // Wait on event flag zero
682 ichan, // Channel to input terminal
683 IO$_SETMODE, // Function - Set Mode
684 &iostatus, // Status after operation
685 0, 0, // No AST service
686 &otermb, // [P1] Address of Char Buffer
687 sizeof (otermb), // [P2] Size of Char Buffer
688 0, 0, 0, 0); // [P3] - [P6]
|
689 mike 1.2
690 if (errorcode != SS$_NORMAL)
691 {
692 return buf;
693 }
694
695 // Start new line
|
696 r.kieninger 1.8
|
697 mike 1.2 const int CR = 0x0d;
698 const int LF = 0x0a;
699 fputc(CR, stdout);
700 fputc(LF, stdout);
701
702 // Remove the termination character
703 psize = strlen(buf);
704 buf[psize - 1] = 0;
705
706 return buf;
707
708 #elif defined(PEGASUS_OS_OS400)
709
710 // Not supported on OS/400, and we don't need it.
711 // 'getpass' is DEPRECATED
712 return String();
713
714 #elif defined(PEGASUS_OS_LSB)
715
716 return String(getpassword(prompt));
717
718 mike 1.2 #else /* default */
719
720 return String(getpass(prompt));
721
722 #endif /* default */
723 }
724
725 String System::getEffectiveUserName()
726 {
727 String userName = String::EMPTY;
728 struct passwd* pwd = NULL;
729
730 #if defined(PEGASUS_OS_SOLARIS) || \
731 defined(PEGASUS_OS_HPUX) || \
732 defined(PEGASUS_OS_LINUX) || \
733 defined(PEGASUS_OS_OS400)
734
735 const unsigned int PWD_BUFF_SIZE = 1024;
736 struct passwd local_pwd;
737 char buf[PWD_BUFF_SIZE];
738
739 mike 1.2 if(getpwuid_r(geteuid(), &local_pwd, buf, PWD_BUFF_SIZE, &pwd) != 0)
740 {
741 String errorMsg = String("getpwuid_r failure : ") +
742 String(strerror(errno));
743 PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2, errorMsg);
744 // L10N TODO - This message needs to be added.
745 //Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
746 // errorMsg);
747 }
748 #elif defined(PEGASUS_OS_ZOS)
749 char effective_username[9];
750 __getuserid(effective_username, 9);
751 __etoa_l(effective_username,9);
752 userName.assign(effective_username);
753 return userName;
754 #else
755 //
756 // get the currently logged in user's UID.
757 //
758 pwd = getpwuid(geteuid());
759 #endif
760 mike 1.2 if (pwd == NULL)
761 {
762 // L10N TODO - This message needs to be added.
|
763 yi.zhou 1.7 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
|
764 mike 1.2 // "getpwuid_r failure, user may have been removed just after login");
765 Tracer::trace (TRC_OS_ABSTRACTION, Tracer::LEVEL4,
766 "getpwuid_r failure, user may have been removed just after login");
767 }
768 else
769 {
770 #if defined(PEGASUS_OS_OS400)
771 EtoA(pwd->pw_name);
772 #endif
773 //
774 // get the user name
775 //
776 userName.assign(pwd->pw_name);
777 }
778
779 return(userName);
780 }
781
782 String System::encryptPassword(const char* password, const char* salt)
783 {
|
784 carson.hovey 1.3 #if defined(PEGASUS_OS_VMS)
|
785 mike 1.2
786 const size_t MAX_PASS_LEN = 1024;
787 char pbBuffer[MAX_PASS_LEN] = {0};
788 int dwByteCount;
789 char pcSalt[3] = {0};
790
791 strncpy(pcSalt, salt, 2);
792 dwByteCount = strlen(password);
793 memcpy(pbBuffer, password, dwByteCount);
794
795 for (int i=0; (i<dwByteCount) || (i>=MAX_PASS_LEN); i++)
796 {
797 (i%2 == 0) ? pbBuffer[i] ^= pcSalt[1] : pbBuffer[i] ^= pcSalt[0];
798 }
799
800 return String(pcSalt) + String((char *)pbBuffer);
801
|
802 r.kieninger 1.8 #elif !defined(PEGASUS_OS_OS400)
|
803 carson.hovey 1.3
804 return ( String(crypt( password,salt)) );
805
|
806 mike 1.2 #else
807
808 // Not supported on OS400, and we don't need it.
809 return ( String(password) );
810
811 #endif
812 }
813
814 Boolean System::isSystemUser(const char* userName)
815 {
816 #if defined(PEGASUS_OS_SOLARIS) || \
817 defined(PEGASUS_OS_HPUX) || \
818 defined(PEGASUS_OS_LINUX) || \
819 defined(PEGASUS_OS_OS400)
820
821 const unsigned int PWD_BUFF_SIZE = 1024;
822 struct passwd pwd;
823 struct passwd *result;
824 char pwdBuffer[PWD_BUFF_SIZE];
825
826 if (getpwnam_r(userName, &pwd, pwdBuffer, PWD_BUFF_SIZE, &result) != 0)
827 mike 1.2 {
828 String errorMsg = String("getpwnam_r failure : ") +
829 String(strerror(errno));
830 PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2, errorMsg);
831 // L10N TODO - This message needs to be added.
832 //Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
833 // errorMsg);
834 }
835
836 if (result == NULL)
837 return false;
838
839 return true;
840
841 #elif defined(PEGASUS_OS_OS400)
842
843 AtoE((char*)userName);
844
845 if (getpwnam(userName) == NULL)
846 {
847 EtoA((char*)userName);
848 mike 1.2 return false;
849 }
850
851 EtoA((char*)userName);
852 return true;
853
854 #else /* default */
855
856 return getpwnam(userName) != NULL;
857
858 #endif /* default */
859 }
860
861 Boolean System::isPrivilegedUser(const String& userName)
862 {
863 #if !defined(PEGASUS_OS_OS400)
864 struct passwd pwd;
865 struct passwd *result;
866 const unsigned int PWD_BUFF_SIZE = 1024;
867 char pwdBuffer[PWD_BUFF_SIZE];
868
869 mike 1.2 if (getpwnam_r(
870 userName.getCString(), &pwd, pwdBuffer, PWD_BUFF_SIZE, &result) != 0)
871 {
872 String errorMsg = String("getpwnam_r failure : ") +
873 String(strerror(errno));
874 PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2, errorMsg);
875 // L10N TODO - This message needs to be added.
876 //Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
877 // errorMsg);
878 }
879
880 // Check if the requested entry was found. If not return false.
881 if ( result != NULL )
882 {
883 // Check if the uid is 0.
884 if ( pwd.pw_uid == 0 )
885 {
886 return true;
887 }
888 }
889 return false;
890 mike 1.2
891 #elif defined(PEGASUS_OS_VMS)
892
893 int retStat;
894
895 unsigned long int prvPrv = 0;
896 retStat = sys$setprv(0, 0, 0, &prvPrv);
897
898 if (!$VMS_STATUS_SUCCESS(retStat))
899 return false;
900
901 // ATTN-VMS: should this be a bitwise and?
902 return ((PRV$M_SETPRV && prvPrv) == 1) ? true : false;
903
904 #else /* default */
905
906 CString user = userName.getCString();
907 const char * tmp = (const char *)user;
908 AtoE((char *)tmp);
909 return ycmCheckUserCmdAuthorities(tmp);
910
911 mike 1.2 #endif /* default */
912 }
913
914 static String _priviledgedUserName;
915 static Once _priviledgedUserNameOnce = PEGASUS_ONCE_INITIALIZER;
916
917 static void _initPrivilegedUserName()
918 {
919 struct passwd* pwd = NULL;
920
921 #if defined(PEGASUS_OS_SOLARIS) || \
922 defined(PEGASUS_OS_HPUX) || \
923 defined(PEGASUS_OS_LINUX) || \
924 defined(PEGASUS_OS_OS400)
925
926 const unsigned int PWD_BUFF_SIZE = 1024;
927 struct passwd local_pwd;
928 char buf[PWD_BUFF_SIZE];
929
930 if (getpwuid_r(0, &local_pwd, buf, PWD_BUFF_SIZE, &pwd) != 0)
931 {
932 mike 1.2 String errorMsg = String("getpwuid_r failure : ") +
933 String(strerror(errno));
934 PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2, errorMsg);
935 // L10N TODO - This message needs to be added.
936 // Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
937 // errorMsg);
938 }
939
940 #else /* default */
941
942 pwd = getpwuid(0);
943
944 #endif /* default */
945
946 if ( pwd != NULL )
947 {
948 #if defined(PEGASUS_OS_OS400)
949 EtoA(pwd->pw_name);
950 #endif
951 _priviledgedUserName.assign(pwd->pw_name);
952 }
953 mike 1.2 else
954 {
955 Tracer::trace (
956 TRC_OS_ABSTRACTION, Tracer::LEVEL4, "Could not find entry.");
957 PEGASUS_ASSERT(0);
958 }
959 }
960
961 String System::getPrivilegedUserName()
962 {
963 once(&_priviledgedUserNameOnce, _initPrivilegedUserName);
964 return _priviledgedUserName;
965 }
966
967 #if !defined(PEGASUS_OS_VMS) || defined(PEGASUS_ENABLE_USERGROUP_AUTHORIZATION)
968
969 Boolean System::isGroupMember(const char* userName, const char* groupName)
970 {
971 struct group grp;
972 char* member;
973 Boolean retVal = false;
974 mike 1.2 const unsigned int PWD_BUFF_SIZE = 1024;
975 const unsigned int GRP_BUFF_SIZE = 1024;
976 struct passwd pwd;
977 struct passwd* result;
978 struct group* grpresult;
979 char pwdBuffer[PWD_BUFF_SIZE];
980 char grpBuffer[GRP_BUFF_SIZE];
981
982 // Search Primary group information.
983
984 // Find the entry that matches "userName"
985
986 if (getpwnam_r(userName, &pwd, pwdBuffer, PWD_BUFF_SIZE, &result) != 0)
987 {
988 String errorMsg = String("getpwnam_r failure : ") +
989 String(strerror(errno));
990 PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2, errorMsg);
|
991 yi.zhou 1.7 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
|
992 mike 1.2 errorMsg);
993 throw InternalSystemError();
994 }
995
996 if ( result != NULL )
997 {
998 // User found, check for group information.
999 gid_t group_id;
1000 group_id = pwd.pw_gid;
1001
1002 // Get the group name using group_id and compare with group passed.
1003 if ( getgrgid_r(group_id, &grp,
1004 grpBuffer, GRP_BUFF_SIZE, &grpresult) != 0)
1005 {
1006 String errorMsg = String("getgrgid_r failure : ") +
1007 String(strerror(errno));
1008 PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2, errorMsg);
|
1009 yi.zhou 1.7 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
|
1010 mike 1.2 errorMsg);
1011 throw InternalSystemError();
1012 }
1013
1014 // Compare the user's group name to groupName.
1015 if ( strcmp (grp.gr_name, groupName) == 0 )
1016 {
1017 // User is a member of the group.
1018 return true;
1019 }
1020 }
1021
1022 //
1023 // Search supplemental groups.
1024 // Get a user group entry
1025 //
1026 if (getgrnam_r((char *)groupName, &grp,
1027 grpBuffer, GRP_BUFF_SIZE, &grpresult) != 0)
1028 {
1029 String errorMsg = String("getgrnam_r failure : ") +
1030 String(strerror(errno));
1031 mike 1.2 PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2, errorMsg);
1032 Logger::put(
|
1033 yi.zhou 1.7 Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING, errorMsg);
|
1034 mike 1.2 throw InternalSystemError();
1035 }
1036
1037 // Check if the requested group was found.
1038 if (grpresult == NULL)
1039 {
1040 return false;
1041 }
1042
1043 Uint32 j = 0;
1044
1045 //
1046 // Get all the members of the group
1047 //
1048 member = grp.gr_mem[j++];
1049
1050 while (member)
1051 {
1052 //
1053 // Check if the user is a member of the group
1054 //
1055 mike 1.2 if ( strcmp(userName, member) == 0 )
1056 {
1057 retVal = true;
1058 break;
1059 }
1060 member = grp.gr_mem[j++];
1061 }
1062
1063 return retVal;
1064 }
1065
1066 #endif /* !PEGASUS_OS_VMS || PEGASUS_ENABLE_USERGROUP_AUTHORIZATION */
1067
1068 #ifndef PEGASUS_OS_OS400
1069
1070 Boolean System::lookupUserId(
1071 const char* userName,
1072 PEGASUS_UID_T& uid,
1073 PEGASUS_GID_T& gid)
1074 {
1075 const unsigned int PWD_BUFF_SIZE = 1024;
1076 mike 1.2 struct passwd pwd;
1077 struct passwd *result;
1078 char pwdBuffer[PWD_BUFF_SIZE];
1079
1080 # if defined(PEGASUS_OS_OS400)
1081 AtoE((char *)userName);
1082 # endif
1083
1084 int rc = getpwnam_r(userName, &pwd, pwdBuffer, PWD_BUFF_SIZE, &result);
1085
1086 # if defined(PEGASUS_OS_OS400)
1087 EtoA((char *)userName);
1088 # endif
1089
1090 if (rc != 0)
1091 {
1092 PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2,
1093 String("getpwnam_r failed: ") + String(strerror(errno)));
1094 return false;
1095 }
1096
1097 mike 1.2 if (result == 0)
1098 {
1099 PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2,
1100 "getpwnam_r failed.");
1101 return false;
1102 }
1103
1104 uid = pwd.pw_uid;
1105 gid = pwd.pw_gid;
1106
1107 return true;
1108 }
1109
1110 Boolean System::changeUserContext(
1111 const PEGASUS_UID_T& uid,
1112 const PEGASUS_GID_T& gid)
1113 {
1114 Tracer::trace(TRC_OS_ABSTRACTION, Tracer::LEVEL4,
1115 "Changing user context to: uid = %d, gid = %d",
1116 (int)uid, (int)gid);
1117
1118 mike 1.2 if (setgid(gid) != 0)
1119 {
1120 PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2,
1121 String("setgid failed: ") + String(strerror(errno)));
1122 return false;
1123 }
1124
1125 if (setuid(uid) != 0)
1126 {
1127 PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2,
1128 String("setuid failed: ") + String(strerror(errno)));
1129 return false;
1130 }
1131
1132 return true;
1133 }
1134
1135 #endif /* PEGASUS_OS_OS400 */
1136
1137 Uint32 System::getPID()
1138 {
1139 mike 1.2 return getpid();
1140 }
1141
1142 Boolean System::truncateFile(
1143 const char* path,
1144 size_t newSize)
1145 {
1146 #if defined(PEGASUS_OS_OS400)
1147 int fd = QlgOpen(QlgPath(path), O_WRONLY);
1148
1149 if (fd != -1)
1150 {
1151 int rc = ftruncate(fd, newSize);
1152 close(fd);
1153 return (rc == 0);
1154 }
1155
1156 return false;
1157 #else
1158 return (truncate(path, newSize) == 0);
1159 #endif
1160 mike 1.2 }
1161
1162 Boolean System::is_absolute_path(const char *path)
1163 {
1164 if (path == NULL)
1165 return false;
1166
1167 if (path[0] == '/')
1168 return true;
1169
1170 return false;
1171 }
1172
1173 Boolean System::changeFilePermissions(const char* path, mode_t mode)
1174 {
1175 Sint32 ret = 0;
1176 const char * tmp = path;
1177
1178 #if defined(PEGASUS_OS_OS400)
1179 // ATTN: Update this code to handle UTF8 when path contains UTF8
1180 AtoE((char *)tmp);
1181 mike 1.2 #endif
1182
1183 return chmod(tmp, mode) == 0 ? true : false;
1184 }
1185
1186 Boolean System::verifyFileOwnership(const char* path)
1187 {
1188 struct stat st;
1189
1190 #if defined(PEGASUS_OS_OS400)
1191 if (QlgStat(QlgPath(path), &st) != 0)
1192 return false;
1193 #else
1194 if (lstat(path, &st) != 0)
1195 return false;
1196 #endif
1197
1198 return ((st.st_uid == geteuid()) && // Verify the file owner
1199 S_ISREG(st.st_mode) && // Verify it is a regular file
1200 (st.st_nlink == 1)); // Verify it is not a hard link
1201 }
1202 mike 1.2
1203 void System::syslog(const String& ident, Uint32 severity, const char* message)
1204 {
1205 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX)
1206
1207 // Since the openlog(), syslog(), and closelog() function calls must be
1208 // coordinated (see below), we need a thread control.
1209
1210 static Mutex logMutex;
1211
1212 AutoMutex loglock(logMutex);
1213
1214 // Get a const char* representation of the identifier string. Note: The
1215 // character string passed to the openlog() function must persist until
1216 // closelog() is called. The syslog() method uses this pointer directly
1217 // rather than a copy of the string it refers to.
1218
1219 CString identCString = ident.getCString();
1220 openlog(identCString, LOG_PID, LOG_DAEMON);
1221
1222 // Map from the Logger log level to the system log level.
1223 mike 1.2
1224 Uint32 syslogLevel;
1225 if (severity & Logger::FATAL)
1226 {
1227 syslogLevel = LOG_CRIT;
1228 }
1229 else if (severity & Logger::SEVERE)
1230 {
1231 syslogLevel = LOG_ERR;
1232 }
1233 else if (severity & Logger::WARNING)
1234 {
1235 syslogLevel = LOG_WARNING;
1236 }
1237 else if (severity & Logger::INFORMATION)
1238 {
1239 syslogLevel = LOG_INFO;
1240 }
1241 else // if (severity & Logger::TRACE)
1242 {
1243 syslogLevel = LOG_DEBUG;
1244 mike 1.2 }
1245
1246 // Write the message to the system log.
1247
1248 ::syslog(syslogLevel, "%s", message);
1249
1250 closelog();
1251
1252 #elif defined(PEGASUS_OS_OS400)
1253
1254 std::string replacementData = message;
1255 // All messages will go to the joblog. In the future
1256 // some messages may go to other message queues yet
1257 // to be determined.
1258 if ((severity & Logger::TRACE) ||
1259 (severity & Logger::INFORMATION))
1260 {
1261
1262 // turn into ycmMessage so we can put it in the job log
1263 # pragma convert(37)
1264 ycmMessage theMessage("CPIDF80",
1265 mike 1.2 message,
1266 strlen(message),
1267 "Logger",
1268 ycmCTLCIMID,
1269 TRUE);
1270 # pragma convert(0)
1271
1272 // put the message in the joblog
1273 theMessage.joblogIt(UnitOfWorkError,
1274 ycmMessage::Informational);
1275 }
1276
1277 if ((severity & Logger::WARNING) ||
1278 (severity & Logger::SEVERE) ||
1279 (severity & Logger::FATAL))
1280 {
1281 // turn into ycmMessage so we can put it in the job log
1282 # pragma convert(37)
1283 ycmMessage theMessage("CPDDF82",
1284 message,
1285 strlen(message),
1286 mike 1.2 "Logger",
1287 ycmCTLCIMID,
1288 TRUE);
1289 # pragma convert(0)
1290 // put the message in the joblog
1291 theMessage.joblogIt(UnitOfWorkError,
1292 ycmMessage::Diagnostic);
1293 }
1294
|
1295 r.kieninger 1.8 #elif defined(PEGASUS_OS_ZOS)
1296
1297 const char * zosMessageString = message;
1298 unsigned int zosMessageStringLength = strlen(message);
1299 char * tmpMessageString = NULL;
1300 Uint32 syslogLevel = LOG_DEBUG;
1301
1302 if (strncmp(message, "CFZ", 3) != 0)
1303 {
1304 // Message is not z/OS message that already has the right prefix.
1305 // Prepend the generic z/OS message ids to Pegasus message
1306 const char* zos_msgid;
1307 if (severity & Logger::TRACE)
1308 {
1309 syslogLevel = LOG_DEBUG;
1310 zos_msgid = "CFZ00001I: ";
1311 }
1312 if (severity & Logger::INFORMATION)
1313 {
1314 syslogLevel = LOG_INFO;
1315 zos_msgid = "CFZ00001I: ";
1316 r.kieninger 1.8 }
1317 if (severity & Logger::WARNING)
1318 {
1319 syslogLevel = LOG_WARNING;
1320 zos_msgid = "CFZ00002W: ";
1321 }
1322 if ((severity & Logger::SEVERE) || (severity & Logger::FATAL) )
1323 {
1324 syslogLevel = LOG_ERR;
1325 zos_msgid = "CFZ00004E: ";
1326 }
1327
1328 zosMessageStringLength += strlen(zos_msgid);
1329 tmpMessageString = (char*)calloc(zosMessageStringLength,1);
1330 strcpy(tmpMessageString, zos_msgid);
1331 strcat(tmpMessageString, message);
1332
1333 zosMessageString = tmpMessageString;
1334 }
1335
1336 // Issue important messages to the z/OS console
1337 r.kieninger 1.8 if (!(severity & Logger::TRACE))
1338 {
1339 struct __cons_msg cons;
1340 int concmd=0;
1341 int rc;
1342
1343
1344 memset(&cons,0,sizeof(cons));
1345
1346 cons.__format.__f1.__msg_length = zosMessageStringLength;
1347 cons.__format.__f1.__msg = (char*)zosMessageString;
1348
1349 rc = __console(&cons, NULL, &concmd );
1350 }
1351
1352 // In addition all messages go to the syslog
1353 static Mutex logMutex;
1354
1355 AutoMutex loglock(logMutex);
1356
1357 CString identCString = ident.getCString();
1358 r.kieninger 1.8 openlog(identCString, LOG_PID, LOG_DAEMON);
1359 ::syslog(syslogLevel, "%s", zosMessageString);
1360 closelog();
1361
1362 if (tmpMessageString)
1363 delete tmpMessageString;
1364
1365
|
1366 mike 1.2 #else /* default */
1367
1368 // Not implemented!
1369
1370 #endif /* default */
1371 }
1372
|
1373 kumpf 1.6
1374 ///////////////////////////////////////////////////////////////////////////////
1375 // AutoFileLock class
1376 ///////////////////////////////////////////////////////////////////////////////
1377
1378 AutoFileLock::AutoFileLock(const char* fileName)
1379 {
1380 #ifdef PEGASUS_OS_TYPE_UNIX
1381 _fl.l_type = F_WRLCK;
1382 _fl.l_whence = SEEK_SET;
1383 _fl.l_start = 0;
1384 _fl.l_len = 0;
1385 _fl.l_pid = getpid();
1386
1387 do
1388 {
1389 _fd = open(fileName, O_WRONLY);
1390 } while ((_fd == -1) && (errno == EINTR));
1391
1392 if (_fd != -1)
1393 {
1394 kumpf 1.6 int rc;
1395
1396 do
1397 {
1398 rc = fcntl(_fd, F_SETLKW, &_fl);
1399 } while ((rc == -1) && (errno == EINTR));
1400
1401 if (rc == -1)
1402 {
1403 Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
1404 "AutoFileLock: Failed to lock file '%s', error code %d.",
1405 fileName, errno);
1406 _fd = -1;
1407 }
1408 }
1409 else
1410 {
1411 Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
1412 "AutoFileLock: Failed to open lock file '%s', error code %d.",
1413 fileName, errno);
1414 }
1415 kumpf 1.6 #endif
1416 }
1417
1418 AutoFileLock::~AutoFileLock()
1419 {
1420 #ifdef PEGASUS_OS_TYPE_UNIX
1421 if (_fd != -1)
1422 {
1423 _fl.l_type = F_UNLCK;
1424 int rc = fcntl(_fd, F_SETLK, &_fl);
1425 if (rc == -1)
1426 {
1427 Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
1428 "AutoFileLock: Failed to unlock file, error code %d.",
1429 errno);
1430 }
1431 close(_fd);
1432 }
1433 #endif
1434 }
1435
1436 kumpf 1.6
|
1437 mike 1.2 //==============================================================================
1438 //
1439 // PEGASUS_OS_AIX
1440 //
1441 //==============================================================================
1442
1443 // System Initializater for AIX
1444 #ifdef PEGASUS_OS_AIX
1445 # include <cstdlib>
1446
1447 class SystemInitializer
1448 {
1449
1450 public:
1451 /**
1452 *
1453 * Default constructor.
1454 *
1455 */
1456 SystemInitializer();
1457 };
1458 mike 1.2
1459 SystemInitializer::SystemInitializer()
1460 {
1461 putenv("XPG_SUS_ENV=ON");
1462 }
1463
1464 static SystemInitializer initializer;
1465
1466 #endif /* PEGASUS_OS_AIX */
1467
1468 PEGASUS_NAMESPACE_END
|