OmniSciDB  471d68cefb
 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 80 of file SysCatalog.cpp.

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

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

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

+ 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 72 of file SysCatalog.cpp.

References CHECK.

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

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

+ Here is the caller graph for this function: