6 #include <WINNT/afsclass.h>
11 * DEFINITIONS ________________________________________________________________
15 #define cREALLOC_ADMINLISTENTRIES 32
17 #define cREALLOC_HOSTLISTENTRIES 16
19 #define cREALLOC_SERVERKEYS 16
21 #define ACCOUNTACCESS_TO_USERACCESS(_aa) ( ((_aa) == aaOWNER_ONLY) ? PTS_USER_OWNER_ACCESS : PTS_USER_ANYUSER_ACCESS )
23 #define ACCOUNTACCESS_TO_GROUPACCESS(_aa) ( ((_aa) == aaOWNER_ONLY) ? PTS_GROUP_OWNER_ACCESS : ((_aa) == aaGROUP_ONLY) ? PTS_GROUP_ACCESS : PTS_GROUP_ANYUSER_ACCESS )
27 * PROTOTYPES _________________________________________________________________
33 * ROUTINES ___________________________________________________________________
37 BOOL AfsClass_GetServerLogFile (LPIDENT lpiServer, LPTSTR pszLocal, LPTSTR pszRemote, ULONG *pStatus)
43 NOTIFYCALLBACK::SendNotificationToAll (evtGetServerLogFileBegin, lpiServer, pszRemote, 0);
48 if ((lpServer = lpiServer->OpenServer (&status)) == NULL)
52 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
60 wp.wpBosLogGet.hServer = hBOS;
61 wp.wpBosLogGet.pszLogName = pszRemote;
62 wp.wpBosLogGet.pszLogData = NULL;
65 if ((rc = Worker_DoTask (wtaskBosLogGet, &wp, &status)) == TRUE)
68 if ((fh = CreateFile (pszLocal, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, NULL)) != INVALID_HANDLE_VALUE)
70 // Write the file a line at a time in order to make
71 // sure that each line ends with "\r\n". If we encounter
72 // a line which ends in \r\n already, well, leave it alone.
74 for (LPTSTR psz = wp.wpBosLogGet.pszLogData; psz && *psz; )
76 for (LPTSTR pszNext = psz; *pszNext && (*pszNext != TEXT('\r')) && (*pszNext != TEXT('\n')); ++pszNext)
80 if ((cbWrite = pszNext - psz) != 0)
81 WriteFile (fh, psz, cbWrite, &cbWrote, NULL);
82 WriteFile (fh, TEXT("\r\n"), 2, &cbWrote, NULL);
83 psz = (*pszNext == TEXT('\r')) ? (2+pszNext) : (*pszNext == TEXT('\n')) ? (1+pszNext) : NULL;
88 Free (wp.wpBosLogGet.pszLogData);
94 if ((lpServer = lpiServer->OpenServer (&status)) != NULL)
96 lpServer->CloseBosObject();
100 NOTIFYCALLBACK::SendNotificationToAll (evtGetServerLogFileEnd, lpiServer, pszRemote, status);
109 BOOL AfsClass_SetServerAuth (LPIDENT lpiServer, BOOL fEnabled, ULONG *pStatus)
115 NOTIFYCALLBACK::SendNotificationToAll (evtSetServerAuthBegin, lpiServer);
120 if ((lpServer = lpiServer->OpenServer (&status)) == NULL)
124 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
132 wp.wpBosAuthSet.hServer = hBOS;
133 wp.wpBosAuthSet.fEnableAuth = fEnabled;
136 rc = Worker_DoTask (wtaskBosAuthSet, &wp, &status);
140 if ((lpServer = lpiServer->OpenServer (&status)) != NULL)
142 lpServer->CloseBosObject();
146 NOTIFYCALLBACK::SendNotificationToAll (evtSetServerAuthEnd, lpiServer, status);
155 BOOL AfsClass_StartService (LPIDENT lpiStart, BOOL fTemporary, ULONG *pStatus)
161 NOTIFYCALLBACK::SendNotificationToAll (evtStartServiceBegin, lpiStart);
166 if ((lpServer = lpiStart->OpenServer (&status)) == NULL)
170 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
177 if (lpiStart->fIsService())
179 TCHAR szName[ cchNAME ];
180 lpiStart->GetServiceName (szName);
185 wp.wpBosProcessExecutionStateSetTemporary.hServer = hBOS;
186 wp.wpBosProcessExecutionStateSetTemporary.pszService = szName;
187 wp.wpBosProcessExecutionStateSetTemporary.state = SERVICESTATE_RUNNING;
190 rc = Worker_DoTask (wtaskBosProcessExecutionStateSetTemporary, &wp, &status);
196 wp.wpBosProcessExecutionStateSet.hServer = hBOS;
197 wp.wpBosProcessExecutionStateSet.pszService = szName;
198 wp.wpBosProcessExecutionStateSet.state = SERVICESTATE_RUNNING;
201 rc = Worker_DoTask (wtaskBosProcessExecutionStateSet, &wp, &status);
208 wp.wpBosProcessAllStart.hServer = hBOS;
210 rc = Worker_DoTask (wtaskBosProcessAllStart, &wp, &status);
217 if (lpiStart->fIsService())
220 if ((lpService = lpiStart->OpenService (&status)) == NULL)
224 lpService->Invalidate();
225 lpService->RefreshStatus();
231 if ((lpServer = lpiStart->OpenServer (&status)) == NULL)
235 lpServer->Invalidate();
236 lpServer->RefreshAll();
242 if ((lpServer = lpiStart->OpenServer (&status)) != NULL)
244 lpServer->CloseBosObject();
248 NOTIFYCALLBACK::SendNotificationToAll (evtStartServiceEnd, lpiStart, status);
257 BOOL AfsClass_StopService (LPIDENT lpiStop, BOOL fTemporary, BOOL fWait, ULONG *pStatus)
263 NOTIFYCALLBACK::SendNotificationToAll (evtStopServiceBegin, lpiStop);
268 if ((lpServer = lpiStop->OpenServer (&status)) == NULL)
272 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
279 if (lpiStop->fIsService())
281 TCHAR szName[ cchNAME ];
282 lpiStop->GetServiceName (szName);
287 wp.wpBosProcessExecutionStateSetTemporary.hServer = hBOS;
288 wp.wpBosProcessExecutionStateSetTemporary.pszService = szName;
289 wp.wpBosProcessExecutionStateSetTemporary.state = SERVICESTATE_STOPPED;
290 // TODO: wp.wpStopBosProcessTemporary.fWait = TRUE;
293 rc = Worker_DoTask (wtaskBosProcessExecutionStateSetTemporary, &wp, &status);
299 wp.wpBosProcessExecutionStateSet.hServer = hBOS;
300 wp.wpBosProcessExecutionStateSet.pszService = szName;
301 wp.wpBosProcessExecutionStateSet.state = SERVICESTATE_STOPPED;
302 // TODO: wp.wpStopBosProcess.fWait = TRUE;
305 rc = Worker_DoTask (wtaskBosProcessExecutionStateSet, &wp, &status);
312 wp.wpBosProcessAllWaitStop.hServer = hBOS;
315 rc = Worker_DoTask (wtaskBosProcessAllWaitStop, &wp, &status);
321 wp.wpBosProcessAllStop.hServer = hBOS;
324 rc = Worker_DoTask (wtaskBosProcessAllStop, &wp, &status);
331 if (lpiStop->fIsService())
334 if ((lpService = lpiStop->OpenService (&status)) == NULL)
338 lpService->Invalidate();
339 lpService->RefreshStatus();
346 if ((lpServer = lpiStop->OpenServer (&status)) == NULL)
350 lpServer->Invalidate();
351 lpServer->RefreshAll();
357 if ((lpServer = lpiStop->OpenServer (&status)) != NULL)
359 lpServer->CloseBosObject();
363 NOTIFYCALLBACK::SendNotificationToAll (evtStopServiceEnd, lpiStop, status);
372 BOOL AfsClass_RestartService (LPIDENT lpiRestart, ULONG *pStatus)
378 NOTIFYCALLBACK::SendNotificationToAll (evtRestartServiceBegin, lpiRestart);
383 if ((lpServer = lpiRestart->OpenServer (&status)) == NULL)
387 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
393 if (!lpiRestart->fIsService())
396 TCHAR szServiceRestart[ cchNAME ];
397 if (lpiRestart->fIsService())
399 lpiRestart->GetServiceName (szServiceRestart);
400 if (!lstrcmpi (szServiceRestart, TEXT("BOS")))
409 wp.wpBosProcessRestart.hServer = hBOS;
410 wp.wpBosProcessRestart.pszService = szServiceRestart;
413 rc = Worker_DoTask (wtaskBosProcessRestart, &wp, &status);
416 else // (fRestartAll)
419 wp.wpBosProcessAllStopAndRestart.hServer = hBOS;
420 wp.wpBosProcessAllStopAndRestart.fRestartBOS = TRUE;
423 rc = Worker_DoTask (wtaskBosProcessAllStopAndRestart, &wp, &status);
433 if ((lpService = lpiRestart->OpenService (&status)) == NULL)
437 lpService->Invalidate();
438 lpService->RefreshStatus();
442 else // (fRestartAll)
445 if ((lpServer = lpiRestart->OpenServer (&status)) == NULL)
449 lpServer->Invalidate();
450 lpServer->RefreshAll();
456 if ((lpServer = lpiRestart->OpenServer (&status)) != NULL)
458 lpServer->CloseBosObject();
462 NOTIFYCALLBACK::SendNotificationToAll (evtRestartServiceEnd, lpiRestart, status);
471 LPIDENT AfsClass_CreateFileset (LPIDENT lpiAggregate, LPTSTR pszFileset, ULONG ckQuota, ULONG *pStatus)
473 LPIDENT lpiFileset = NULL;
478 NOTIFYCALLBACK::SendNotificationToAll (evtCreateFilesetBegin, lpiAggregate, pszFileset, 0);
480 // Obtain hCell and hVOS
485 if ((lpServer = lpiAggregate->OpenServer (&status)) == NULL)
489 if ((hVOS = lpServer->OpenVosObject (&hCell, &status)) == NULL)
494 // Obtain idPartition
497 LPAGGREGATE lpAggregate;
498 if ((lpAggregate = lpiAggregate->OpenAggregate (&status)) == NULL)
502 idPartition = lpAggregate->GetID();
503 lpAggregate->Close();
506 // Perform the actual operation
511 wp.wpVosVolumeCreate.hCell = hCell;
512 wp.wpVosVolumeCreate.hServer = hVOS;
513 wp.wpVosVolumeCreate.idPartition = idPartition;
514 wp.wpVosVolumeCreate.pszVolume = pszFileset;
515 wp.wpVosVolumeCreate.ckQuota = ckQuota;
518 rc = Worker_DoTask (wtaskVosVolumeCreate, &wp, &status);
526 LPAGGREGATE lpAggregate;
527 if ((lpAggregate = lpiAggregate->OpenAggregate (&status)) == NULL)
531 lpAggregate->Invalidate();
532 lpAggregate->RefreshFilesets (TRUE, &status);
533 lpAggregate->Close();
540 if ((lpCell = lpiAggregate->OpenCell()) == NULL)
544 lpCell->RefreshVLDB (lpiAggregate);
551 LPAGGREGATE lpAggregate;
552 if ((lpAggregate = lpiAggregate->OpenAggregate (&status)) == NULL)
557 if ((lpFileset = lpAggregate->OpenFileset (pszFileset, &status)) == NULL)
561 lpiFileset = lpFileset->GetIdentifier();
564 lpAggregate->Close();
570 if ((lpServer = lpiAggregate->OpenServer (&status)) != NULL)
572 lpServer->CloseVosObject();
577 NOTIFYCALLBACK::SendNotificationToAll (evtCreateFilesetEnd, lpiAggregate, pszFileset, status);
582 return (rc) ? lpiFileset : NULL;
586 BOOL AfsClass_DeleteFileset (LPIDENT lpiFileset, BOOL fVLDB, BOOL fServer, ULONG *pStatus)
592 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteFilesetBegin, lpiFileset);
594 // Obtain hCell and hVOS
599 if ((lpServer = lpiFileset->OpenServer (&status)) == NULL)
603 if ((hVOS = lpServer->OpenVosObject (&hCell, &status)) == NULL)
608 // Does the fileset have a VLDB entry? Does it actually exist on the server?
609 // What's its volume ID? Its R/W ID? Its partition ID?
612 VOLUMEID vidReadWrite;
615 // Obtain the ID of the fileset's parent aggregate.
618 LPAGGREGATE lpAggregate;
619 if ((lpAggregate = lpiFileset->OpenAggregate (&status)) == NULL)
623 if ((idPartition = lpAggregate->GetID()) == NO_PARTITION)
625 lpAggregate->Close();
631 if ((lpFileset = lpiFileset->OpenFileset (&status)) == NULL)
635 wFilesetGhost = lpFileset->GetGhostStatus();
636 lpiFileset->GetFilesetID (&vidFileset);
639 if (!lpFileset->GetStatus (&fs))
640 vidReadWrite = vidFileset;
642 vidReadWrite = fs.idReadWrite;
648 if (!(wFilesetGhost & GHOST_HAS_VLDB_ENTRY))
650 if (!(wFilesetGhost & GHOST_HAS_SERVER_ENTRY))
653 if (rc && fVLDB && fServer)
656 wp.wpVosVolumeDelete.hCell = hCell;
657 wp.wpVosVolumeDelete.hServer = hVOS;
658 wp.wpVosVolumeDelete.idPartition = idPartition;
659 wp.wpVosVolumeDelete.idVolume = vidFileset;
662 rc = Worker_DoTask (wtaskVosVolumeDelete, &wp, &status);
665 else if (rc && fVLDB)
668 wp.wpVosVLDBEntryRemove.hCell = hCell;
669 wp.wpVosVLDBEntryRemove.hServer = hVOS;
670 wp.wpVosVLDBEntryRemove.idPartition = idPartition;
671 wp.wpVosVLDBEntryRemove.idVolume = vidReadWrite;
674 rc = Worker_DoTask (wtaskVosVLDBEntryRemove, &wp, &status);
677 else if (rc && fServer)
680 wp.wpVosVolumeZap.hCell = hCell;
681 wp.wpVosVolumeZap.hServer = hVOS;
682 wp.wpVosVolumeZap.idPartition = idPartition;
683 wp.wpVosVolumeZap.idVolume = vidFileset;
684 wp.wpVosVolumeZap.fForce = TRUE;
687 rc = Worker_DoTask (wtaskVosVolumeZap, &wp, &status);
693 LPAGGREGATE lpAggregate;
694 if ((lpAggregate = lpiFileset->OpenAggregate (&status)) == NULL)
698 lpAggregate->Invalidate();
699 lpAggregate->RefreshFilesets (TRUE);
700 lpAggregate->Close();
707 if ((lpCell = lpiFileset->OpenCell (&status)) == NULL)
711 lpCell->RefreshVLDB (lpiFileset->GetAggregate(), TRUE);
718 if ((lpServer = lpiFileset->OpenServer()) != NULL)
720 lpServer->CloseVosObject();
725 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteFilesetEnd, lpiFileset, status);
734 BOOL AfsClass_MoveFileset (LPIDENT lpiFileset, LPIDENT lpiAggregateTarget, ULONG *pStatus)
740 NOTIFYCALLBACK::SendNotificationToAll (evtMoveFilesetBegin, lpiFileset, lpiAggregateTarget, NULL, NULL, 0, 0);
742 LPIDENT lpiAggregateSource = lpiFileset->GetAggregate();
744 // Obtain hCell, hVOS and the aggregate name for the source
747 PVOID hVOSSource = NULL;
749 if ((lpServer = lpiFileset->OpenServer (&status)) == NULL)
753 if ((hVOSSource = lpServer->OpenVosObject (&hCell, &status)) == NULL)
758 // Obtain the ID of the source aggregate
760 int idPartitionSource;
761 LPAGGREGATE lpAggregate;
762 if ((lpAggregate = lpiFileset->OpenAggregate (&status)) == NULL)
766 if ((idPartitionSource = lpAggregate->GetID()) == NO_PARTITION)
768 lpAggregate->Close();
771 // Obtain hCell, hVOS and the aggregate name for the target
773 PVOID hVOSTarget = NULL;
774 if ((lpServer = lpiAggregateTarget->OpenServer (&status)) == NULL)
778 if ((hVOSTarget = lpServer->OpenVosObject (NULL, &status)) == NULL)
783 // Obtain the ID of the target aggregate
785 int idPartitionTarget;
786 if ((lpAggregate = lpiAggregateTarget->OpenAggregate (&status)) == NULL)
790 if ((idPartitionTarget = lpAggregate->GetID()) == NO_PARTITION)
792 lpAggregate->Close();
798 wp.wpVosVolumeMove.hCell = hCell;
799 wp.wpVosVolumeMove.hServerFrom = hVOSSource;
800 wp.wpVosVolumeMove.idPartitionFrom = idPartitionSource;
801 wp.wpVosVolumeMove.hServerTo = hVOSTarget;
802 wp.wpVosVolumeMove.idPartitionTo = idPartitionTarget;
803 lpiFileset->GetFilesetID (&wp.wpVosVolumeMove.idVolume);
806 rc = Worker_DoTask (wtaskVosVolumeMove, &wp, &status);
812 LPAGGREGATE lpAggregate;
813 if ((lpAggregate = lpiAggregateSource->OpenAggregate (&status)) == NULL)
817 lpAggregate->Invalidate();
818 lpAggregate->RefreshFilesets();
819 lpAggregate->Close();
825 LPAGGREGATE lpAggregate;
826 if ((lpAggregate = lpiAggregateTarget->OpenAggregate (&status)) == NULL)
830 lpAggregate->Invalidate();
831 lpAggregate->RefreshFilesets();
832 lpAggregate->Close();
839 if ((lpFileset = lpiFileset->OpenFileset (&status)) == NULL)
843 lpFileset->Invalidate();
844 lpFileset->RefreshStatus();
852 if ((lpCell = lpiFileset->OpenCell (&status)) == NULL)
856 lpCell->RefreshVLDB (lpiAggregateSource, TRUE);
857 lpCell->RefreshVLDB (lpiAggregateTarget, TRUE);
864 if ((lpServer = lpiAggregateSource->OpenServer()) != NULL)
866 lpServer->CloseVosObject();
872 if ((lpServer = lpiAggregateTarget->OpenServer()) != NULL)
874 lpServer->CloseVosObject();
879 NOTIFYCALLBACK::SendNotificationToAll (evtMoveFilesetEnd, lpiFileset, lpiAggregateTarget, NULL, NULL, 0, status);
888 BOOL AfsClass_SetFilesetQuota (LPIDENT lpiFileset, size_t ckQuotaNew, ULONG *pStatus)
894 NOTIFYCALLBACK::SendNotificationToAll (evtSetFilesetQuotaBegin, lpiFileset);
896 // Obtain hCell and hVOS for the server where this fileset lives
901 if ((lpServer = lpiFileset->OpenServer (&status)) == NULL)
905 if ((hVOS = lpServer->OpenVosObject (&hCell, &status)) == NULL)
910 // Obtain the ID of the fileset's parent aggregate.
915 LPAGGREGATE lpAggregate;
916 if ((lpAggregate = lpiFileset->OpenAggregate (&status)) == NULL)
920 if ((idPartition = lpAggregate->GetID()) == NO_PARTITION)
922 lpAggregate->Close();
926 // Change the fileset's quota.
931 wp.wpVosVolumeQuotaChange.hCell = hCell;
932 wp.wpVosVolumeQuotaChange.hServer = hVOS;
933 wp.wpVosVolumeQuotaChange.idPartition = idPartition;
934 lpiFileset->GetFilesetID (&wp.wpVosVolumeQuotaChange.idVolume);
935 wp.wpVosVolumeQuotaChange.ckQuota = ckQuotaNew;
938 rc = Worker_DoTask (wtaskVosVolumeQuotaChange, &wp, &status);
945 if ((lpFileset = lpiFileset->OpenFileset (&status)) == NULL)
949 lpFileset->Invalidate();
950 lpFileset->RefreshStatus();
957 LPAGGREGATE lpAggregate;
958 if ((lpAggregate = lpiFileset->OpenAggregate (&status)) == NULL)
962 lpAggregate->RefreshStatus();
963 lpAggregate->Close();
969 if ((lpServer = lpiFileset->OpenServer()) != NULL)
971 lpServer->CloseVosObject();
976 NOTIFYCALLBACK::SendNotificationToAll (evtSetFilesetQuotaEnd, lpiFileset, status);
985 BOOL AfsClass_SyncVLDB (LPIDENT lpiSync, BOOL fForce, ULONG *pStatus)
991 NOTIFYCALLBACK::SendNotificationToAll (evtSyncVLDBBegin, lpiSync);
993 // Obtain hCell and hVOS
998 if ((lpServer = lpiSync->OpenServer (&status)) == NULL)
1002 if ((hVOS = lpServer->OpenVosObject (&hCell, &status)) == NULL)
1007 // Obtain the ID of the target aggregate.
1009 int idPartition = NO_PARTITION;
1010 if (rc && (lpiSync->fIsAggregate() || lpiSync->fIsFileset()))
1012 LPAGGREGATE lpAggregate;
1013 if ((lpAggregate = lpiSync->OpenAggregate (&status)) == NULL)
1017 if ((idPartition = lpAggregate->GetID()) == NO_PARTITION)
1019 lpAggregate->Close();
1026 wp.wpVosVLDBSync.hCell = hCell;
1027 wp.wpVosVLDBSync.hServer = hVOS;
1028 wp.wpVosVLDBSync.idPartition = idPartition;
1029 wp.wpVosVLDBSync.fForce = fForce;
1032 rc = Worker_DoTask (wtaskVosVLDBSync, &wp, &status);
1038 if (lpiSync->fIsServer())
1041 if ((lpServer = lpiSync->OpenServer (&status)) == NULL)
1045 lpServer->Invalidate();
1046 rc = lpServer->RefreshAll (&status);
1050 else // (lpiSync->fIsAggregate())
1052 LPAGGREGATE lpAggregate;
1053 if ((lpAggregate = lpiSync->OpenAggregate (&status)) == NULL)
1057 lpAggregate->Invalidate();
1058 lpAggregate->RefreshStatus();
1059 lpAggregate->RefreshFilesets();
1060 lpAggregate->Close();
1063 if ((lpCell = lpiSync->OpenCell()) == NULL)
1067 lpCell->RefreshVLDB (lpiSync);
1076 if ((lpServer = lpiSync->OpenServer()) != NULL)
1078 lpServer->CloseVosObject();
1083 NOTIFYCALLBACK::SendNotificationToAll (evtSyncVLDBEnd, lpiSync, status);
1092 BOOL AfsClass_ChangeAddress (LPIDENT lpiServer, LPSOCKADDR_IN pAddrOld, LPSOCKADDR_IN pAddrNew, ULONG *pStatus)
1098 NOTIFYCALLBACK::SendNotificationToAll (evtChangeAddressBegin, lpiServer);
1104 if ((lpCell = lpiServer->OpenCell (&status)) == NULL)
1108 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
1116 wp.wpVosFileServerAddressChange.hCell = hCell;
1117 wp.wpVosFileServerAddressChange.addrOld = *pAddrOld;
1118 wp.wpVosFileServerAddressChange.addrNew = *pAddrNew;
1121 rc = Worker_DoTask (wtaskVosFileServerAddressChange, &wp, &status);
1124 else if (rc && !pAddrNew)
1127 wp.wpVosFileServerAddressRemove.hCell = hCell;
1128 wp.wpVosFileServerAddressRemove.addr = *pAddrOld;
1131 rc = Worker_DoTask (wtaskVosFileServerAddressRemove, &wp, &status);
1138 if ((lpServer = lpiServer->OpenServer (&status)) != NULL)
1140 lpServer->InvalidateStatus();
1145 if ((lpCell = lpiServer->OpenCell (&status)) == NULL)
1149 lpCell->InvalidateServers ();
1150 rc = lpCell->RefreshServers (TRUE, &status);
1155 NOTIFYCALLBACK::SendNotificationToAll (evtChangeAddressEnd, lpiServer, status);
1164 BOOL AfsClass_ChangeAddress (LPIDENT lpiServer, LPSERVERSTATUS pStatusOld, LPSERVERSTATUS pStatusNew, ULONG *pStatus)
1170 NOTIFYCALLBACK::SendNotificationToAll (evtChangeAddressBegin, lpiServer);
1176 if ((lpCell = lpiServer->OpenCell (&status)) == NULL)
1180 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
1189 for (size_t iAddr = 0; rc && (iAddr < AFSCLASS_MAX_ADDRESSES_PER_SITE); ++iAddr)
1193 AfsClass_AddressToInt (&oldAddress, &pStatusOld->aAddresses[ iAddr ]);
1194 AfsClass_AddressToInt (&newAddress, &pStatusNew->aAddresses[ iAddr ]);
1196 if (oldAddress && newAddress && (oldAddress != newAddress))
1199 wp.wpVosFileServerAddressChange.hCell = hCell;
1200 wp.wpVosFileServerAddressChange.addrOld = pStatusOld->aAddresses[ iAddr ];
1201 wp.wpVosFileServerAddressChange.addrNew = pStatusNew->aAddresses[ iAddr ];
1203 rc = Worker_DoTask (wtaskVosFileServerAddressChange, &wp, &status);
1205 else if (oldAddress && !newAddress)
1208 wp.wpVosFileServerAddressRemove.hCell = hCell;
1209 wp.wpVosFileServerAddressRemove.addr = pStatusOld->aAddresses[ iAddr ];
1211 rc = Worker_DoTask (wtaskVosFileServerAddressRemove, &wp, &status);
1221 if ((lpServer = lpiServer->OpenServer (&status)) != NULL)
1223 lpServer->InvalidateStatus();
1228 if ((lpCell = lpiServer->OpenCell (&status)) == NULL)
1232 lpCell->InvalidateServers ();
1233 rc = lpCell->RefreshServers (TRUE, &status);
1238 NOTIFYCALLBACK::SendNotificationToAll (evtChangeAddressEnd, lpiServer, status);
1247 BOOL AfsClass_LockFileset (LPIDENT lpiFileset, ULONG *pStatus)
1253 NOTIFYCALLBACK::SendNotificationToAll (evtLockFilesetBegin, lpiFileset);
1259 if ((lpCell = lpiFileset->OpenCell (&status)) == NULL)
1263 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
1268 // Obtain the fileset's read-write identifier
1270 LPIDENT lpiRW = NULL;
1271 LPFILESET lpFileset;
1272 if ((lpFileset = lpiFileset->OpenFileset (&status)) == NULL)
1276 if ((lpiRW = lpFileset->GetReadWriteIdentifier()) == NULL)
1281 // Perform the lock operation
1286 wp.wpVosVLDBEntryLock.hCell = hCell;
1287 lpiRW->GetFilesetID (&wp.wpVosVLDBEntryLock.idVolume);
1290 rc = Worker_DoTask (wtaskVosVLDBEntryLock, &wp, &status);
1297 if ((lpCell = lpiFileset->OpenCell (&status)) == NULL)
1302 lpCell->RefreshVLDB (lpiRW, TRUE, NULL, TRUE);
1304 lpCell->RefreshVLDB (lpiFileset->GetCell());
1309 NOTIFYCALLBACK::SendNotificationToAll (evtLockFilesetEnd, lpiFileset, status);
1318 BOOL AfsClass_UnlockFileset (LPIDENT lpiFileset, ULONG *pStatus)
1324 NOTIFYCALLBACK::SendNotificationToAll (evtUnlockFilesetBegin, lpiFileset);
1330 if ((lpCell = lpiFileset->OpenCell (&status)) == NULL)
1334 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
1339 // Obtain the fileset's read-write identifier
1341 LPIDENT lpiRW = NULL;
1342 LPFILESET lpFileset;
1343 if ((lpFileset = lpiFileset->OpenFileset (&status)) == NULL)
1347 if ((lpiRW = lpFileset->GetReadWriteIdentifier()) == NULL)
1352 // Perform the unlock operation
1357 wp.wpVosVLDBEntryUnlock.hCell = hCell;
1358 wp.wpVosVLDBEntryUnlock.hServer = NULL;
1359 wp.wpVosVLDBEntryUnlock.idPartition = NO_PARTITION;
1360 lpiRW->GetFilesetID (&wp.wpVosVLDBEntryUnlock.idVolume);
1363 rc = Worker_DoTask (wtaskVosVLDBEntryUnlock, &wp, &status);
1370 if ((lpCell = lpiFileset->OpenCell (&status)) == NULL)
1375 lpCell->RefreshVLDB (lpiRW, TRUE, NULL, TRUE);
1377 lpCell->RefreshVLDB (lpiFileset->GetCell());
1382 NOTIFYCALLBACK::SendNotificationToAll (evtUnlockFilesetEnd, lpiFileset, status);
1391 BOOL AfsClass_UnlockAllFilesets (LPIDENT lpi, ULONG *pStatus)
1397 NOTIFYCALLBACK::SendNotificationToAll (evtUnlockAllFilesetsBegin, lpi);
1403 if ((lpCell = lpi->OpenCell (&status)) == NULL)
1407 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
1412 // Obtain hServer if appropriate
1415 if (lpi && (!lpi->fIsCell()))
1418 if ((lpServer = lpi->OpenServer (&status)) == NULL)
1422 if ((hVOS = lpServer->OpenVosObject (NULL, &status)) == NULL)
1428 // Obtain the ID of the scope aggregate.
1430 int idPartition = NO_PARTITION;
1431 if (rc && (lpi->fIsFileset() || (lpi->fIsAggregate())))
1433 LPAGGREGATE lpAggregate;
1434 if ((lpAggregate = lpi->OpenAggregate (&status)) == NULL)
1438 if ((idPartition = lpAggregate->GetID()) == NO_PARTITION)
1440 lpAggregate->Close();
1444 // Perform the unlock operation
1449 wp.wpVosVLDBEntryUnlock.hCell = hCell;
1450 wp.wpVosVLDBEntryUnlock.hServer = hVOS;
1451 wp.wpVosVLDBEntryUnlock.idPartition = idPartition;
1452 wp.wpVosVLDBEntryUnlock.idVolume = NO_VOLUME;
1455 rc = Worker_DoTask (wtaskVosVLDBEntryUnlock, &wp, &status);
1462 if ((lpCell = lpi->OpenCell (&status)) == NULL)
1466 lpCell->RefreshVLDB (lpi);
1474 if ((lpServer = lpi->OpenServer (&status)) != NULL)
1476 lpServer->CloseVosObject();
1481 NOTIFYCALLBACK::SendNotificationToAll (evtUnlockAllFilesetsEnd, lpi);
1490 LPIDENT AfsClass_CreateReplica (LPIDENT lpiFileset, LPIDENT lpiAggregate, ULONG *pStatus)
1494 LPIDENT lpiReplica = NULL;
1497 NOTIFYCALLBACK::SendNotificationToAll (evtCreateReplicaBegin, lpiFileset, lpiAggregate, NULL, NULL, 0, 0);
1499 // Obtain hCell and hVOS for the target server
1504 if ((lpServer = lpiAggregate->OpenServer (&status)) == NULL)
1508 if ((hVOS = lpServer->OpenVosObject (&hCell, &status)) == NULL)
1513 // Obtain idPartition
1516 LPAGGREGATE lpAggregate;
1517 if ((lpAggregate = lpiAggregate->OpenAggregate (&status)) == NULL)
1521 idPartition = lpAggregate->GetID();
1522 lpAggregate->Close();
1525 // Modify VLDB to create mention of a new replica
1530 wp.wpVosVLDBReadOnlySiteCreate.hCell = hCell;
1531 wp.wpVosVLDBReadOnlySiteCreate.hServer = hVOS;
1532 wp.wpVosVLDBReadOnlySiteCreate.idPartition = idPartition;
1533 lpiFileset->GetFilesetID (&wp.wpVosVLDBReadOnlySiteCreate.idVolume);
1536 rc = Worker_DoTask (wtaskVosVLDBReadOnlySiteCreate, &wp, &status);
1544 LPAGGREGATE lpAggregate;
1545 if ((lpAggregate = lpiAggregate->OpenAggregate (&status)) == NULL)
1549 lpAggregate->Invalidate();
1550 lpAggregate->RefreshFilesets (TRUE, &status);
1551 lpAggregate->Close();
1558 if ((lpCell = lpiAggregate->OpenCell()) == NULL)
1562 lpCell->RefreshVLDB (lpiAggregate);
1569 LPFILESET lpFileset;
1570 if ((lpFileset = lpiFileset->OpenFileset (&status)) == NULL)
1574 if ((lpiReplica = lpFileset->GetReadOnlyIdentifier (lpiAggregate, &status)) == NULL)
1582 if ((lpServer = lpiAggregate->OpenServer (&status)) != NULL)
1584 lpServer->CloseVosObject();
1589 NOTIFYCALLBACK::SendNotificationToAll (evtCreateReplicaEnd, lpiFileset, lpiAggregate, NULL, NULL, 0, status);
1594 return (rc) ? lpiReplica : FALSE;
1598 BOOL AfsClass_DeleteReplica (LPIDENT lpiReplica, ULONG *pStatus)
1604 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteFilesetBegin, lpiReplica);
1606 // Obtain hCell and hVOS for the server
1611 if ((lpServer = lpiReplica->OpenServer (&status)) == NULL)
1615 if ((hVOS = lpServer->OpenVosObject (&hCell, &status)) == NULL)
1620 // Get the read/write fileset identifier and Ghost status
1622 LPIDENT lpiRW = NULL;
1623 int wFilesetGhost = 0;
1624 LPFILESET lpFileset;
1625 if ((lpFileset = lpiReplica->OpenFileset (&status)) == NULL)
1629 wFilesetGhost = lpFileset->GetGhostStatus();
1630 if ((lpiRW = lpFileset->GetReadWriteIdentifier()) == NULL)
1635 TCHAR szAggregateName[ cchNAME ];
1636 lpiReplica->GetAggregateName (szAggregateName);
1638 // Obtain the ID of the replica's partition
1641 LPAGGREGATE lpAggregate;
1642 if ((lpAggregate = lpiReplica->OpenAggregate (&status)) == NULL)
1646 idPartition = lpAggregate->GetID();
1647 lpAggregate->Close();
1650 // If the volume exists in both VLDB and on the server, just delete it
1652 if (rc && (wFilesetGhost & GHOST_HAS_VLDB_ENTRY) && (wFilesetGhost & GHOST_HAS_SERVER_ENTRY))
1655 wp.wpVosVolumeDelete.hCell = hCell;
1656 wp.wpVosVolumeDelete.hServer = hVOS;
1657 wp.wpVosVolumeDelete.idPartition = idPartition;
1658 lpiReplica->GetFilesetID (&wp.wpVosVolumeDelete.idVolume);
1661 rc = Worker_DoTask (wtaskVosVolumeDelete, &wp, &status);
1666 // If necessary, modify VLDB to remove mention of this replica
1668 if (rc && (wFilesetGhost & GHOST_HAS_VLDB_ENTRY))
1671 wp.wpVosVLDBReadOnlySiteDelete.hCell = hCell;
1672 wp.wpVosVLDBReadOnlySiteDelete.hServer = hVOS;
1673 wp.wpVosVLDBReadOnlySiteDelete.idPartition = idPartition;
1674 lpiRW->GetFilesetID (&wp.wpVosVLDBReadOnlySiteDelete.idVolume);
1677 rc = Worker_DoTask (wtaskVosVLDBReadOnlySiteDelete, &wp, &status);
1681 // If necessary, zap the volume
1683 if (rc && (wFilesetGhost & GHOST_HAS_SERVER_ENTRY))
1686 wp.wpVosVolumeZap.hCell = hCell;
1687 wp.wpVosVolumeZap.hServer = hVOS;
1688 wp.wpVosVolumeZap.idPartition = idPartition;
1689 lpiReplica->GetFilesetID (&wp.wpVosVolumeZap.idVolume);
1690 wp.wpVosVolumeZap.fForce = TRUE;
1693 rc = Worker_DoTask (wtaskVosVolumeZap, &wp, &status);
1702 LPAGGREGATE lpAggregate;
1703 if ((lpAggregate = lpiReplica->OpenAggregate (&status)) == NULL)
1707 lpAggregate->Invalidate();
1708 lpAggregate->RefreshFilesets (TRUE, &status);
1709 lpAggregate->Close();
1716 if ((lpCell = lpiReplica->OpenCell()) == NULL)
1720 lpCell->RefreshVLDB (lpiReplica->GetAggregate());
1727 if ((lpServer = lpiReplica->OpenServer (&status)) != NULL)
1729 lpServer->CloseVosObject();
1734 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteFilesetEnd, lpiReplica, status);
1743 BOOL AfsClass_DeleteClone (LPIDENT lpiClone, ULONG *pStatus)
1745 return AfsClass_DeleteFileset (lpiClone, TRUE, TRUE, pStatus);
1749 BOOL AfsClass_InstallFile (LPIDENT lpiServer, LPTSTR pszTarget, LPTSTR pszSource, ULONG *pStatus)
1755 NOTIFYCALLBACK::SendNotificationToAll (evtInstallFileBegin, lpiServer, pszSource, 0);
1760 if ((lpServer = lpiServer->OpenServer (&status)) == NULL)
1764 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
1772 wp.wpBosExecutableCreate.hServer = hBOS;
1773 wp.wpBosExecutableCreate.pszLocal = pszSource;
1774 wp.wpBosExecutableCreate.pszRemoteDir = pszTarget;
1777 rc = Worker_DoTask (wtaskBosExecutableCreate, &wp, &status);
1781 if ((lpServer = lpiServer->OpenServer (&status)) != NULL)
1783 lpServer->CloseBosObject();
1787 NOTIFYCALLBACK::SendNotificationToAll (evtInstallFileEnd, lpiServer, pszSource, status);
1796 BOOL AfsClass_UninstallFile (LPIDENT lpiServer, LPTSTR pszUninstall, ULONG *pStatus)
1802 NOTIFYCALLBACK::SendNotificationToAll (evtUninstallFileBegin, lpiServer, pszUninstall, 0);
1807 if ((lpServer = lpiServer->OpenServer (&status)) == NULL)
1811 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
1819 wp.wpBosExecutableRevert.hServer = hBOS;
1820 wp.wpBosExecutableRevert.pszFilename = pszUninstall;
1823 rc = Worker_DoTask (wtaskBosExecutableRevert, &wp, &status);
1827 if ((lpServer = lpiServer->OpenServer (&status)) != NULL)
1829 lpServer->CloseBosObject();
1833 NOTIFYCALLBACK::SendNotificationToAll (evtUninstallFileEnd, lpiServer, pszUninstall, status);
1842 BOOL AfsClass_PruneOldFiles (LPIDENT lpiServer, BOOL fBAK, BOOL fOLD, BOOL fCore, ULONG *pStatus)
1848 NOTIFYCALLBACK::SendNotificationToAll (evtPruneFilesBegin, lpiServer);
1853 if ((lpServer = lpiServer->OpenServer (&status)) == NULL)
1857 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
1865 wp.wpBosExecutablePrune.hServer = hBOS;
1866 wp.wpBosExecutablePrune.fPruneBak = fBAK;
1867 wp.wpBosExecutablePrune.fPruneOld = fOLD;
1868 wp.wpBosExecutablePrune.fPruneCore = fCore;
1871 rc = Worker_DoTask (wtaskBosExecutablePrune, &wp, &status);
1875 if ((lpServer = lpiServer->OpenServer (&status)) != NULL)
1877 lpServer->CloseBosObject();
1881 NOTIFYCALLBACK::SendNotificationToAll (evtPruneFilesEnd, lpiServer, status);
1890 BOOL AfsClass_RenameFileset (LPIDENT lpiFileset, LPTSTR pszNewName, ULONG *pStatus)
1896 NOTIFYCALLBACK::SendNotificationToAll (evtRenameFilesetBegin, lpiFileset, pszNewName, 0);
1900 if ((lpCell = lpiFileset->OpenCell (&status)) == NULL)
1904 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
1912 wp.wpVosVolumeRename.hCell = hCell;
1913 lpiFileset->GetFilesetID (&wp.wpVosVolumeRename.idVolume);
1914 wp.wpVosVolumeRename.pszVolume = pszNewName;
1917 rc = Worker_DoTask (wtaskVosVolumeRename, &wp, &status);
1924 if ((lpCell = lpiFileset->OpenCell (&status)) == NULL)
1928 lpCell->Invalidate();
1929 rc = lpCell->RefreshAll (&status);
1935 NOTIFYCALLBACK::SendNotificationToAll (evtRenameFilesetEnd, lpiFileset, pszNewName, status);
1944 #define iswhite(_ch) ((_ch)==TEXT(' ') || (_ch)==TEXT('\t'))
1946 LPIDENT AfsClass_CreateService (LPIDENT lpiServer, LPTSTR pszService, LPTSTR pszCommand, LPTSTR pszParams, LPTSTR pszNotifier, SERVICETYPE type, SYSTEMTIME *pstIfCron, ULONG *pStatus)
1950 LPIDENT lpiService = NULL;
1953 NOTIFYCALLBACK::SendNotificationToAll (evtCreateServiceBegin, lpiServer, pszService, 0);
1958 if ((lpServer = lpiServer->OpenServer (&status)) == NULL)
1962 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
1970 wp.wpBosProcessCreate.hServer = hBOS;
1971 wp.wpBosProcessCreate.pszService = pszService;
1972 wp.wpBosProcessCreate.type = type;
1973 wp.wpBosProcessCreate.pszNotifier = pszNotifier;
1975 TCHAR szFullCommand[ MAX_PATH + MAX_PATH ];
1976 wsprintf (szFullCommand, TEXT("%s %s"), pszCommand, pszParams);
1977 wp.wpBosProcessCreate.pszCommand = szFullCommand;
1979 TCHAR szCronTime[ 256 ] = TEXT("");
1980 wp.wpBosProcessCreate.pszTimeCron = szCronTime;
1982 if (type == SERVICETYPE_CRON)
1983 AfsClass_FormatRecurringTime (szCronTime, pstIfCron);
1985 wp.wpBosProcessCreate.pszTimeCron = NULL;
1988 rc = Worker_DoTask (wtaskBosProcessCreate, &wp, &status);
1994 if ((lpServer = lpiServer->OpenServer (&status)) == NULL)
1998 lpServer->InvalidateServices();
1999 if (!lpServer->RefreshServices (TRUE, &status))
2003 LPSERVICE lpService;
2004 if ((lpService = lpServer->OpenService (pszService, &status)) == NULL)
2008 lpiService = lpService->GetIdentifier();
2016 if ((lpServer = lpiServer->OpenServer (&status)) != NULL)
2018 lpServer->CloseBosObject();
2022 NOTIFYCALLBACK::SendNotificationToAll (evtCreateServiceEnd, lpiServer, pszService, status);
2027 return (rc) ? lpiService : NULL;
2031 BOOL AfsClass_DeleteService (LPIDENT lpiService, ULONG *pStatus)
2037 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteServiceBegin, lpiService);
2042 if ((lpServer = lpiService->OpenServer (&status)) == NULL)
2046 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
2051 // Before a service can be deleted, it must be stopped (otherwise, on NT,
2052 // the Delete operation won't block for the required Stop to complete--
2053 // so our wtaskDeleteBosProcess would return before the service really
2058 TCHAR szService[ cchNAME ];
2059 lpiService->GetServiceName (szService);
2062 wp.wpBosProcessExecutionStateSet.hServer = hBOS;
2063 wp.wpBosProcessExecutionStateSet.pszService = szService;
2064 wp.wpBosProcessExecutionStateSet.state = SERVICESTATE_STOPPED;
2065 // TODO: wp.wpStopBosProcess.fWait = TRUE;
2068 rc = Worker_DoTask (wtaskBosProcessExecutionStateSet, &wp, &status);
2072 // Delete the service
2076 TCHAR szService[ cchNAME ];
2077 lpiService->GetServiceName (szService);
2080 wp.wpBosProcessDelete.hServer = hBOS;
2081 wp.wpBosProcessDelete.pszService = szService;
2084 rc = Worker_DoTask (wtaskBosProcessDelete, &wp, &status);
2090 if ((lpServer = lpiService->OpenServer (&status)) == NULL)
2094 lpServer->InvalidateServices();
2095 if (!lpServer->RefreshServices (TRUE, &status))
2101 if ((lpServer = lpiService->OpenServer (&status)) != NULL)
2103 lpServer->CloseBosObject();
2107 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteServiceEnd, lpiService, status);
2116 BOOL AfsClass_ReleaseFileset (LPIDENT lpiFilesetRW, BOOL fForce, ULONG *pStatus)
2122 NOTIFYCALLBACK::SendNotificationToAll (evtReleaseFilesetBegin, lpiFilesetRW);
2124 // Obtain hCell and hVOS
2129 if ((lpServer = lpiFilesetRW->OpenServer (&status)) == NULL)
2133 if ((hVOS = lpServer->OpenVosObject (&hCell, &status)) == NULL)
2138 // Perform the actual operation
2143 wp.wpVosVolumeRelease.hCell = hCell;
2144 wp.wpVosVolumeRelease.fForce = fForce;
2145 lpiFilesetRW->GetFilesetID (&wp.wpVosVolumeRelease.idVolume);
2148 rc = Worker_DoTask (wtaskVosVolumeRelease, &wp, &status);
2157 if ((lpCell = lpiFilesetRW->OpenCell (&status)) == NULL)
2161 lpCell->Invalidate();
2162 rc = lpCell->RefreshAll (&status);
2169 if ((lpServer = lpiFilesetRW->OpenServer (&status)) != NULL)
2171 lpServer->CloseVosObject();
2176 NOTIFYCALLBACK::SendNotificationToAll (evtReleaseFilesetEnd, lpiFilesetRW, status);
2185 BOOL AfsClass_GetFileDates (LPIDENT lpiServer, LPTSTR pszFilename, SYSTEMTIME *pstFile, SYSTEMTIME *pstBAK, SYSTEMTIME *pstOLD, ULONG *pStatus)
2191 NOTIFYCALLBACK::SendNotificationToAll (evtGetFileDatesBegin, lpiServer, pszFilename, 0);
2196 if ((lpServer = lpiServer->OpenServer (&status)) == NULL)
2200 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
2208 wp.wpBosExecutableTimestampGet.hServer = hBOS;
2209 wp.wpBosExecutableTimestampGet.pszFilename = pszFilename;
2212 if ((rc = Worker_DoTask (wtaskBosExecutableTimestampGet, &wp, &status)) == TRUE)
2214 *pstFile = wp.wpBosExecutableTimestampGet.timeNew;
2215 *pstBAK = wp.wpBosExecutableTimestampGet.timeBak;
2216 *pstOLD = wp.wpBosExecutableTimestampGet.timeOld;
2222 if ((lpServer = lpiServer->OpenServer (&status)) != NULL)
2224 lpServer->CloseBosObject();
2228 NOTIFYCALLBACK::SendNotificationToAll (evtGetFileDatesEnd, lpiServer, pszFilename, status);
2237 BOOL AfsClass_ExecuteCommand (LPIDENT lpiServer, LPTSTR pszCommand, ULONG *pStatus)
2243 NOTIFYCALLBACK::SendNotificationToAll (evtExecuteCommandBegin, lpiServer, pszCommand, 0);
2248 if ((lpServer = lpiServer->OpenServer (&status)) == NULL)
2252 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
2260 wp.wpBosCommandExecute.hServer = hBOS;
2261 wp.wpBosCommandExecute.pszCommand = pszCommand;
2264 rc = Worker_DoTask (wtaskBosCommandExecute, &wp, &status);
2268 if ((lpServer = lpiServer->OpenServer (&status)) != NULL)
2270 lpServer->CloseBosObject();
2274 NOTIFYCALLBACK::SendNotificationToAll (evtExecuteCommandEnd, lpiServer, pszCommand, status);
2283 LPADMINLIST AfsClass_AdminList_Load (LPIDENT lpiServer, ULONG *pStatus)
2287 LPADMINLIST lpList = NULL;
2290 NOTIFYCALLBACK::SendNotificationToAll (evtAdminListLoadBegin, lpiServer);
2295 if ((lpServer = lpiServer->OpenServer (&status)) == NULL)
2299 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
2306 lpList = New(ADMINLIST);
2307 memset (lpList, 0x00, sizeof(ADMINLIST));
2309 lpList->lpiServer = lpiServer;
2311 WORKERPACKET wpBegin;
2312 wpBegin.wpBosAdminGetBegin.hServer = hBOS;
2313 if (!Worker_DoTask (wtaskBosAdminGetBegin, &wpBegin, &status))
2319 TCHAR szAdmin[ cchNAME ];
2321 WORKERPACKET wpNext;
2322 wpNext.wpBosAdminGetNext.hEnum = wpBegin.wpBosAdminGetBegin.hEnum;
2323 wpNext.wpBosAdminGetNext.pszAdmin = szAdmin;
2325 if (!Worker_DoTask (wtaskBosAdminGetNext, &wpNext, &status))
2327 if (status == ADMITERATORDONE)
2335 if ((iAdded = AfsClass_AdminList_AddEntry (lpList, szAdmin)) != (size_t)-1)
2337 lpList->aEntries[ iAdded ].fAdded = FALSE;
2341 WORKERPACKET wpDone;
2342 wpDone.wpBosAdminGetDone.hEnum = wpBegin.wpBosAdminGetBegin.hEnum;
2343 Worker_DoTask (wtaskBosAdminGetDone, &wpDone);
2347 if ((lpServer = lpiServer->OpenServer (&status)) != NULL)
2349 lpServer->CloseBosObject();
2353 NOTIFYCALLBACK::SendNotificationToAll (evtAdminListLoadEnd, lpiServer, status);
2358 return (rc) ? lpList : NULL;
2362 LPADMINLIST AfsClass_AdminList_Copy (LPADMINLIST lpOld)
2364 LPADMINLIST lpNew = NULL;
2368 lpNew = New(ADMINLIST);
2369 memcpy (lpNew, lpOld, sizeof(ADMINLIST));
2372 lpNew->aEntries = 0;
2373 lpNew->cEntries = 0;
2375 if (REALLOC (lpNew->aEntries, lpNew->cEntries, lpOld->cEntries, cREALLOC_ADMINLISTENTRIES))
2377 size_t cb = lpOld->cEntries * sizeof(ADMINLISTENTRY);
2378 memcpy (lpNew->aEntries, lpOld->aEntries, cb);
2386 BOOL AfsClass_AdminList_Save (LPADMINLIST lpList, ULONG *pStatus)
2392 NOTIFYCALLBACK::SendNotificationToAll (evtAdminListSaveBegin, lpList->lpiServer);
2397 if ((lpServer = lpList->lpiServer->OpenServer (&status)) == NULL)
2401 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
2408 for (size_t iEntry = 0; iEntry < lpList->cEntries; ++iEntry)
2410 if (!lpList->aEntries[ iEntry ].szAdmin[0])
2413 // are we supposed to add this entry?
2415 if (lpList->aEntries[ iEntry ].fAdded && !lpList->aEntries[ iEntry ].fDeleted)
2418 wp.wpBosAdminCreate.hServer = hBOS;
2419 wp.wpBosAdminCreate.pszAdmin = lpList->aEntries[ iEntry ].szAdmin;
2422 if (!Worker_DoTask (wtaskBosAdminCreate, &wp, &thisstatus))
2425 status = thisstatus;
2429 lpList->aEntries[ iEntry ].fAdded = FALSE;
2433 // are we supposed to delete this entry?
2435 if (!lpList->aEntries[ iEntry ].fAdded && lpList->aEntries[ iEntry ].fDeleted)
2438 wp.wpBosAdminDelete.hServer = hBOS;
2439 wp.wpBosAdminDelete.pszAdmin = lpList->aEntries[ iEntry ].szAdmin;
2442 if (!Worker_DoTask (wtaskBosAdminDelete, &wp, &thisstatus))
2445 status = thisstatus;
2449 lpList->aEntries[ iEntry ].szAdmin[0] = TEXT('\0');
2450 lpList->aEntries[ iEntry ].fDeleted = FALSE;
2456 if ((lpServer = lpList->lpiServer->OpenServer (&status)) != NULL)
2458 lpServer->CloseBosObject();
2462 NOTIFYCALLBACK::SendNotificationToAll (evtAdminListSaveEnd, lpList->lpiServer, status);
2471 void AfsClass_AdminList_Free (LPADMINLIST lpList)
2473 if (lpList && !InterlockedDecrement (&lpList->cRef))
2475 if (lpList->aEntries)
2476 Free (lpList->aEntries);
2477 memset (lpList, 0x00, sizeof(ADMINLIST));
2483 size_t AfsClass_AdminList_AddEntry (LPADMINLIST lpList, LPTSTR pszAdmin)
2485 size_t iAdded = (size_t)-1;
2489 for (size_t iEntry = 0; iEntry < lpList->cEntries; ++iEntry)
2491 if (!lpList->aEntries[ iEntry ].szAdmin[0])
2494 if (iEntry >= lpList->cEntries)
2496 (void)REALLOC (lpList->aEntries, lpList->cEntries, 1+iEntry, cREALLOC_ADMINLISTENTRIES);
2498 if (iEntry < lpList->cEntries)
2501 lstrcpy (lpList->aEntries[ iAdded ].szAdmin, pszAdmin);
2502 lpList->aEntries[ iAdded ].fAdded = TRUE;
2503 lpList->aEntries[ iAdded ].fDeleted = FALSE;
2511 BOOL AfsClass_AdminList_DelEntry (LPADMINLIST lpList, size_t iIndex)
2516 (iIndex < lpList->cEntries) &&
2517 (lpList->aEntries[ iIndex ].szAdmin[0]) &&
2518 (!lpList->aEntries[ iIndex ].fDeleted) )
2520 if (lpList->aEntries[ iIndex ].fAdded)
2521 lpList->aEntries[ iIndex ].szAdmin[0] = TEXT('\0');
2523 lpList->aEntries[ iIndex ].fDeleted = TRUE;
2532 LPKEYLIST AfsClass_KeyList_Load (LPIDENT lpiServer, ULONG *pStatus)
2536 LPKEYLIST lpList = NULL;
2539 NOTIFYCALLBACK::SendNotificationToAll (evtKeyListLoadBegin, lpiServer);
2544 if ((lpServer = lpiServer->OpenServer (&status)) == NULL)
2548 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
2555 lpList = New(KEYLIST);
2556 memset (lpList, 0x00, sizeof(KEYLIST));
2557 lpList->lpiServer = lpiServer;
2559 WORKERPACKET wpBegin;
2560 wpBegin.wpBosKeyGetBegin.hServer = hBOS;
2561 if (!Worker_DoTask (wtaskBosKeyGetBegin, &wpBegin, &status))
2565 for (size_t iEnum = 0; ; ++iEnum)
2567 WORKERPACKET wpNext;
2568 wpNext.wpBosKeyGetNext.hEnum = wpBegin.wpBosKeyGetBegin.hEnum;
2570 if (!Worker_DoTask (wtaskBosKeyGetNext, &wpNext, &status))
2572 if (status == ADMITERATORDONE)
2579 if (REALLOC (lpList->aKeys, lpList->cKeys, 1+iEnum, cREALLOC_SERVERKEYS))
2581 lpList->aKeys[ iEnum ].keyVersion = wpNext.wpBosKeyGetNext.keyVersion;
2582 memcpy (&lpList->aKeys[ iEnum ].keyData, &wpNext.wpBosKeyGetNext.keyData, sizeof(ENCRYPTIONKEY));
2583 memcpy (&lpList->aKeys[ iEnum ].keyInfo, &wpNext.wpBosKeyGetNext.keyInfo, sizeof(ENCRYPTIONKEYINFO));
2587 WORKERPACKET wpDone;
2588 wpDone.wpBosKeyGetDone.hEnum = wpBegin.wpBosKeyGetBegin.hEnum;
2589 Worker_DoTask (wtaskBosKeyGetDone, &wpDone);
2593 if ((lpServer = lpiServer->OpenServer (&status)) != NULL)
2595 lpServer->CloseBosObject();
2599 NOTIFYCALLBACK::SendNotificationToAll (evtKeyListLoadEnd, lpiServer, status);
2604 return (rc) ? lpList : NULL;
2608 void AfsClass_KeyList_Free (LPKEYLIST lpList)
2613 Free (lpList->aKeys);
2614 memset (lpList, 0x00, sizeof(KEYLIST));
2620 BOOL AfsClass_AddKey (LPIDENT lpiServer, int keyVersion, LPTSTR pszString, ULONG *pStatus)
2625 TCHAR szCell[ cchNAME ];
2626 lpiServer->GetCellName (szCell);
2629 wp.wpKasStringToKey.pszCell = szCell;
2630 wp.wpKasStringToKey.pszString = pszString;
2631 if (!Worker_DoTask (wtaskKasStringToKey, &wp, &status))
2635 else if (!AfsClass_AddKey (lpiServer, keyVersion, &wp.wpKasStringToKey.key, &status))
2646 BOOL AfsClass_AddKey (LPIDENT lpiServer, int keyVersion, LPENCRYPTIONKEY pKey, ULONG *pStatus)
2654 if ((lpServer = lpiServer->OpenServer (&status)) == NULL)
2658 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
2666 wp.wpBosKeyCreate.hServer = hBOS;
2667 wp.wpBosKeyCreate.keyVersion = keyVersion;
2668 memcpy (&wp.wpBosKeyCreate.key, pKey, sizeof(ENCRYPTIONKEY));
2669 rc = Worker_DoTask (wtaskBosKeyCreate, &wp, &status);
2672 if ((lpServer = lpiServer->OpenServer (&status)) != NULL)
2674 lpServer->CloseBosObject();
2684 BOOL AfsClass_DeleteKey (LPIDENT lpiServer, int keyVersion, ULONG *pStatus)
2692 if ((lpServer = lpiServer->OpenServer (&status)) == NULL)
2696 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
2704 wp.wpBosKeyDelete.hServer = hBOS;
2705 wp.wpBosKeyDelete.keyVersion = keyVersion;
2706 rc = Worker_DoTask (wtaskBosKeyDelete, &wp, &status);
2709 if ((lpServer = lpiServer->OpenServer (&status)) != NULL)
2711 lpServer->CloseBosObject();
2721 BOOL AfsClass_GetRandomKey (LPIDENT lpi, LPENCRYPTIONKEY pKey, ULONG *pStatus)
2729 if ((lpCell = lpi->OpenCell (&status)) == NULL)
2733 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
2736 hKAS = lpCell->GetKasObject (&status);
2743 wp.wpKasServerRandomKeyGet.hCell = hCell;
2744 wp.wpKasServerRandomKeyGet.hServer = hKAS;
2745 rc = Worker_DoTask (wtaskKasServerRandomKeyGet, &wp, &status);
2748 memcpy (pKey, &wp.wpKasServerRandomKeyGet.key, sizeof(ENCRYPTIONKEY));
2757 BOOL AfsClass_Clone (LPIDENT lpiRW, ULONG *pStatus)
2763 NOTIFYCALLBACK::SendNotificationToAll (evtCloneBegin, lpiRW, 0);
2769 if ((lpCell = lpiRW->OpenCell (&status)) == NULL)
2773 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
2778 // Perform the actual operation
2783 wp.wpVosBackupVolumeCreate.hCell = hCell;
2784 lpiRW->GetFilesetID (&wp.wpVosBackupVolumeCreate.idVolume);
2787 rc = Worker_DoTask (wtaskVosBackupVolumeCreate, &wp, &status);
2796 if ((lpServer = lpiRW->OpenServer (&status)) == NULL)
2800 lpServer->Invalidate();
2801 rc = lpServer->RefreshAll (&status);
2806 NOTIFYCALLBACK::SendNotificationToAll (evtCloneEnd, lpiRW, status);
2815 BOOL AfsClass_CloneMultiple (LPIDENT lpi, LPTSTR pszPrefix, BOOL fExclude, ULONG *pStatus)
2821 NOTIFYCALLBACK::SendNotificationToAll (evtCloneMultipleBegin, lpi);
2827 if ((lpCell = lpi->OpenCell (&status)) == NULL)
2831 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
2836 // Obtain hServer if appropriate
2839 if (!lpi->fIsCell())
2842 if ((lpServer = lpi->OpenServer (&status)) == NULL)
2846 if ((hVOS = lpServer->OpenVosObject (NULL, &status)) == NULL)
2852 // If requested, obtain the appropriate aggregate ID
2854 int idPartition = NO_PARTITION;
2855 if (rc && (lpi->fIsFileset() || lpi->fIsAggregate()))
2857 LPAGGREGATE lpAggregate;
2858 if ((lpAggregate = lpi->OpenAggregate (&status)) == NULL)
2862 if ((idPartition = lpAggregate->GetID()) == NO_PARTITION)
2864 lpAggregate->Close();
2868 // Perform the actual operation
2873 wp.wpVosBackupVolumeCreateMultiple.hCell = hCell;
2874 wp.wpVosBackupVolumeCreateMultiple.hServer = hVOS;
2875 wp.wpVosBackupVolumeCreateMultiple.idPartition = idPartition;
2876 wp.wpVosBackupVolumeCreateMultiple.pszPrefix = pszPrefix;
2877 wp.wpVosBackupVolumeCreateMultiple.fExclude = fExclude;
2880 rc = Worker_DoTask (wtaskVosBackupVolumeCreateMultiple, &wp, &status);
2891 if ((lpCell = lpi->OpenCell (&status)) == NULL)
2895 lpCell->Invalidate();
2896 rc = lpCell->RefreshAll (&status);
2903 if ((lpServer = lpi->OpenServer (&status)) == NULL)
2907 lpServer->Invalidate();
2908 rc = lpServer->RefreshAll (&status);
2917 if ((lpServer = lpi->OpenServer (&status)) != NULL)
2919 lpServer->CloseVosObject();
2924 NOTIFYCALLBACK::SendNotificationToAll (evtCloneMultipleEnd, lpi, status);
2933 BOOL AfsClass_DumpFileset (LPIDENT lpi, LPTSTR pszFilename, LPSYSTEMTIME pstDate, ULONG *pStatus)
2939 NOTIFYCALLBACK::SendNotificationToAll (evtDumpFilesetBegin, lpi, pszFilename, 0);
2941 // Obtain hCell and hVOS
2946 if ((lpServer = lpi->OpenServer (&status)) == NULL)
2950 if ((hVOS = lpServer->OpenVosObject (&hCell, &status)) == NULL)
2955 // Obtain idPartition
2958 LPAGGREGATE lpAggregate;
2959 if ((lpAggregate = lpi->OpenAggregate (&status)) == NULL)
2963 idPartition = lpAggregate->GetID();
2964 lpAggregate->Close();
2967 // Perform the actual operation
2972 wp.wpVosVolumeDump.hCell = hCell;
2973 wp.wpVosVolumeDump.hServer = hVOS;
2974 wp.wpVosVolumeDump.pszFilename = pszFilename;
2975 wp.wpVosVolumeDump.idPartition = idPartition;
2976 lpi->GetFilesetID (&wp.wpVosVolumeDump.idVolume);
2979 memcpy (&wp.wpVosVolumeDump.stStart, pstDate, sizeof(SYSTEMTIME));
2981 memset (&wp.wpVosVolumeDump.stStart, 0x00, sizeof(SYSTEMTIME));
2984 rc = Worker_DoTask (wtaskVosVolumeDump, &wp, &status);
2988 NOTIFYCALLBACK::SendNotificationToAll (evtDumpFilesetEnd, lpi, pszFilename, status);
2994 if ((lpServer = lpi->OpenServer (&status)) != NULL)
2996 lpServer->CloseVosObject();
3007 BOOL AfsClass_RestoreFileset (LPIDENT lpi, LPTSTR pszFileset, LPTSTR pszFilename, BOOL fIncremental, ULONG *pStatus)
3013 NOTIFYCALLBACK::SendNotificationToAll (evtRestoreFilesetBegin, lpi, NULL, pszFileset, pszFilename, 0, 0);
3015 // Obtain hCell and hVOS
3020 if ((lpServer = lpi->OpenServer (&status)) == NULL)
3024 if ((hVOS = lpServer->OpenVosObject (&hCell, &status)) == NULL)
3029 // Obtain idPartition
3032 LPAGGREGATE lpAggregate;
3033 if ((lpAggregate = lpi->OpenAggregate (&status)) == NULL)
3037 idPartition = lpAggregate->GetID();
3038 lpAggregate->Close();
3041 // Perform the actual operation
3046 wp.wpVosVolumeRestore.hCell = hCell;
3047 wp.wpVosVolumeRestore.hServer = hVOS;
3048 wp.wpVosVolumeRestore.idPartition = idPartition;
3049 wp.wpVosVolumeRestore.pszVolume = pszFileset;
3050 wp.wpVosVolumeRestore.pszFilename = pszFilename;
3051 wp.wpVosVolumeRestore.fIncremental = fIncremental;
3053 if (lpi->fIsFileset())
3054 lpi->GetFilesetID (&wp.wpVosVolumeRestore.idVolume);
3056 wp.wpVosVolumeRestore.idVolume = NO_VOLUME;
3059 rc = Worker_DoTask (wtaskVosVolumeRestore, &wp, &status);
3067 if ((lpServer = lpi->OpenServer (&status)) == NULL)
3071 lpServer->Invalidate();
3072 rc = lpServer->RefreshAll (&status);
3079 if ((lpServer = lpi->OpenServer (&status)) != NULL)
3081 lpServer->CloseVosObject();
3086 NOTIFYCALLBACK::SendNotificationToAll (evtRestoreFilesetEnd, lpi, NULL, pszFileset, pszFilename, 0, status);
3095 BOOL AfsClass_GetRestartTimes (LPIDENT lpiServer, BOOL *pfWeekly, LPSYSTEMTIME pstWeekly, BOOL *pfDaily, LPSYSTEMTIME pstDaily, ULONG *pStatus)
3101 NOTIFYCALLBACK::SendNotificationToAll (evtGetRestartTimesBegin, lpiServer);
3106 if ((lpServer = lpiServer->OpenServer (&status)) == NULL)
3110 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
3118 wp.wpBosExecutableRestartTimeGet.hServer = hBOS;
3121 rc = Worker_DoTask (wtaskBosExecutableRestartTimeGet, &wp, &status);
3126 *pfWeekly = wp.wpBosExecutableRestartTimeGet.fWeeklyRestart;
3127 *pstWeekly = wp.wpBosExecutableRestartTimeGet.timeWeekly;
3128 *pfDaily = wp.wpBosExecutableRestartTimeGet.fDailyRestart;
3129 *pstDaily = wp.wpBosExecutableRestartTimeGet.timeDaily;
3133 if ((lpServer = lpiServer->OpenServer (&status)) != NULL)
3135 lpServer->CloseBosObject();
3139 NOTIFYCALLBACK::SendNotificationToAll (evtGetRestartTimesEnd, lpiServer, status);
3148 BOOL AfsClass_SetRestartTimes (LPIDENT lpiServer, LPSYSTEMTIME pstWeekly, LPSYSTEMTIME pstDaily, ULONG *pStatus)
3154 NOTIFYCALLBACK::SendNotificationToAll (evtSetRestartTimesBegin, lpiServer);
3159 if ((lpServer = lpiServer->OpenServer (&status)) == NULL)
3163 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
3170 SYSTEMTIME timeNever;
3171 memset (&timeNever, 0x00, sizeof(SYSTEMTIME));
3174 wp.wpBosExecutableRestartTimeSet.hServer = hBOS;
3175 wp.wpBosExecutableRestartTimeSet.fWeeklyRestart = (pstWeekly != NULL) ? TRUE : FALSE;
3176 wp.wpBosExecutableRestartTimeSet.timeWeekly = (pstWeekly != NULL) ? *pstWeekly : timeNever;
3177 wp.wpBosExecutableRestartTimeSet.fDailyRestart = (pstDaily != NULL) ? TRUE : FALSE;
3178 wp.wpBosExecutableRestartTimeSet.timeDaily = (pstDaily != NULL) ? *pstDaily : timeNever;
3181 rc = Worker_DoTask (wtaskBosExecutableRestartTimeSet, &wp, &status);
3185 if ((lpServer = lpiServer->OpenServer (&status)) != NULL)
3187 lpServer->CloseBosObject();
3191 NOTIFYCALLBACK::SendNotificationToAll (evtSetRestartTimesEnd, lpiServer, status);
3200 BOOL AfsClass_MoveReplica (LPIDENT lpiReplica, LPIDENT lpiAggregateTarget, ULONG *pStatus)
3204 // Find the identifier for this replica's read/write fileset.
3206 LPIDENT lpiFilesetRW = NULL;
3207 LPFILESET lpFileset;
3208 if ((lpFileset = lpiReplica->OpenFileset (pStatus)) == NULL)
3212 if ((lpiFilesetRW = lpFileset->GetReadWriteIdentifier (pStatus)) == NULL)
3217 // If the fileset replica currently resides on the same server
3218 // as the target aggregate, we'll follow the following steps:
3220 // 1. Delete the old fileset replica -> on error, quit
3221 // 2. Create the new fileset replica -> on error, recreate old replica, quit
3223 // If the fileset replica instead currently resides on a different
3224 // server, we can follow the preferred steps:
3226 // 1. Create the new fileset replica -> on error, quit
3227 // 2. Delete the old fileset replica -> on error, delete the new replica, quit
3231 LPIDENT lpiReplicaNew;
3233 if (lpiReplica->GetServer() == lpiAggregateTarget->GetServer())
3235 LPIDENT lpiAggregateOriginal = lpiReplica->GetAggregate();
3237 if (!AfsClass_DeleteReplica (lpiReplica, pStatus))
3241 else if ((lpiReplicaNew = AfsClass_CreateReplica (lpiFilesetRW, lpiAggregateTarget, pStatus)) == NULL)
3243 (void)AfsClass_CreateReplica (lpiFilesetRW, lpiAggregateOriginal);
3247 else // different server?
3249 if ((lpiReplicaNew = AfsClass_CreateReplica (lpiFilesetRW, lpiAggregateTarget, pStatus)) == NULL)
3253 else if (!AfsClass_DeleteReplica (lpiReplica, pStatus))
3255 (void)AfsClass_DeleteReplica (lpiReplicaNew, pStatus);
3265 BOOL AfsClass_Salvage (LPIDENT lpiSalvage, LPTSTR *ppszLogData, int nProcesses, LPTSTR pszTempDir, LPTSTR pszLogFile, BOOL fForce, BOOL fReadonly, BOOL fLogInodes, BOOL fLogRootInodes, BOOL fRebuildDirs, BOOL fReadBlocks, ULONG *pStatus)
3271 NOTIFYCALLBACK::SendNotificationToAll (evtSalvageBegin, lpiSalvage);
3276 if ((lpServer = lpiSalvage->OpenServer (&status)) == NULL)
3280 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
3286 *ppszLogData = NULL;
3288 // Step one: perform the actual salvage. This will dump a log file onto
3289 // the target computer.
3293 LPTSTR pszAggregate = NULL;
3294 TCHAR szAggregate[ cchNAME ];
3295 if (lpiSalvage->fIsAggregate() || lpiSalvage->fIsFileset())
3297 lpiSalvage->GetAggregateName (szAggregate);
3298 pszAggregate = szAggregate;
3301 LPTSTR pszFileset = NULL;
3302 TCHAR szFileset[ cchNAME ];
3303 if (lpiSalvage->fIsFileset())
3306 lpiSalvage->GetFilesetID (&vid);
3307 wsprintf (szFileset, TEXT("%lu"), vid);
3308 pszFileset = szFileset;
3311 if (pszLogFile == NULL)
3312 pszLogFile = TEXT("SalvageLog");
3315 wp.wpBosSalvage.hCell = hCell;
3316 wp.wpBosSalvage.hServer = hBOS;
3317 wp.wpBosSalvage.pszAggregate = pszAggregate;
3318 wp.wpBosSalvage.pszFileset = pszFileset;
3319 wp.wpBosSalvage.nProcesses = nProcesses;
3320 wp.wpBosSalvage.pszTempDir = pszTempDir;
3321 wp.wpBosSalvage.pszLogFile = pszLogFile;
3322 wp.wpBosSalvage.fForce = fForce;
3323 wp.wpBosSalvage.fReadonly = fReadonly;
3324 wp.wpBosSalvage.fLogInodes = fLogInodes;
3325 wp.wpBosSalvage.fLogRootInodes = fLogRootInodes;
3326 wp.wpBosSalvage.fRebuildDirs = fRebuildDirs;
3327 wp.wpBosSalvage.fReadBlocks = fReadBlocks;
3330 rc = Worker_DoTask (wtaskBosSalvage, &wp, &status);
3334 // Step two: retrieve the log file from that salvage operation.
3335 // If we can't get the log file back, that's not fatal--just return
3336 // a NULL pointer for the log data.
3338 if (rc && ppszLogData)
3341 wp.wpBosLogGet.hServer = hBOS;
3342 wp.wpBosLogGet.pszLogName = pszLogFile;
3343 wp.wpBosLogGet.pszLogData = NULL;
3346 if ((rc = Worker_DoTask (wtaskBosLogGet, &wp, &status)) == TRUE)
3348 // Okay, well, we have the log in memory now. Problem is,
3349 // it has UNIX-style CR's... and so is missing the LF which
3350 // PCs expect before each CR. Wow--look at all the
3351 // acronyms! Count the CRs, alloc a larger buffer, and stuff
3352 // in the LFs before each CR.
3354 size_t cchRequired = 1;
3355 for (LPTSTR pchIn = wp.wpBosLogGet.pszLogData; *pchIn; ++pchIn)
3357 cchRequired += (*pchIn == TEXT('\r')) ? 0 : (*pchIn == TEXT('\n')) ? 2 : 1;
3360 if ((*ppszLogData = AllocateString (cchRequired)) != NULL)
3362 LPTSTR pszOut = *ppszLogData;
3363 for (LPTSTR pchIn = wp.wpBosLogGet.pszLogData; *pchIn; ++pchIn)
3365 if (*pchIn == TEXT('\n'))
3366 *pszOut++ = TEXT('\r');
3367 if (*pchIn != TEXT('\r'))
3370 *pszOut++ = TEXT('\0');
3376 if ((lpServer = lpiSalvage->OpenServer (&status)) != NULL)
3378 lpServer->CloseBosObject();
3382 NOTIFYCALLBACK::SendNotificationToAll (evtSalvageEnd, lpiSalvage, status);
3391 void AfsClass_FreeSalvageLog (LPTSTR pszLogData)
3398 LPHOSTLIST AfsClass_HostList_Load (LPIDENT lpiServer, ULONG *pStatus)
3402 LPHOSTLIST lpList = NULL;
3405 NOTIFYCALLBACK::SendNotificationToAll (evtHostListLoadBegin, lpiServer);
3410 if ((lpServer = lpiServer->OpenServer (&status)) == NULL)
3414 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
3421 lpList = New(HOSTLIST);
3422 memset (lpList, 0x00, sizeof(HOSTLIST));
3424 lpList->lpiServer = lpiServer;
3426 WORKERPACKET wpBegin;
3427 wpBegin.wpBosHostGetBegin.hServer = hBOS;
3428 if (!Worker_DoTask (wtaskBosHostGetBegin, &wpBegin, &status))
3434 TCHAR szHost[ cchNAME ];
3436 WORKERPACKET wpNext;
3437 wpNext.wpBosHostGetNext.hEnum = wpBegin.wpBosHostGetBegin.hEnum;
3438 wpNext.wpBosHostGetNext.pszServer = szHost;
3440 if (!Worker_DoTask (wtaskBosHostGetNext, &wpNext, &status))
3442 if (status == ADMITERATORDONE)
3450 if ((iAdded = AfsClass_HostList_AddEntry (lpList, szHost)) != (size_t)-1)
3452 lpList->aEntries[ iAdded ].fAdded = FALSE;
3456 WORKERPACKET wpDone;
3457 wpDone.wpBosHostGetDone.hEnum = wpBegin.wpBosHostGetBegin.hEnum;
3458 Worker_DoTask (wtaskBosHostGetDone, &wpDone);
3462 if ((lpServer = lpiServer->OpenServer (&status)) != NULL)
3464 lpServer->CloseBosObject();
3468 NOTIFYCALLBACK::SendNotificationToAll (evtHostListLoadEnd, lpiServer, status);
3473 return (rc) ? lpList : NULL;
3477 LPHOSTLIST AfsClass_HostList_Copy (LPHOSTLIST lpOld)
3479 LPHOSTLIST lpNew = NULL;
3483 lpNew = New(HOSTLIST);
3484 memcpy (lpNew, lpOld, sizeof(HOSTLIST));
3487 lpNew->aEntries = 0;
3488 lpNew->cEntries = 0;
3490 if (REALLOC (lpNew->aEntries, lpNew->cEntries, lpOld->cEntries, cREALLOC_HOSTLISTENTRIES))
3492 size_t cb = lpOld->cEntries * sizeof(HOSTLISTENTRY);
3493 memcpy (lpNew->aEntries, lpOld->aEntries, cb);
3501 BOOL AfsClass_HostList_Save (LPHOSTLIST lpList, ULONG *pStatus)
3507 NOTIFYCALLBACK::SendNotificationToAll (evtHostListSaveBegin, lpList->lpiServer);
3512 if ((lpServer = lpList->lpiServer->OpenServer (&status)) == NULL)
3516 if ((hBOS = lpServer->OpenBosObject (&hCell, &status)) == NULL)
3523 for (size_t iEntry = 0; iEntry < lpList->cEntries; ++iEntry)
3525 if (!lpList->aEntries[ iEntry ].szHost[0])
3528 // are we supposed to add this entry?
3530 if (lpList->aEntries[ iEntry ].fAdded && !lpList->aEntries[ iEntry ].fDeleted)
3533 wp.wpBosHostCreate.hServer = hBOS;
3534 wp.wpBosHostCreate.pszServer = lpList->aEntries[ iEntry ].szHost;
3537 if (!Worker_DoTask (wtaskBosHostCreate, &wp, &thisstatus))
3540 status = thisstatus;
3544 lpList->aEntries[ iEntry ].fAdded = FALSE;
3548 // are we supposed to delete this entry?
3550 if (!lpList->aEntries[ iEntry ].fAdded && lpList->aEntries[ iEntry ].fDeleted)
3553 wp.wpBosHostDelete.hServer = hBOS;
3554 wp.wpBosHostDelete.pszServer = lpList->aEntries[ iEntry ].szHost;
3557 if (!Worker_DoTask (wtaskBosHostDelete, &wp, &thisstatus))
3560 status = thisstatus;
3564 lpList->aEntries[ iEntry ].szHost[0] = TEXT('\0');
3565 lpList->aEntries[ iEntry ].fDeleted = FALSE;
3571 if ((lpServer = lpList->lpiServer->OpenServer (&status)) != NULL)
3573 lpServer->CloseBosObject();
3577 NOTIFYCALLBACK::SendNotificationToAll (evtHostListSaveEnd, lpList->lpiServer, status);
3586 void AfsClass_HostList_Free (LPHOSTLIST lpList)
3588 if (lpList && !InterlockedDecrement (&lpList->cRef))
3590 if (lpList->aEntries)
3591 Free (lpList->aEntries);
3592 memset (lpList, 0x00, sizeof(HOSTLIST));
3598 size_t AfsClass_HostList_AddEntry (LPHOSTLIST lpList, LPTSTR pszHost)
3600 size_t iAdded = (size_t)-1;
3604 for (size_t iEntry = 0; iEntry < lpList->cEntries; ++iEntry)
3606 if (!lpList->aEntries[ iEntry ].szHost[0])
3609 if (iEntry >= lpList->cEntries)
3611 (void)REALLOC (lpList->aEntries, lpList->cEntries, 1+iEntry, cREALLOC_HOSTLISTENTRIES);
3613 if (iEntry < lpList->cEntries)
3616 lstrcpy (lpList->aEntries[ iAdded ].szHost, pszHost);
3617 lpList->aEntries[ iAdded ].fAdded = TRUE;
3618 lpList->aEntries[ iAdded ].fDeleted = FALSE;
3626 BOOL AfsClass_HostList_DelEntry (LPHOSTLIST lpList, size_t iIndex)
3631 (iIndex < lpList->cEntries) &&
3632 (lpList->aEntries[ iIndex ].szHost[0]) &&
3633 (!lpList->aEntries[ iIndex ].fDeleted) )
3635 if (lpList->aEntries[ iIndex ].fAdded)
3636 lpList->aEntries[ iIndex ].szHost[0] = TEXT('\0');
3638 lpList->aEntries[ iIndex ].fDeleted = TRUE;
3647 BOOL AfsClass_GetPtsProperties (LPIDENT lpiCell, LPPTSPROPERTIES pProperties, ULONG *pStatus)
3652 memset (pProperties, 0x00, sizeof(PTSPROPERTIES));
3658 if ((lpCell = lpiCell->OpenCell (&status)) == NULL)
3662 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
3667 // Go get the necessary properties
3672 wp.wpPtsUserMaxGet.hCell = hCell;
3674 if ((rc = Worker_DoTask (wtaskPtsUserMaxGet, &wp, &status)) == TRUE)
3675 pProperties->idUserMax = wp.wpPtsUserMaxGet.idUserMax;
3681 wp.wpPtsGroupMaxGet.hCell = hCell;
3683 if ((rc = Worker_DoTask (wtaskPtsGroupMaxGet, &wp, &status)) == TRUE)
3684 pProperties->idGroupMax = wp.wpPtsGroupMaxGet.idGroupMax;
3693 BOOL AfsClass_SetPtsProperties (LPIDENT lpiCell, LPPTSPROPERTIES pProperties, ULONG *pStatus)
3702 if ((lpCell = lpiCell->OpenCell (&status)) == NULL)
3706 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
3711 // Modify the specified properties
3716 wp.wpPtsUserMaxSet.hCell = hCell;
3717 wp.wpPtsUserMaxSet.idUserMax = pProperties->idUserMax;
3718 rc = Worker_DoTask (wtaskPtsUserMaxSet, &wp, &status);
3724 wp.wpPtsGroupMaxSet.hCell = hCell;
3725 wp.wpPtsGroupMaxSet.idGroupMax = pProperties->idGroupMax;
3726 Worker_DoTask (wtaskPtsGroupMaxSet, &wp, &status);
3735 LPIDENT AfsClass_CreateUser (LPIDENT lpiCell, LPTSTR pszUserName, LPTSTR pszInstance, LPTSTR pszPassword, int idUser, BOOL fCreateKAS, BOOL fCreatePTS, ULONG *pStatus)
3740 if (pszInstance && !*pszInstance)
3744 NOTIFYCALLBACK::SendNotificationToAll (evtCreateUserBegin, lpiCell, pszUserName, 0);
3746 // We'll need both hCell and hKAS.
3751 if ((lpCell = lpiCell->OpenCell (&status)) == NULL)
3755 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
3758 hKAS = lpCell->GetKasObject (&status);
3762 // First try to create a KAS entry.
3764 if (rc && fCreateKAS)
3767 wp.wpKasPrincipalCreate.hCell = hCell;
3768 wp.wpKasPrincipalCreate.hServer = hKAS;
3769 wp.wpKasPrincipalCreate.pszPrincipal = pszUserName;
3770 wp.wpKasPrincipalCreate.pszInstance = pszInstance;
3771 wp.wpKasPrincipalCreate.pszPassword = pszPassword;
3774 rc = Worker_DoTask (wtaskKasPrincipalCreate, &wp, &status);
3778 // If that succeeded, try to create a PTS entry as well.
3780 if (rc && fCreatePTS)
3782 TCHAR szUserName[ cchNAME ];
3783 lstrcpy (szUserName, pszUserName);
3785 wsprintf (&szUserName[ lstrlen(szUserName) ], TEXT(".%s"), pszInstance);
3788 wp.wpPtsUserCreate.hCell = hCell;
3789 wp.wpPtsUserCreate.pszUser = szUserName;
3790 wp.wpPtsUserCreate.idUser = idUser;
3794 if ((rc = Worker_DoTask (wtaskPtsUserCreate, &wp, &status)) == FALSE)
3796 if (status == PREXIST)
3802 // If we couldn't make a KAS entry as well, remove the KAS entry.
3807 wpDel.wpKasPrincipalDelete.hCell = hCell;
3808 wpDel.wpKasPrincipalDelete.hServer = hKAS;
3809 wpDel.wpKasPrincipalDelete.pszPrincipal = pszUserName;
3810 wpDel.wpKasPrincipalDelete.pszInstance = pszInstance;
3811 Worker_DoTask (wtaskKasPrincipalDelete, &wpDel);
3818 // If we were able to create the user's accounts successfully, refresh
3819 // the cell status and return the new user's ident.
3825 if ((lpCell = lpiCell->OpenCell (&status)) == NULL)
3829 if (!lpCell->RefreshAccount (pszUserName, pszInstance, CELL_REFRESH_ACCOUNT_CREATED_USER, &lpiUser))
3837 NOTIFYCALLBACK::SendNotificationToAll (evtCreateUserEnd, lpiCell, pszUserName, status);
3842 return (rc) ? lpiUser : NULL;
3846 BOOL AfsClass_SetUserProperties (LPIDENT lpiUser, LPUSERPROPERTIES pProperties, ULONG *pStatus)
3852 NOTIFYCALLBACK::SendNotificationToAll (evtChangeUserBegin, lpiUser);
3854 // We'll need both hCell and hKAS.
3859 if ((lpCell = lpiUser->OpenCell (&status)) == NULL)
3863 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
3866 hKAS = lpCell->GetKasObject (&status);
3870 // We'll also need this user's current status
3874 if ((lpUser = lpiUser->OpenUser (&status)) == NULL)
3878 if (!lpUser->GetStatus (&us, TRUE, &status))
3883 // Modify the user's KAS entry (if necessary)
3885 DWORD dwKasMask = ( MASK_USERPROP_fAdmin |
3886 MASK_USERPROP_fGrantTickets |
3887 MASK_USERPROP_fCanEncrypt |
3888 MASK_USERPROP_fCanChangePassword |
3889 MASK_USERPROP_fCanReusePasswords |
3890 MASK_USERPROP_timeAccountExpires |
3891 MASK_USERPROP_cdayPwExpires |
3892 MASK_USERPROP_csecTicketLifetime |
3893 MASK_USERPROP_nFailureAttempts |
3894 MASK_USERPROP_csecFailedLoginLockTime );
3896 if (rc && (pProperties->dwMask & dwKasMask))
3898 TCHAR szPrincipal[ cchNAME ];
3899 TCHAR szInstance[ cchNAME ];
3900 lpiUser->GetUserName (szPrincipal, szInstance);
3903 wp.wpKasPrincipalFieldsSet.hCell = hCell;
3904 wp.wpKasPrincipalFieldsSet.hServer = hKAS;
3905 wp.wpKasPrincipalFieldsSet.pszPrincipal = szPrincipal;
3906 wp.wpKasPrincipalFieldsSet.pszInstance = szInstance;
3907 wp.wpKasPrincipalFieldsSet.fIsAdmin = (pProperties->dwMask & MASK_USERPROP_fAdmin) ? pProperties->fAdmin : us.KASINFO.fIsAdmin;
3908 wp.wpKasPrincipalFieldsSet.fGrantTickets = (pProperties->dwMask & MASK_USERPROP_fGrantTickets) ? pProperties->fGrantTickets : us.KASINFO.fCanGetTickets;
3909 wp.wpKasPrincipalFieldsSet.fCanEncrypt = (pProperties->dwMask & MASK_USERPROP_fCanEncrypt) ? pProperties->fCanEncrypt : us.KASINFO.fEncrypt;
3910 wp.wpKasPrincipalFieldsSet.fCanChangePassword = (pProperties->dwMask & MASK_USERPROP_fCanChangePassword) ? pProperties->fCanChangePassword : us.KASINFO.fCanChangePassword;
3911 wp.wpKasPrincipalFieldsSet.fCanReusePasswords = (pProperties->dwMask & MASK_USERPROP_fCanReusePasswords) ? pProperties->fCanReusePasswords : us.KASINFO.fCanReusePasswords;
3912 memcpy (&wp.wpKasPrincipalFieldsSet.timeExpires, (pProperties->dwMask & MASK_USERPROP_timeAccountExpires) ? &pProperties->timeAccountExpires : &us.KASINFO.timeExpires, sizeof(SYSTEMTIME));
3913 wp.wpKasPrincipalFieldsSet.cdayPwExpires = (pProperties->dwMask & MASK_USERPROP_cdayPwExpires) ? pProperties->cdayPwExpires : us.KASINFO.cdayPwExpire;
3914 wp.wpKasPrincipalFieldsSet.csecTicketLifetime = (pProperties->dwMask & MASK_USERPROP_csecTicketLifetime) ? pProperties->csecTicketLifetime : us.KASINFO.csecTicketLifetime;
3915 wp.wpKasPrincipalFieldsSet.nFailureAttempts = (pProperties->dwMask & MASK_USERPROP_nFailureAttempts) ? pProperties->nFailureAttempts : us.KASINFO.cFailLogin;
3916 wp.wpKasPrincipalFieldsSet.csecFailedLoginLockTime = (pProperties->dwMask & MASK_USERPROP_csecFailedLoginLockTime) ? pProperties->csecFailedLoginLockTime : us.KASINFO.csecFailLoginLock;
3919 rc = Worker_DoTask (wtaskKasPrincipalFieldsSet, &wp, &status);
3924 // Modify the user's PTS entry (if necessary)
3926 DWORD dwPtsMask = ( MASK_USERPROP_cGroupCreationQuota |
3927 MASK_USERPROP_aaListStatus |
3928 MASK_USERPROP_aaGroupsOwned |
3929 MASK_USERPROP_aaMembership );
3931 if (rc && (pProperties->dwMask & dwPtsMask))
3933 TCHAR szFullName[ cchNAME ];
3934 lpiUser->GetFullUserName (szFullName);
3937 wp.wpPtsUserModify.hCell = hCell;
3938 wp.wpPtsUserModify.pszUser = szFullName;
3939 memset (&wp.wpPtsUserModify.Delta, 0x00, sizeof(wp.wpPtsUserModify.Delta));
3941 if (pProperties->dwMask & MASK_USERPROP_cGroupCreationQuota)
3943 wp.wpPtsUserModify.Delta.flag = (pts_UserUpdateFlag_t)( (LONG)wp.wpPtsUserModify.Delta.flag | (LONG)PTS_USER_UPDATE_GROUP_CREATE_QUOTA );
3944 wp.wpPtsUserModify.Delta.groupCreationQuota = pProperties->cGroupCreationQuota;
3947 if (pProperties->dwMask & (MASK_USERPROP_aaListStatus | MASK_USERPROP_aaGroupsOwned | MASK_USERPROP_aaMembership))
3949 wp.wpPtsUserModify.Delta.flag = (pts_UserUpdateFlag_t)( (LONG)wp.wpPtsUserModify.Delta.flag | (LONG)PTS_USER_UPDATE_PERMISSIONS );
3950 wp.wpPtsUserModify.Delta.listStatus = ACCOUNTACCESS_TO_USERACCESS( (pProperties->dwMask & MASK_USERPROP_aaListStatus) ? pProperties->aaListStatus : us.PTSINFO.aaListStatus );
3951 wp.wpPtsUserModify.Delta.listGroupsOwned = ACCOUNTACCESS_TO_USERACCESS( (pProperties->dwMask & MASK_USERPROP_aaGroupsOwned) ? pProperties->aaGroupsOwned : us.PTSINFO.aaGroupsOwned );
3952 wp.wpPtsUserModify.Delta.listMembership = ACCOUNTACCESS_TO_USERACCESS( (pProperties->dwMask & MASK_USERPROP_aaMembership) ? pProperties->aaMembership : us.PTSINFO.aaMembership );
3956 rc = Worker_DoTask (wtaskPtsUserModify, &wp, &status);
3960 // If we were able to modify the user's properties successfully, refresh
3961 // that user's status.
3963 if ((lpUser = lpiUser->OpenUser (&status)) != NULL)
3965 lpUser->Invalidate();
3966 lpUser->RefreshStatus();
3970 NOTIFYCALLBACK::SendNotificationToAll (evtChangeUserBegin, lpiUser, status);
3979 BOOL AfsClass_SetUserPassword (LPIDENT lpiUser, int keyVersion, LPTSTR pszPassword, ULONG *pStatus)
3984 TCHAR szCell[ cchNAME ];
3985 lpiUser->GetCellName (szCell);
3988 wp.wpKasStringToKey.pszCell = szCell;
3989 wp.wpKasStringToKey.pszString = pszPassword;
3990 if (!Worker_DoTask (wtaskKasStringToKey, &wp, &status))
3994 else if (!AfsClass_SetUserPassword (lpiUser, keyVersion, &wp.wpKasStringToKey.key, &status))
4005 BOOL AfsClass_SetUserPassword (LPIDENT lpiUser, int keyVersion, LPENCRYPTIONKEY pKey, ULONG *pStatus)
4011 NOTIFYCALLBACK::SendNotificationToAll (evtChangeUserPasswordBegin, lpiUser);
4013 // We'll need both hCell and hKAS.
4018 if ((lpCell = lpiUser->OpenCell (&status)) == NULL)
4022 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
4025 hKAS = lpCell->GetKasObject (&status);
4029 // Change the user's password
4033 TCHAR szPrincipal[ cchNAME ];
4034 TCHAR szInstance[ cchNAME ];
4035 lpiUser->GetUserName (szPrincipal, szInstance);
4038 wp.wpKasPrincipalKeySet.hCell = hCell;
4039 wp.wpKasPrincipalKeySet.hServer = hKAS;
4040 wp.wpKasPrincipalKeySet.pszPrincipal = szPrincipal;
4041 wp.wpKasPrincipalKeySet.pszInstance = szInstance;
4042 wp.wpKasPrincipalKeySet.keyVersion = keyVersion;
4043 memcpy (&wp.wpKasPrincipalKeySet.key.key, &pKey->key, ENCRYPTIONKEY_LEN);
4046 rc = Worker_DoTask (wtaskKasPrincipalKeySet, &wp, &status);
4050 // If we were able to modify the user's password successfully, refresh
4051 // that user's status.
4054 if ((lpUser = lpiUser->OpenUser (&status)) != NULL)
4056 lpUser->Invalidate();
4057 lpUser->RefreshStatus();
4061 NOTIFYCALLBACK::SendNotificationToAll (evtChangeUserPasswordEnd, lpiUser, status);
4070 BOOL AfsClass_DeleteUser (LPIDENT lpiUser, BOOL fDeleteKAS, BOOL fDeletePTS, ULONG *pStatus)
4076 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteUserBegin, lpiUser);
4078 // We'll need both hCell and hKAS.
4083 if ((lpCell = lpiUser->OpenCell (&status)) == NULL)
4087 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
4090 hKAS = lpCell->GetKasObject (&status);
4094 // Find out whether this user has KAS and/or PTS entries. Also
4095 // get the various lists of groups for this user...
4098 LPTSTR mszOwnerOf = NULL;
4099 LPTSTR mszMemberOf = NULL;
4100 if ((lpUser = lpiUser->OpenUser (&status)) == NULL)
4104 lpUser->GetOwnerOf (&mszOwnerOf);
4105 lpUser->GetMemberOf (&mszMemberOf);
4109 // Delete the user's PTS entry
4111 if (rc && fDeletePTS)
4113 TCHAR szFullName[ cchNAME ];
4114 lpiUser->GetFullUserName (szFullName);
4117 wp.wpPtsUserDelete.hCell = hCell;
4118 wp.wpPtsUserDelete.pszUser = szFullName;
4121 if ((rc = Worker_DoTask (wtaskPtsUserDelete, &wp, &status)) == FALSE)
4123 if (status == ADMPTSFAILEDNAMETRANSLATE) // User had no PTS entry?
4129 // Delete the user's KAS entry
4131 if (rc && fDeleteKAS)
4133 TCHAR szPrincipal[ cchNAME ];
4134 TCHAR szInstance[ cchNAME ];
4135 lpiUser->GetUserName (szPrincipal, szInstance);
4138 wp.wpKasPrincipalDelete.hCell = hCell;
4139 wp.wpKasPrincipalDelete.hServer = hKAS;
4140 wp.wpKasPrincipalDelete.pszPrincipal = szPrincipal;
4141 wp.wpKasPrincipalDelete.pszInstance = szInstance;
4144 if ((rc = Worker_DoTask (wtaskKasPrincipalDelete, &wp, &status)) == FALSE)
4146 if (status == KANOENT)
4152 // If we were able to delete the user's accounts successfully, refresh
4157 if ((lpCell = lpiUser->OpenCell (&status)) != NULL)
4159 TCHAR szPrincipal[ cchNAME ];
4160 TCHAR szInstance[ cchNAME ];
4161 lpiUser->GetUserName (szPrincipal, szInstance);
4163 lpCell->RefreshAccount (szPrincipal, szInstance, CELL_REFRESH_ACCOUNT_DELETED);
4164 lpCell->RefreshAccounts (mszOwnerOf, CELL_REFRESH_ACCOUNT_CHANGED);
4165 lpCell->RefreshAccounts (mszMemberOf, CELL_REFRESH_ACCOUNT_CHANGED);
4170 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteUserEnd, lpiUser, status);
4174 FreeString (mszOwnerOf);
4176 FreeString (mszMemberOf);
4183 BOOL AfsClass_UnlockUser (LPIDENT lpiUser, ULONG *pStatus)
4189 NOTIFYCALLBACK::SendNotificationToAll (evtUnlockUserBegin, lpiUser);
4191 // We'll need both hCell and hKAS.
4196 if ((lpCell = lpiUser->OpenCell (&status)) == NULL)
4200 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
4203 hKAS = lpCell->GetKasObject (&status);
4207 // Unlock the user's KAS entry
4211 TCHAR szPrincipal[ cchNAME ];
4212 TCHAR szInstance[ cchNAME ];
4213 lpiUser->GetUserName (szPrincipal, szInstance);
4216 wp.wpKasPrincipalUnlock.hCell = hCell;
4217 wp.wpKasPrincipalUnlock.hServer = hKAS;
4218 wp.wpKasPrincipalUnlock.pszPrincipal = szPrincipal;
4219 wp.wpKasPrincipalUnlock.pszInstance = szInstance;
4222 rc = Worker_DoTask (wtaskKasPrincipalUnlock, &wp, &status);
4226 // If we were able to unlock the user's accounts successfully, refresh
4227 // the user's properties.
4232 if ((lpUser = lpiUser->OpenUser (&status)) != NULL)
4234 lpUser->Invalidate();
4235 lpUser->RefreshStatus();
4240 NOTIFYCALLBACK::SendNotificationToAll (evtUnlockUserEnd, lpiUser, status);
4249 LPIDENT AfsClass_CreateGroup (LPIDENT lpiCell, LPTSTR pszGroupName, LPIDENT lpiOwner, int idGroup, ULONG *pStatus)
4255 NOTIFYCALLBACK::SendNotificationToAll (evtCreateGroupBegin, lpiCell, pszGroupName, 0);
4261 if ((lpCell = lpiCell->OpenCell (&status)) == NULL)
4265 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
4270 // Create a PTS entry for the new group
4274 TCHAR szOwner[ cchNAME ] = TEXT("");
4275 if (lpiOwner && lpiOwner->fIsUser())
4276 lpiOwner->GetFullUserName (szOwner);
4277 else if (lpiOwner && lpiOwner->fIsGroup())
4278 lpiOwner->GetGroupName (szOwner);
4281 wp.wpPtsGroupCreate.hCell = hCell;
4282 wp.wpPtsGroupCreate.pszGroup = pszGroupName;
4283 wp.wpPtsGroupCreate.pszOwner = (szOwner[0]) ? szOwner : NULL;
4284 wp.wpPtsGroupCreate.idGroup = idGroup;
4287 rc = Worker_DoTask (wtaskPtsGroupCreate, &wp, &status);
4291 // If we were able to create the group successfully, refresh
4292 // the cell status and return the new group's ident.
4298 if ((lpCell = lpiCell->OpenCell (&status)) == NULL)
4302 if (!lpCell->RefreshAccount (pszGroupName, NULL, CELL_REFRESH_ACCOUNT_CREATED_GROUP, &lpiGroup))
4310 NOTIFYCALLBACK::SendNotificationToAll (evtCreateGroupEnd, lpiCell, pszGroupName, status);
4315 return (rc) ? lpiGroup : NULL;
4319 BOOL AfsClass_SetGroupProperties (LPIDENT lpiGroup, LPGROUPPROPERTIES pProperties, ULONG *pStatus)
4325 NOTIFYCALLBACK::SendNotificationToAll (evtChangeGroupBegin, lpiGroup);
4331 if ((lpCell = lpiGroup->OpenCell (&status)) == NULL)
4335 if ((hCell = lpCell->GetCellObject (&status)) == NULL)
4340 // We'll also need this group's current status
4344 if ((lpGroup = lpiGroup->OpenGroup (&status)) == NULL)
4348 if (!lpGroup->GetStatus (&gs, TRUE, &status))
4353 // Modify the group's PTS entry (if requested)
4355 DWORD dwPtsMask = ( MASK_GROUPPROP_aaListStatus |
4356 MASK_GROUPPROP_aaListGroupsOwned |
4357 MASK_GROUPPROP_aaListMembers |
4358 MASK_GROUPPROP_aaAddMember |
4359 MASK_GROUPPROP_aaDeleteMember );
4361 if (rc && (pProperties->dwMask & dwPtsMask))
4363 TCHAR szGroup[ cchNAME ];
4364 lpiGroup->GetGroupName (szGroup);
4367 wp.wpPtsGroupModify.hCell = hCell;
4368 wp.wpPtsGroupModify.pszGroup = szGroup;
4369 memset (&wp.wpPtsGroupModify.Delta, 0x00, sizeof(wp.wpPtsGroupModify.Delta));
4370 wp.wpPtsGroupModify.Delta.listStatus = ACCOUNTACCESS_TO_GROUPACCESS( (pProperties->dwMask & MASK_GROUPPROP_aaListStatus) ? pProperties->aaListStatus : gs.aaListStatus );
4371 wp.wpPtsGroupModify.Delta.listGroupsOwned = ACCOUNTACCESS_TO_GROUPACCESS( (pProperties->dwMask & MASK_GROUPPROP_aaListGroupsOwned) ? pProperties->aaListGroupsOwned : gs.aaListGroupsOwned );
4372 wp.wpPtsGroupModify.Delta.listMembership = ACCOUNTACCESS_TO_GROUPACCESS( (pProperties->dwMask & MASK_GROUPPROP_aaListMembers) ? pProperties->aaListMembers : gs.aaListMembers );
4373 wp.wpPtsGroupModify.Delta.listAdd = ACCOUNTACCESS_TO_GROUPACCESS( (pProperties->dwMask & MASK_GROUPPROP_aaAddMember) ? pProperties->aaAddMember : gs.aaAddMember );
4374 wp.wpPtsGroupModify.Delta.listDelete = ACCOUNTACCESS_TO_GROUPACCESS( (pProperties->dwMask & MASK_GROUPPROP_aaDeleteMember) ? pProperties->aaDeleteMember : gs.aaDeleteMember );
4377 rc = Worker_DoTask (wtaskPtsGroupModify, &wp, &status);
4381 // Change the group's owner (if requested)
4383 if (rc && (pProperties->dwMask & MASK_GROUPPROP_szOwner))
4385 TCHAR szGroup[ cchNAME ];
4386 lpiGroup->GetGroupName (szGroup);
4389 wp.wpPtsGroupOwnerChange.hCell = hCell;
4390 wp.wpPtsGroupOwnerChange.pszGroup = szGroup;
4391 wp.wpPtsGroupOwnerChange.pszOwner = pProperties->szOwner;
4394 rc = Worker_DoTask (wtaskPtsGroupOwnerChange, &wp, &status);
4398 // If we were able to modify the group's properties successfully, refresh
4399 // either the group's status. If the group's owner changed, also refresh
4400 // the group's old and new owners.
4404 if ((lpCell = lpiGroup->OpenCell (&status)) != NULL)