MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / init

Method init

src/common/utils.cpp:623–707  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

621 }
622
623 void init()
624 {
625 alignas(SID) char sid[SECURITY_MAX_SID_SIZE];
626 DWORD cbSid = sizeof(sid);
627
628 // For now use EVERYONE, could be changed later
629 cbSid = sizeof(sid);
630 if (!CreateWellKnownSid(WinWorldSid, NULL, &sid, &cbSid))
631 raiseError("CreateWellKnownSid");
632
633 // Create security descriptor which allows generic access to the just created SID
634
635 SECURITY_ATTRIBUTES sa;
636 RtlSecureZeroMemory(&sa, sizeof(sa));
637 sa.nLength = sizeof(sa);
638 sa.bInheritHandle = FALSE;
639
640 char strSecDesc[255];
641 LPSTR strSid = NULL;
642 if (ConvertSidToStringSid(&sid, &strSid))
643 {
644 snprintf(strSecDesc, sizeof(strSecDesc), "D:(A;;GA;;;%s)", strSid);
645 LocalFree(strSid);
646 }
647 else
648 strncpy(strSecDesc, "D:(A;;GA;;;WD)", sizeof(strSecDesc));
649
650 if (!ConvertStringSecurityDescriptorToSecurityDescriptor(strSecDesc, SDDL_REVISION_1,
651 &sa.lpSecurityDescriptor, NULL))
652 {
653 raiseError("ConvertStringSecurityDescriptorToSecurityDescriptor");
654 }
655
656 Firebird::Cleanup cleanSecDesc( [&sa] {
657 LocalFree(sa.lpSecurityDescriptor);
658 });
659
660 HANDLE hBoundaryDesc = CreateBoundaryDescriptor(sBoundaryName, 0);
661 if (hBoundaryDesc == NULL)
662 raiseError("CreateBoundaryDescriptor");
663
664 Firebird::Cleanup cleanBndDesc( [&hBoundaryDesc] {
665 DeleteBoundaryDescriptor(hBoundaryDesc);
666 });
667
668 if (!AddSIDToBoundaryDescriptor(&hBoundaryDesc, &sid))
669 raiseError("AddSIDToBoundaryDescriptor");
670
671 int retry = 0;
672 while (true)
673 {
674 m_hNamespace = CreatePrivateNamespace(&sa, hBoundaryDesc, sPrivateNameSpace);
675
676 if (m_hNamespace == NULL)
677 {
678 DWORD err = GetLastError();
679 if (err != ERROR_ALREADY_EXISTS)
680 raiseError("CreatePrivateNamespace");

Callers 1

copyStatusFunction · 0.45

Calls 6

ISC_get_security_descFunction · 0.85
snprintfFunction · 0.70
raiseErrorFunction · 0.50
sleepFunction · 0.50
appendMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected