1 karl 1.45 //%2005////////////////////////////////////////////////////////////////////////
|
2 mike 1.13 //
|
3 karl 1.42 // 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.32 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.42 // 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.45 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 mike 1.13 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
13 mike 1.14 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
16 mike 1.13 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
|
18 kumpf 1.25 //
|
19 mike 1.14 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
20 mike 1.13 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
22 mike 1.14 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
25 mike 1.13 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 // Author: Mike Brasher (mbrasher@bmc.com)
31 //
|
32 mike 1.14 // Modified By: Sushma Fernandes (sushma_fernandes@hp.com)
33 // Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)
|
34 kumpf 1.35 // Bapu Patil (bapu_patil@hp.com)
|
35 mike 1.13 //
|
36 david 1.29 // Modified By: Dave Rosckes (rosckes@us.ibm.com)
|
37 kumpf 1.36 // Terry Martin, Hewlett-Packard Company (terry.martin@hp.com)
|
38 a.arora 1.40 // Amit K Arora, IBM (amita@in.ibm.com) for Bug#1428
|
39 h.sterling 1.46 // Seema Gupta (gseema@in.ibm.com) for Bug#1617
|
40 david.dillard 1.43 // David Dillard, VERITAS Software Corp.
41 // (david.dillard@veritas.com)
|
42 david 1.29 //
|
43 mike 1.13 //%/////////////////////////////////////////////////////////////////////////////
44
45 #include "System.h"
46
47 #include <windows.h>
|
48 tony 1.31 #ifndef _WINSOCKAPI_
49 #include <winsock2.h>
50 #endif
|
51 mike 1.21 #include <fcntl.h>
|
52 mike 1.13 #include <sys/types.h>
53 #include <time.h>
54 #include <sys/timeb.h>
55 #include <io.h>
|
56 tony 1.33 #include <conio.h>
|
57 mike 1.13 #include <direct.h>
58 #include <sys/types.h>
|
59 mday 1.19 #include <windows.h>
|
60 kumpf 1.18 #include <process.h>
|
61 kumpf 1.38 #include <lm.h>
|
62 mike 1.13
|
63 kumpf 1.36 PEGASUS_NAMESPACE_BEGIN
64
|
65 se.gupta 1.41 #define PEGASUS_ACCESS_EXISTS 0
66 #define PEGASUS_ACCESS_WRITE 2
67 #define PEGASUS_ACCESS_READ 4
68 #define PEGASUS_ACCESS_READ_AND_WRITE 6
|
69 mike 1.13
|
70 tony 1.33 #define PW_BUFF_LEN 65
71
|
72 mike 1.13 void System::getCurrentTime(Uint32& seconds, Uint32& milliseconds)
73 {
74 FILETIME ft;
75 GetSystemTimeAsFileTime(&ft);
76 ULARGE_INTEGER largeInt = { ft.dwLowDateTime, ft.dwHighDateTime };
77 largeInt.QuadPart -= 0x19db1ded53e8000;
78 seconds = long(largeInt.QuadPart / (10000 * 1000));
79 milliseconds = long((largeInt.QuadPart % (10000 * 1000)) / 10);
|
80 karl 1.23 // This is a real hack. Added the following line after timevalue was
81 // corrected and this apparently wrong. ks 7 apri 2002
82 milliseconds = milliseconds / 1000;
|
83 mike 1.13 }
84
85 String System::getCurrentASCIITime()
86 {
87 char tmpbuf[128];
|
88 kumpf 1.28 _strdate( tmpbuf );
89 String date = tmpbuf;
|
90 mike 1.13 _strtime( tmpbuf );
|
91 kumpf 1.28 date.append("-");
92 date.append(tmpbuf);
93 return date;
|
94 mike 1.13 }
95
96 void System::sleep(Uint32 seconds)
97 {
98 Sleep(seconds * 1000);
99 }
100
101 Boolean System::exists(const char* path)
102 {
|
103 se.gupta 1.41 return _access(path, PEGASUS_ACCESS_EXISTS) == 0;
|
104 mike 1.13 }
105
106 Boolean System::canRead(const char* path)
107 {
|
108 se.gupta 1.41 return _access(path, PEGASUS_ACCESS_READ) == 0;
|
109 mike 1.13 }
110
111 Boolean System::canWrite(const char* path)
112 {
|
113 se.gupta 1.41 return _access(path, PEGASUS_ACCESS_WRITE) == 0;
|
114 mike 1.13 }
115
116 Boolean System::getCurrentDirectory(char* path, Uint32 size)
117 {
118 return GetCurrentDirectory(size, path) != 0;
119 }
120
121 Boolean System::isDirectory(const char* path)
122 {
123 struct stat st;
124
125 if (stat(path, &st) != 0)
|
126 h.sterling 1.46 return false;
|
127 mike 1.13
128 return (st.st_mode & _S_IFDIR) != 0;
129 }
130
131 Boolean System::changeDirectory(const char* path)
132 {
133 return chdir(path) == 0;
134 }
135
136 Boolean System::makeDirectory(const char* path)
137 {
138 return _mkdir(path) == 0;
139 }
140
141 Boolean System::getFileSize(const char* path, Uint32& size)
142 {
143 struct stat st;
144
145 if (stat(path, &st) != 0)
|
146 h.sterling 1.46 return false;
|
147 mike 1.13
148 size = st.st_size;
149 return true;
150 }
151
152 Boolean System::removeDirectory(const char* path)
153 {
|
154 h.sterling 1.46 return rmdir(path) == 0;
|
155 mike 1.13 }
156
157 Boolean System::removeFile(const char* path)
158 {
|
159 h.sterling 1.46 return unlink(path) == 0;
|
160 mike 1.13 }
161
162 Boolean System::renameFile(const char* oldPath, const char* newPath)
163 {
164 return rename(oldPath, newPath) == 0;
165 }
166
167 DynamicLibraryHandle System::loadDynamicLibrary(const char* fileName)
168 {
169 return DynamicLibraryHandle(LoadLibrary(fileName));
170 }
171
|
172 mike 1.14 void System::unloadDynamicLibrary(DynamicLibraryHandle libraryHandle)
173 {
|
174 h.sterling 1.46 FreeLibrary(HINSTANCE(libraryHandle));
|
175 mike 1.14 }
176
|
177 mike 1.13 String System::dynamicLoadError(void) {
178 return String();
179 }
180
181 DynamicSymbolHandle System::loadDynamicSymbol(
182 DynamicLibraryHandle libraryHandle,
183 const char* symbolName)
184 {
185 return DynamicSymbolHandle(GetProcAddress(
|
186 h.sterling 1.46 (HINSTANCE)libraryHandle, symbolName));
|
187 mike 1.13 }
188
189 String System::getHostName()
190 {
|
191 kumpf 1.35 static char hostname[PEGASUS_MAXHOSTNAMELEN];
|
192 mike 1.13
193 if (!*hostname)
194 gethostname(hostname, sizeof(hostname));
195
196 return hostname;
|
197 kumpf 1.16 }
198
|
199 kumpf 1.22 String System::getFullyQualifiedHostName ()
200 {
|
201 a.arora 1.40 static char FQHostName[PEGASUS_MAXHOSTNAMELEN];
202
203 if (!*FQHostName)
204 {
205 String hostname = getHostName();
206 struct hostent* hostEnt;
207
208 hostEnt = gethostbyname((const char *)hostname.getCString());
209 if (hostEnt == NULL)
210 {
211 return String::EMPTY;
212 }
213 strcpy(FQHostName, hostEnt->h_name);
214 }
215
216 return FQHostName;
|
217 kumpf 1.22 }
218
219 String System::getSystemCreationClassName ()
220 {
|
221 karl 1.39 return "CIM_ComputerSystem";
|
222 kumpf 1.22 }
223
|
224 kumpf 1.16 Uint32 System::lookupPort(
225 const char * serviceName,
226 Uint32 defaultPort)
227 {
228 Uint32 localPort;
229
230 struct servent *serv;
231
232 //
233 // Get wbem-local port from /etc/services
234 //
235 if ( (serv = getservbyname(serviceName, TCP)) != NULL )
236 {
237 localPort = serv->s_port;
238 }
239 else
240 {
241 localPort = defaultPort;
242 }
243
244 return localPort;
|
245 mike 1.13 }
246
|
247 mike 1.14 String System::getPassword(const char* prompt)
248 {
|
249 tony 1.33 char password[PW_BUFF_LEN] = {0};
250 int num_chars = 0;
251 int ch;
252
253 fputs(prompt, stderr);
254
255 while ((ch = _getch()) != '\r' &&
256 num_chars < PW_BUFF_LEN)
257 {
258 // EOF
259 if (ch == EOF)
260 {
261 fputs("[EOF]\n", stderr);
262 return String::EMPTY;
263 }
264 // Backspace or Delete
265 else if ((ch == '\b' || ch == 127) &&
266 num_chars > 0)
267 {
268 password[--num_chars] = '\0';
269 fputs("\b \b", stderr);
270 tony 1.33 }
271 // CTRL+C
272 else if (ch == 3)
273 {
274 // _getch() does not catch CTRL+C
275 fputs("^C\n", stderr);
276 exit(-1);
277 }
278 // CTRL+Z
279 else if (ch == 26)
280 {
281 fputs("^Z\n", stderr);
282 return String::EMPTY;
283 }
284 // Esc
285 else if (ch == 27)
286 {
287 fputc('\n', stderr);
288 fputs(prompt, stderr);
289 num_chars = 0;
290 }
291 tony 1.33 // Function keys (0 or E0) are a guards for a Function key codes
292 else if (ch == 0 || ch == 0xE0)
293 {
294 ch = (ch << 4) | _getch();
295 // Handle DELETE, left arrow, keypad DEL, and keypad left arrow
296 if ((ch == 0xE53 || ch == 0xE4B || ch == 0x053 || ch == 0x04b) &&
297 num_chars > 0)
298 {
299 password[--num_chars] = '\0';
300 fputs("\b \b", stderr);
301 }
302 else
303 {
304 fputc('\a', stderr);
305 }
306 }
307 else if ((num_chars < sizeof(password) - 1) &&
308 !iscntrl(((unsigned char)(ch))))
309 {
310 password[num_chars++] = ch;
311 fputc('*', stderr);
312 tony 1.33 }
313 else
314 {
315 fputc('\a', stderr);
316 }
317 }
|
318 mike 1.14
|
319 tony 1.33 fputc('\n', stderr);
320 password[num_chars] = '\0';
321
322 return String(password);
|
323 mike 1.14 }
324
|
325 kumpf 1.24 String System::getEffectiveUserName()
|
326 mike 1.14 {
|
327 tony 1.33 int retcode = 0;
328
329 // UNLEN (256) is the limit, not including null
330 char pUserName[256+1] = {0};
331 DWORD nSize = sizeof(pUserName);
|
332 mike 1.14
|
333 tony 1.33 retcode = GetUserName(pUserName, &nSize);
334 if (retcode == 0)
335 {
336 // zero is failure
337 return String();
338 }
339
340 return String(pUserName);
|
341 mike 1.14 }
342
343 String System::encryptPassword(const char* password, const char* salt)
344 {
|
345 tony 1.33 BYTE pbBuffer[PW_BUFF_LEN] = {0};
346 DWORD dwByteCount;
347 char pcSalt[3] = {0};
348
349 strncpy(pcSalt, salt, 2);
350 dwByteCount = strlen(password);
351 memcpy(pbBuffer, password, dwByteCount);
352 for (DWORD i=0; (i<dwByteCount) || (i>=PW_BUFF_LEN); i++)
353 (i%2 == 0) ? pbBuffer[i] ^= pcSalt[1] : pbBuffer[i] ^= pcSalt[0];
354
355 return String(pcSalt) + String((char *)pbBuffer);
|
356 mike 1.14 }
357
|
358 kumpf 1.26 Boolean System::isSystemUser(const char* userName)
|
359 mike 1.14 {
|
360 h.sterling 1.46 Boolean isSystemUser = false;
361
362 char mUserName[UNLEN+1];
363 char mDomainName[UNLEN+1];
364 wchar_t wUserName[UNLEN+1];
365 wchar_t wDomainName[UNLEN+1];
366 char* pbs;
367 bool usingDomain = false;
368
369 LPBYTE pComputerName=NULL;
370 DWORD dwLevel = 1;
371 LPUSER_INFO_1 pUserInfo = NULL;
372 NET_API_STATUS nStatus = NULL;
373
374 //separate the domain and user name if both are present.
375 if (NULL != (pbs = strchr(userName, '\\')))
376 {
377 *pbs = '\0';
378 strcpy(mDomainName, userName);
379 strcpy(mUserName, pbs+1);
380 usingDomain = true;
381 h.sterling 1.46
382 } else if ((NULL != (pbs = (strchr(userName, '@')))) ||
383 (NULL != (pbs = (strchr(userName, '.')))))
384 {
385 *pbs = '\0';
386 strcpy(mDomainName, pbs+1);
387 strcpy(mUserName, userName);
388 usingDomain = true;
389
390 } else
391 {
392 strcpy(mDomainName, ".");
393 strcpy(mUserName, userName);
394 }
395
396 //convert domain name to unicode
397 if (!MultiByteToWideChar(CP_ACP, 0, mDomainName, -1, wDomainName, strlen(mDomainName)+1))
398 {
399 return false;
400 }
401
402 h.sterling 1.46 //convert username to unicode
403 if (!MultiByteToWideChar(CP_ACP, 0, mUserName, -1, wUserName, strlen(mUserName)+1))
404 {
405 return false;
406 }
407
408 if (usingDomain)
409 {
410 //get domain controller
411 DWORD rc = NetGetDCName(NULL, wDomainName, &pComputerName);
412 if (rc == NERR_Success)
413 {
414 wcscpy(wDomainName, (LPWSTR) pComputerName); //this is automatically prefixed with "\\"
415 }
416 /*
417 else
418 {
419 // failover
420 // ATTN: This is commented out until there is resolution on Bugzilla 2236. -hns 2/2005
421 // This needs to be more thoroughly tested when we uncomment it out.
422
423 h.sterling 1.46 PDOMAIN_CONTROLLER_INFO DomainControllerInfo = NULL;
424
425 //this function does not take wide strings
426 rc = DsGetDcName(NULL,
427 mDomainName,
428 NULL,
429 NULL,
430 DS_DIRECTORY_SERVICE_REQUIRED, //not sure what flags we want here
431 &DomainControllerInfo);
432
433 if (rc == ERROR_SUCCESS && DomainControllerInfo)
434 {
435 strcpy(mDomainName, DomainControllerInfo->DomainName);
436 NetApiBufferFree(DomainControllerInfo);
437
438 if (!MultiByteToWideChar(CP_ACP, 0, mDomainName, -1, wDomainName, strlen(mDomainName)+1))
439 {
440 return false;
441 }
442 }
443 }
444 h.sterling 1.46 */
445 }
446
447 //get user info
448 nStatus = NetUserGetInfo(wDomainName,
449 wUserName,
450 dwLevel,
451 (LPBYTE *)&pUserInfo);
452
453 if (nStatus == NERR_Success)
454 {
455 isSystemUser = true;
456 }
457
458 if (pComputerName != NULL)
459 {
460 NetApiBufferFree(pComputerName);
461 }
462
463 if (pUserInfo != NULL)
464 {
465 h.sterling 1.46 NetApiBufferFree(pUserInfo);
466 }
467
468 return isSystemUser;
|
469 mike 1.14 }
470
|
471 h.sterling 1.46
|
472 david.dillard 1.43 Boolean System::isPrivilegedUser(const String& userName)
|
473 mike 1.14 {
|
474 h.sterling 1.46 Boolean isPrivileged = false;
475
476 char mUserName[UNLEN+1];
477 char mDomainName[UNLEN+1];
478 wchar_t wUserName[UNLEN+1];
479 wchar_t wDomainName[UNLEN+1];
480 char* pbs;
481 char userStr[UNLEN+1];
482 bool usingDomain = false;
483
484 LPBYTE pComputerName=NULL;
485 DWORD dwLevel = 1;
486 LPUSER_INFO_1 pUserInfo = NULL;
487 NET_API_STATUS nStatus = NULL;
488
489 //get the username in the correct format
490 strcpy(userStr, (const char*)userName.getCString());
491
492 //separate the domain and user name if both are present.
493 if (NULL != (pbs = strchr(userStr, '\\')))
494 {
495 h.sterling 1.46 *pbs = '\0';
496 strcpy(mDomainName, userStr);
497 strcpy(mUserName, pbs+1);
498 usingDomain = true;
499
500 } else if ((NULL != (pbs = (strchr(userStr, '@')))) ||
501 (NULL != (pbs = (strchr(userStr, '.')))))
502 {
503 *pbs = '\0';
504 strcpy(mDomainName, pbs+1);
505 strcpy(mUserName, userStr);
506 usingDomain = true;
507
508 } else
509 {
510 strcpy(mDomainName, ".");
511 strcpy(mUserName, userStr);
512 }
513
514 //convert domain name to unicode
515 if (!MultiByteToWideChar(CP_ACP, 0, mDomainName, -1, wDomainName, strlen(mDomainName)+1))
516 h.sterling 1.46 {
517 return false;
518 }
519
520 //convert username to unicode
521 if (!MultiByteToWideChar(CP_ACP, 0, mUserName, -1, wUserName, strlen(mUserName)+1))
522 {
523 return false;
524 }
525
526 if (usingDomain)
527 {
528 //get domain controller
529 DWORD rc = NetGetDCName(NULL, wDomainName, &pComputerName);
530 if (rc == NERR_Success)
531 {
532 wcscpy(wDomainName, (LPWSTR) pComputerName); //this is automatically prefixed with "\\"
533 }
534 /*
535 else
536 {
537 h.sterling 1.46 // failover
538 // ATTN: This is commented out until there is resolution on Bugzilla 2236. -hns 2/2005
539 // This needs to be more thoroughly tested when we uncomment it out.
540
541 PDOMAIN_CONTROLLER_INFO DomainControllerInfo = NULL;
542
543 //this function does not take wide strings
544 rc = DsGetDcName(NULL,
545 mDomainName,
546 NULL,
547 NULL,
548 DS_DIRECTORY_SERVICE_REQUIRED, //not sure what flags we want here
549 &DomainControllerInfo);
550
551 if (rc == ERROR_SUCCESS && DomainControllerInfo)
552 {
553 strcpy(mDomainName, DomainControllerInfo->DomainName);
554 NetApiBufferFree(DomainControllerInfo);
555
556 if (!MultiByteToWideChar(CP_ACP, 0, mDomainName, -1, wDomainName, strlen(mDomainName)+1))
557 {
558 h.sterling 1.46 return false;
559 }
560 }
561 }
562 */
563 }
564
565 //get privileges
566 nStatus = NetUserGetInfo(wDomainName,
567 wUserName,
568 dwLevel,
569 (LPBYTE *)&pUserInfo);
570
571 if ((nStatus == NERR_Success) &&
572 (pUserInfo != NULL) &&
573 (pUserInfo->usri1_priv == USER_PRIV_ADMIN))
574 {
575 isPrivileged = true;
576 }
577
578 if (pComputerName != NULL)
579 h.sterling 1.46 {
580 NetApiBufferFree(pComputerName);
581 }
582
583 if (pUserInfo != NULL)
584 {
585 NetApiBufferFree(pUserInfo);
586 }
587
588 return isPrivileged;
|
589 mike 1.14 }
|
590 kumpf 1.20
591 String System::getPrivilegedUserName()
592 {
593 // ATTN-NB-03-20000304: Implement better way to get the privileged
594 // user on the system.
595
596 return (String("Administrator"));
597 }
|
598 kumpf 1.37
599 Boolean System::isGroupMember(const char* userName, const char* groupName)
600 {
|
601 kumpf 1.38 Boolean retVal = false;
602
603 LPLOCALGROUP_USERS_INFO_0 pBuf = NULL;
604 DWORD dwLevel = 0;
605 DWORD dwFlags = LG_INCLUDE_INDIRECT ;
606 DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH;
607 DWORD dwEntriesRead = 0;
608 DWORD dwTotalEntries = 0;
609 NET_API_STATUS nStatus;
610
611
612 //
613 // Call the NetUserGetLocalGroups function
614 // specifying information level 0.
615 //
616 // The LG_INCLUDE_INDIRECT flag specifies that the
617 // function should also return the names of the local
618 // groups in which the user is indirectly a member.
619 //
620 nStatus = NetUserGetLocalGroups(NULL,
621 (LPCWSTR)userName,
622 kumpf 1.38 dwLevel,
623 dwFlags,
624 (LPBYTE *) &pBuf,
625 dwPrefMaxLen,
626 &dwEntriesRead,
627 &dwTotalEntries);
628
629 //
630 // If the call succeeds,
631 //
632 if (nStatus == NERR_Success)
633 {
634 LPLOCALGROUP_USERS_INFO_0 pTmpBuf;
635 DWORD i;
636 DWORD dwTotalCount = 0;
637
638 if ((pTmpBuf = pBuf) != NULL)
639 {
640 //
641 // Loop through the local groups that the user belongs
642 // and find the matching group name.
643 kumpf 1.38 //
644 for (i = 0; i < dwEntriesRead; i++)
645 {
646 //
647 // Compare the user's group name to groupName.
648 //
649 if ( strcmp ((char *)pTmpBuf->lgrui0_name, groupName) == 0 )
650 {
651 // User is a member of the group.
652 retVal = true;
653 break;
654 }
655
656 pTmpBuf++;
657 dwTotalCount++;
658 }
659 }
660 }
661
662 //
663 // Free the allocated memory.
664 kumpf 1.38 //
665 if (pBuf != NULL)
666 NetApiBufferFree(pBuf);
667
668 //
669 // If the given user and group are not found in the local group
670 // then try on the global groups.
671 //
672 if (!retVal)
673 {
674 LPGROUP_USERS_INFO_0 pBuf = NULL;
675 dwLevel = 0;
676 dwPrefMaxLen = MAX_PREFERRED_LENGTH;
677 dwEntriesRead = 0;
678 dwTotalEntries = 0;
679
680 //
681 // Call the NetUserGetGroups function, specifying level 0.
682 //
683 nStatus = NetUserGetGroups(NULL,
684 (LPCWSTR)userName,
685 kumpf 1.38 dwLevel,
686 (LPBYTE*)&pBuf,
687 dwPrefMaxLen,
688 &dwEntriesRead,
689 &dwTotalEntries);
690 //
691 // If the call succeeds,
692 //
693 if (nStatus == NERR_Success)
694 {
695 LPGROUP_USERS_INFO_0 pTmpBuf;
696 DWORD i;
697 DWORD dwTotalCount = 0;
698
699 if ((pTmpBuf = pBuf) != NULL)
700 {
701 //
702 // Loop through the global groups to which the user belongs
703 // and find the matching group name.
704 //
705 for (i = 0; i < dwEntriesRead; i++)
706 kumpf 1.38 {
707 //
708 // Compare the user's group name to groupName.
709 //
710 if ( strcmp ((char *)pTmpBuf->grui0_name, groupName) == 0 )
711 {
712 // User is a member of the group.
713 retVal = true;
714 break;
715 }
716
717 pTmpBuf++;
718 dwTotalCount++;
719 }
720 }
721 }
722
723 //
724 // Free the allocated buffer.
725 //
726 if (pBuf != NULL)
727 kumpf 1.38 NetApiBufferFree(pBuf);
728 }
729
730 return retVal;
|
731 kumpf 1.37 }
|
732 kumpf 1.44
733 Boolean System::changeUserContext(const char* userName)
734 {
735 // ATTN: Implement this method to change the process user context to the
736 // specified user
737 return false;
738 }
739
|
740 kumpf 1.15 Uint32 System::getPID()
741 {
|
742 kumpf 1.18 return _getpid();
|
743 mike 1.21 }
744
745 Boolean System::truncateFile(
746 const char* path,
747 size_t newSize)
748 {
749 int fd = open(path, O_RDWR);
750
751 if (fd == -1)
752 return false;
753
754 if (chsize(fd, newSize) != 0)
|
755 h.sterling 1.46 return false;
|
756 mike 1.21
757 close(fd);
758 return true;
|
759 kumpf 1.15 }
760
|
761 tony 1.27 // Is absolute path?
762 Boolean System::is_absolute_path(const char *path)
763 {
764 char full[_MAX_PATH];
|
765 tony 1.30 char path_slash[_MAX_PATH];
766 char *p;
767
768 strncpy(path_slash, path, _MAX_PATH);
769 path_slash[_MAX_PATH-1] = '\0';
770
771 for(p = path_slash; p < path_slash + strlen(path_slash); p++)
772 if (*p == '/') *p = '\\';
773
774 return (strcasecmp(_fullpath( full, path_slash, _MAX_PATH ), path_slash) == 0) ? true : false;
|
775 kumpf 1.34 }
776
777 // Changes file permissions on the given file.
778 Boolean System::changeFilePermissions(const char* path, mode_t mode)
779 {
780 // ATTN: File permissions are not currently defined in Windows
781 return true;
|
782 tony 1.27 }
|
783 david 1.29
|
784 kumpf 1.44 Boolean System::verifyFileOwnership(const char* path)
785 {
786 // ATTN: Implement this to check that the owner of the specified file is
787 // the same as the effective user for this process.
788 return true;
789 }
790
|
791 david.dillard 1.47 void System::openlog(const String &ident)
|
792 david 1.29 {
793 return;
794 }
795
796 void System::syslog(Uint32 severity, const char *data)
797 {
798 return;
799 }
800
801 void System::closelog()
802 {
803 return;
804 }
805
806 // System ID constants for Logger::put and Logger::trace
807 const String System::CIMSERVER = "cimserver"; // Server system ID
|
808 tony 1.27
|
809 mike 1.13 PEGASUS_NAMESPACE_END
|