OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{SysCatalog.cpp} Namespace Reference

Functions

std::string hash_with_bcrypt (const std::string &pwd)
 
std::filesystem::path copy_catalog_if_read_only (std::filesystem::path base_data_path)
 

Function Documentation

std::filesystem::path anonymous_namespace{SysCatalog.cpp}::copy_catalog_if_read_only ( std::filesystem::path  base_data_path)

Definition at line 81 of file SysCatalog.cpp.

References CHECK_NE, gpu_enabled::copy(), g_read_only, logger::INFO, shared::kCatalogDirectoryName, and LOG.

Referenced by Catalog_Namespace::SysCatalog::init().

81  {
82  std::filesystem::path catalog_base_data_path;
83 
84  // For a read-only server, make a temporary copy of the catalog directory.
85  // This catalog copy must take place before any other catalog accesses.
86  if (!g_read_only) {
87  // Catalog directory will be in the normal location.
88  catalog_base_data_path = base_data_path;
89  } else {
90  // Catalog directory will be in a temporary location.
91  catalog_base_data_path = base_data_path / "temporary";
92 
93  // Delete the temporary directory if it exists.
94  // The name "temporary" is hardcoded so nobody should object to its deletion!
95  CHECK_NE(catalog_base_data_path.string().find("temporary"), std::string::npos);
96  CHECK_NE(catalog_base_data_path, base_data_path);
97  if (std::filesystem::exists(catalog_base_data_path)) {
98  std::filesystem::remove_all(catalog_base_data_path);
99  }
100  std::filesystem::create_directories(catalog_base_data_path);
101 
102  // Make the temporary copy of the catalog.
103  const auto normal_catalog_path = base_data_path / shared::kCatalogDirectoryName;
104  const auto temporary_catalog_path =
105  catalog_base_data_path / shared::kCatalogDirectoryName;
106  LOG(INFO) << "copying catalog from " << normal_catalog_path << " to "
107  << temporary_catalog_path << " for read-only server";
108  std::filesystem::copy(normal_catalog_path,
109  temporary_catalog_path,
110  std::filesystem::copy_options::recursive);
111  }
112 
113  return catalog_base_data_path;
114 }
#define LOG(tag)
Definition: Logger.h:217
DEVICE auto copy(ARGS &&...args)
Definition: gpu_enabled.h:51
#define CHECK_NE(x, y)
Definition: Logger.h:232
bool g_read_only
Definition: File.cpp:40
const std::string kCatalogDirectoryName

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string anonymous_namespace{SysCatalog.cpp}::hash_with_bcrypt ( const std::string &  pwd)

Definition at line 73 of file SysCatalog.cpp.

References CHECK.

Referenced by Catalog_Namespace::SysCatalog::alterUser(), Catalog_Namespace::SysCatalog::createUser(), Catalog_Namespace::SysCatalog::initDB(), Catalog_Namespace::SysCatalog::updateBlankPasswordsToRandom(), Catalog_Namespace::SysCatalog::updatePasswordsToHashes(), and Catalog_Namespace::UserAlterations::wouldChange().

73  {
74  char salt[BCRYPT_HASHSIZE], hash[BCRYPT_HASHSIZE];
75  CHECK(bcrypt_gensalt(-1, salt) == 0);
76  CHECK(bcrypt_hashpw(pwd.c_str(), salt, hash) == 0);
77  return std::string(hash, BCRYPT_HASHSIZE);
78 }
#define CHECK(condition)
Definition: Logger.h:223

+ Here is the caller graph for this function: