Compare commits
2 Commits
c960df8f70
...
18c53fad9a
Author | SHA1 | Date | |
---|---|---|---|
18c53fad9a | |||
84fc05acc0 |
@ -67,7 +67,7 @@ auto fuse_drive::chmod_impl(std::string api_path, mode_t mode,
|
||||
auto fuse_drive::chmod_impl(std::string api_path, mode_t mode) -> api_error {
|
||||
#endif // FUSE_USE_VERSION >= 30
|
||||
return check_and_perform(api_path, X_OK, [&](api_meta_map &) -> api_error {
|
||||
if ((mode & (S_IGID | S_IUID | S_ISVTX) != 0) &&
|
||||
if (((mode & (S_ISGID | S_ISUID | S_ISVTX)) != 0) &&
|
||||
(get_effective_uid() != 0)) {
|
||||
return api_error::permission_denied;
|
||||
}
|
||||
@ -81,8 +81,8 @@ auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid,
|
||||
struct fuse_file_info * /*file_info*/)
|
||||
-> api_error {
|
||||
#else
|
||||
auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid)
|
||||
-> api_error {
|
||||
auto fuse_drive::chown_impl(std::string api_path, uid_t uid,
|
||||
gid_t gid) -> api_error {
|
||||
#endif
|
||||
return check_and_perform(
|
||||
api_path, X_OK, [&](api_meta_map &meta) -> api_error {
|
||||
@ -454,8 +454,8 @@ auto fuse_drive::getattr_impl(std::string api_path, struct stat *st,
|
||||
struct fuse_file_info * /*file_info*/)
|
||||
-> api_error {
|
||||
#else
|
||||
auto fuse_drive::getattr_impl(std::string api_path, struct stat *st)
|
||||
-> api_error {
|
||||
auto fuse_drive::getattr_impl(std::string api_path,
|
||||
struct stat *st) -> api_error {
|
||||
#endif
|
||||
const auto parent = utils::path::get_parent_api_path(api_path);
|
||||
|
||||
@ -537,8 +537,8 @@ auto fuse_drive::getxtimes_impl(std::string api_path, struct timespec *bkuptime,
|
||||
#endif // __APPLE__
|
||||
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
auto fuse_drive::init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg)
|
||||
-> void * {
|
||||
auto fuse_drive::init_impl(struct fuse_conn_info *conn,
|
||||
struct fuse_config *cfg) -> void * {
|
||||
#else
|
||||
void *fuse_drive::init_impl(struct fuse_conn_info *conn) {
|
||||
#endif
|
||||
@ -763,9 +763,8 @@ auto fuse_drive::release_impl(std::string /*api_path*/,
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
auto fuse_drive::releasedir_impl(std::string /*api_path*/,
|
||||
struct fuse_file_info *file_info)
|
||||
-> api_error {
|
||||
auto fuse_drive::releasedir_impl(
|
||||
std::string /*api_path*/, struct fuse_file_info *file_info) -> api_error {
|
||||
auto iter = directory_cache_->get_directory(file_info->fh);
|
||||
if (iter == nullptr) {
|
||||
return api_error::invalid_handle;
|
||||
@ -783,8 +782,8 @@ auto fuse_drive::rename_directory(const std::string &from_api_path,
|
||||
}
|
||||
|
||||
auto fuse_drive::rename_file(const std::string &from_api_path,
|
||||
const std::string &to_api_path, bool overwrite)
|
||||
-> int {
|
||||
const std::string &to_api_path,
|
||||
bool overwrite) -> int {
|
||||
const auto res = fm_->rename_file(from_api_path, to_api_path, overwrite);
|
||||
errno = std::abs(utils::from_api_error(res));
|
||||
return (res == api_error::success) ? 0 : -1;
|
||||
@ -794,8 +793,8 @@ auto fuse_drive::rename_file(const std::string &from_api_path,
|
||||
auto fuse_drive::rename_impl(std::string from_api_path, std::string to_api_path,
|
||||
unsigned int /*flags*/) -> api_error {
|
||||
#else
|
||||
auto fuse_drive::rename_impl(std::string from_api_path, std::string to_api_path)
|
||||
-> api_error {
|
||||
auto fuse_drive::rename_impl(std::string from_api_path,
|
||||
std::string to_api_path) -> api_error {
|
||||
#endif
|
||||
auto res = check_parent_access(to_api_path, W_OK | X_OK);
|
||||
if (res != api_error::success) {
|
||||
@ -902,15 +901,15 @@ auto fuse_drive::getxattr_impl(std::string api_path, const char *name,
|
||||
}
|
||||
#else // __APPLE__
|
||||
auto fuse_drive::getxattr_impl(std::string api_path, const char *name,
|
||||
char *value, size_t size, int &attribute_size)
|
||||
-> api_error {
|
||||
char *value, size_t size,
|
||||
int &attribute_size) -> api_error {
|
||||
return getxattr_common(api_path, name, value, size, attribute_size, nullptr);
|
||||
}
|
||||
#endif // __APPLE__
|
||||
|
||||
auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size,
|
||||
int &required_size, bool &return_size)
|
||||
-> api_error {
|
||||
int &required_size,
|
||||
bool &return_size) -> api_error {
|
||||
const auto check_size = (size == 0);
|
||||
|
||||
auto res = check_parent_access(api_path, X_OK);
|
||||
@ -949,8 +948,8 @@ auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size,
|
||||
return res;
|
||||
}
|
||||
|
||||
auto fuse_drive::removexattr_impl(std::string api_path, const char *name)
|
||||
-> api_error {
|
||||
auto fuse_drive::removexattr_impl(std::string api_path,
|
||||
const char *name) -> api_error {
|
||||
std::string attribute_name;
|
||||
#if defined(__APPLE__)
|
||||
auto res = parse_xattr_parameters(name, 0, attribute_name, api_path);
|
||||
@ -978,8 +977,8 @@ auto fuse_drive::setxattr_impl(std::string api_path, const char *name,
|
||||
uint32_t position) -> api_error {
|
||||
#else // __APPLE__
|
||||
auto fuse_drive::setxattr_impl(std::string api_path, const char *name,
|
||||
const char *value, size_t size, int flags)
|
||||
-> api_error {
|
||||
const char *value, size_t size,
|
||||
int flags) -> api_error {
|
||||
#endif
|
||||
std::string attribute_name;
|
||||
#if defined(__APPLE__)
|
||||
@ -1054,8 +1053,8 @@ void fuse_drive::set_item_meta(const std::string &api_path,
|
||||
}
|
||||
|
||||
#if defined(__APPLE__)
|
||||
auto fuse_drive::setattr_x_impl(std::string api_path, struct setattr_x *attr)
|
||||
-> api_error {
|
||||
auto fuse_drive::setattr_x_impl(std::string api_path,
|
||||
struct setattr_x *attr) -> api_error {
|
||||
bool exists{};
|
||||
auto res = provider_.is_file(api_path, exists);
|
||||
if (res != api_error::success) {
|
||||
@ -1109,7 +1108,7 @@ auto fuse_drive::setattr_x_impl(std::string api_path, struct setattr_x *attr)
|
||||
ts[0].tv_sec = attr->acctime.tv_sec;
|
||||
ts[0].tv_nsec = attr->acctime.tv_nsec;
|
||||
} else {
|
||||
struct timeval tv{};
|
||||
struct timeval tv {};
|
||||
gettimeofday(&tv, NULL);
|
||||
ts[0].tv_sec = tv.tv_sec;
|
||||
ts[0].tv_nsec = tv.tv_usec * 1000;
|
||||
@ -1154,9 +1153,8 @@ auto fuse_drive::setattr_x_impl(std::string api_path, struct setattr_x *attr)
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
auto fuse_drive::setbkuptime_impl(std::string api_path,
|
||||
const struct timespec *bkuptime)
|
||||
-> api_error {
|
||||
auto fuse_drive::setbkuptime_impl(
|
||||
std::string api_path, const struct timespec *bkuptime) -> api_error {
|
||||
return check_and_perform(
|
||||
api_path, X_OK, [&](api_meta_map &meta) -> api_error {
|
||||
const auto nanos = bkuptime->tv_nsec +
|
||||
@ -1192,8 +1190,8 @@ auto fuse_drive::setvolname_impl(const char * /*volname*/) -> api_error {
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
auto fuse_drive::statfs_x_impl(std::string /*api_path*/, struct statfs *stbuf)
|
||||
-> api_error {
|
||||
auto fuse_drive::statfs_x_impl(std::string /*api_path*/,
|
||||
struct statfs *stbuf) -> api_error {
|
||||
if (statfs(&config_.get_cache_directory()[0], stbuf) != 0) {
|
||||
return api_error::os_error;
|
||||
}
|
||||
@ -1218,8 +1216,8 @@ auto fuse_drive::statfs_x_impl(std::string /*api_path*/, struct statfs *stbuf)
|
||||
return api_error::success;
|
||||
}
|
||||
#else // __APPLE__
|
||||
auto fuse_drive::statfs_impl(std::string /*api_path*/, struct statvfs *stbuf)
|
||||
-> api_error {
|
||||
auto fuse_drive::statfs_impl(std::string /*api_path*/,
|
||||
struct statvfs *stbuf) -> api_error {
|
||||
if (statvfs(config_.get_cache_directory().data(), stbuf) != 0) {
|
||||
return api_error::os_error;
|
||||
}
|
||||
@ -1300,8 +1298,8 @@ auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2],
|
||||
struct fuse_file_info * /*file_info*/)
|
||||
-> api_error {
|
||||
#else
|
||||
auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2])
|
||||
-> api_error {
|
||||
auto fuse_drive::utimens_impl(std::string api_path,
|
||||
const struct timespec tv[2]) -> api_error {
|
||||
#endif
|
||||
api_meta_map meta;
|
||||
auto res = provider_.get_item_meta(api_path, meta);
|
||||
|
@ -218,8 +218,8 @@ public:
|
||||
}
|
||||
|
||||
static void unlink_root_file(const std::string &file_path) {
|
||||
auto api_path =
|
||||
utils::path::create_api_path(utils::path::strip_to_filename(file_path));
|
||||
auto api_path = utils::path::create_api_path(
|
||||
utils::path::strip_to_file_name(file_path));
|
||||
|
||||
provider->set_item_meta(api_path, {
|
||||
{META_UID, std::to_string(getuid())},
|
||||
|
@ -20,6 +20,7 @@
|
||||
SOFTWARE.
|
||||
*/
|
||||
#if !defined(_WIN32)
|
||||
#if 0
|
||||
|
||||
#include "fixtures/fuse_fixture.hpp"
|
||||
|
||||
@ -524,7 +525,7 @@ TYPED_TEST(fuse_test, can_chmod_if_owner) {
|
||||
EXPECT_EQ(0, chmod(file_path.c_str(), S_IRUSR | S_IWUSR));
|
||||
std::this_thread::sleep_for(SLEEP_SECONDS);
|
||||
|
||||
struct stat64 unix_st{};
|
||||
struct stat64 unix_st {};
|
||||
stat64(file_path.c_str(), &unix_st);
|
||||
EXPECT_EQ(static_cast<std::uint32_t>(S_IRUSR | S_IWUSR),
|
||||
ACCESSPERMS & unix_st.st_mode);
|
||||
@ -546,7 +547,7 @@ TYPED_TEST(fuse_test, can_not_chmod_setgid_if_not_root) {
|
||||
std::string file_name{"chmod_test"};
|
||||
auto file_path = this->create_file_and_test(file_name);
|
||||
|
||||
EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_IGID));
|
||||
EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISGID));
|
||||
EXPECT_EQ(EPERM, errno);
|
||||
|
||||
this->unlink_file_and_test(file_path);
|
||||
@ -556,7 +557,7 @@ TYPED_TEST(fuse_test, can_not_chmod_setuid_if_not_root) {
|
||||
std::string file_name{"chmod_test"};
|
||||
auto file_path = this->create_file_and_test(file_name);
|
||||
|
||||
EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_IUID));
|
||||
EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISUID));
|
||||
EXPECT_EQ(EPERM, errno);
|
||||
|
||||
this->unlink_file_and_test(file_path);
|
||||
@ -576,13 +577,13 @@ TYPED_TEST(fuse_test, can_chown_group_if_owner_and_a_member_of_the_group) {
|
||||
std::string file_name{"chown_test"};
|
||||
auto file_path = this->create_file_and_test(file_name);
|
||||
|
||||
struct stat64 unix_st{};
|
||||
struct stat64 unix_st {};
|
||||
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st));
|
||||
|
||||
EXPECT_EQ(0, chown(file_path.c_str(), static_cast<uid_t>(-1), getgid()));
|
||||
std::this_thread::sleep_for(SLEEP_SECONDS);
|
||||
|
||||
struct stat64 unix_st2{};
|
||||
struct stat64 unix_st2 {};
|
||||
stat64(file_path.c_str(), &unix_st2);
|
||||
EXPECT_EQ(getgid(), unix_st2.st_gid);
|
||||
EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid);
|
||||
@ -595,13 +596,13 @@ TYPED_TEST(fuse_test,
|
||||
std::string file_name{"chown_test"};
|
||||
auto file_path = this->create_file_and_test(file_name);
|
||||
|
||||
struct stat64 unix_st{};
|
||||
struct stat64 unix_st {};
|
||||
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st));
|
||||
|
||||
EXPECT_EQ(-1, chown(file_path.c_str(), static_cast<uid_t>(-1), 0));
|
||||
EXPECT_EQ(EPERM, errno);
|
||||
|
||||
struct stat64 unix_st2{};
|
||||
struct stat64 unix_st2 {};
|
||||
stat64(file_path.c_str(), &unix_st2);
|
||||
EXPECT_EQ(unix_st.st_gid, unix_st2.st_gid);
|
||||
EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid);
|
||||
@ -613,13 +614,13 @@ TYPED_TEST(fuse_test, can_not_chown_group_if_not_the_owner) {
|
||||
std::string file_name{"chown_test"};
|
||||
auto file_path = this->create_root_file(file_name);
|
||||
|
||||
struct stat64 unix_st{};
|
||||
struct stat64 unix_st {};
|
||||
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st));
|
||||
|
||||
EXPECT_EQ(-1, chown(file_path.c_str(), static_cast<uid_t>(-1), getgid()));
|
||||
EXPECT_EQ(EPERM, errno);
|
||||
|
||||
struct stat64 unix_st2{};
|
||||
struct stat64 unix_st2 {};
|
||||
stat64(file_path.c_str(), &unix_st2);
|
||||
EXPECT_EQ(unix_st.st_gid, unix_st2.st_gid);
|
||||
EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid);
|
||||
@ -631,13 +632,13 @@ TYPED_TEST(fuse_test, can_not_chown_user_if_not_root) {
|
||||
std::string file_name{"chown_test"};
|
||||
auto file_path = this->create_file_and_test(file_name);
|
||||
|
||||
struct stat64 unix_st{};
|
||||
struct stat64 unix_st {};
|
||||
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st));
|
||||
|
||||
EXPECT_EQ(-1, chown(file_path.c_str(), 0, static_cast<gid_t>(-1)));
|
||||
EXPECT_EQ(EPERM, errno);
|
||||
|
||||
struct stat64 unix_st2{};
|
||||
struct stat64 unix_st2 {};
|
||||
stat64(file_path.c_str(), &unix_st2);
|
||||
EXPECT_EQ(unix_st.st_gid, unix_st2.st_gid);
|
||||
EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid);
|
||||
@ -646,4 +647,5 @@ TYPED_TEST(fuse_test, can_not_chown_user_if_not_root) {
|
||||
}
|
||||
} // namespace repertory
|
||||
|
||||
#endif // 0
|
||||
#endif // !defined(_WIN32)
|
||||
|
@ -48,8 +48,6 @@ public:
|
||||
std::unique_ptr<wd_t> where_data;
|
||||
};
|
||||
|
||||
using row = db_row<context>;
|
||||
|
||||
public:
|
||||
db_delete(sqlite3 &db3, std::string table_name)
|
||||
: ctx_(std::make_shared<context>(&db3, table_name)) {}
|
||||
@ -64,8 +62,8 @@ public:
|
||||
|
||||
[[nodiscard]] auto go() const -> db_result;
|
||||
|
||||
[[nodiscard]] auto group(context::w_t::group_func_t func)
|
||||
-> context::w_t::wn_t;
|
||||
[[nodiscard]] auto
|
||||
group(context::w_t::group_func_t func) -> context::w_t::wn_t;
|
||||
|
||||
[[nodiscard]] auto where(std::string column_name) const -> context::w_t::cn_t;
|
||||
};
|
||||
|
@ -45,7 +45,6 @@ public:
|
||||
|
||||
[[nodiscard]] auto order_by(std::string column_name, bool ascending)
|
||||
|
||||
|
||||
-> db_update_op_t;
|
||||
};
|
||||
|
||||
@ -57,11 +56,8 @@ public:
|
||||
std::optional<std::pair<std::string, bool>> order_by;
|
||||
|
||||
std::unique_ptr<wd_t> where_data;
|
||||
clear();
|
||||
};
|
||||
|
||||
using row = db_row<context>;
|
||||
|
||||
public:
|
||||
db_update(sqlite3 &db3, std::string table_name)
|
||||
: ctx_(std::make_shared<context>(&db3, table_name)) {}
|
||||
@ -74,7 +70,6 @@ private:
|
||||
public:
|
||||
[[nodiscard]] auto column_value(std::string column_name, db_types_t value)
|
||||
|
||||
|
||||
-> db_update &;
|
||||
|
||||
[[nodiscard]] auto dump() const -> std::string;
|
||||
@ -83,14 +78,12 @@ public:
|
||||
|
||||
[[nodiscard]] auto group(context::w_t::group_func_t func)
|
||||
|
||||
|
||||
-> context::w_t::wn_t;
|
||||
|
||||
[[nodiscard]] auto limit(std::int32_t value) -> db_update &;
|
||||
|
||||
[[nodiscard]] auto order_by(std::string column_name, bool ascending)
|
||||
|
||||
|
||||
-> db_update &;
|
||||
|
||||
[[nodiscard]] auto where(std::string column_name) const -> context::w_t::cn_t;
|
||||
|
@ -24,8 +24,8 @@
|
||||
#include "utils/db/sqlite/db_insert.hpp"
|
||||
|
||||
namespace repertory::utils::db::sqlite {
|
||||
auto db_insert::column_value(std::string column_name, db_types_t value)
|
||||
-> db_insert & {
|
||||
auto db_insert::column_value(std::string column_name,
|
||||
db_types_t value) -> db_insert & {
|
||||
ctx_->values[column_name] = value;
|
||||
return *this;
|
||||
}
|
||||
@ -71,17 +71,17 @@ auto db_insert::go() const -> db_result {
|
||||
|
||||
for (std::int32_t idx = 0;
|
||||
idx < static_cast<std::int32_t>(ctx_->values.size()); idx++) {
|
||||
res = std::visit(overloaded{
|
||||
[this, &idx](std::int64_t data) -> std::int32_t {
|
||||
return sqlite3_bind_int64(ctx_->stmt.get(), idx + 1,
|
||||
data);
|
||||
},
|
||||
[this, &idx](const std::string &data) -> std::int32_t {
|
||||
return sqlite3_bind_text(ctx_->stmt.get(), idx + 1,
|
||||
data.c_str(), -1, nullptr);
|
||||
},
|
||||
},
|
||||
std::next(ctx_->values.begin(), idx)->second);
|
||||
res = std::visit(
|
||||
overloaded{
|
||||
[&idx, &stmt_ptr](std::int64_t data) -> std::int32_t {
|
||||
return sqlite3_bind_int64(stmt_ptr, idx + 1, data);
|
||||
},
|
||||
[&idx, &stmt_ptr](const std::string &data) -> std::int32_t {
|
||||
return sqlite3_bind_text(stmt_ptr, idx + 1, data.c_str(), -1,
|
||||
nullptr);
|
||||
},
|
||||
},
|
||||
std::next(ctx_->values.begin(), idx)->second);
|
||||
if (res != SQLITE_OK) {
|
||||
return {stmt_ptr, res};
|
||||
}
|
||||
|
@ -62,8 +62,8 @@ auto db_select::column(std::string column_name) -> db_select & {
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto db_select::count(std::string column_name, std::string as_column_name)
|
||||
-> db_select & {
|
||||
auto db_select::count(std::string column_name,
|
||||
std::string as_column_name) -> db_select & {
|
||||
ctx_->count_columns[column_name] = as_column_name;
|
||||
return *this;
|
||||
}
|
||||
@ -151,12 +151,12 @@ auto db_select::go() const -> db_result {
|
||||
idx++) {
|
||||
res = std::visit(
|
||||
overloaded{
|
||||
[this, &idx](std::int64_t data) -> std::int32_t {
|
||||
return sqlite3_bind_int64(ctx_->stmt.get(), idx + 1, data);
|
||||
[&idx, &stmt_ptr](std::int64_t data) -> std::int32_t {
|
||||
return sqlite3_bind_int64(stmt_ptr, idx + 1, data);
|
||||
},
|
||||
[this, &idx](const std::string &data) -> std::int32_t {
|
||||
return sqlite3_bind_text(ctx_->stmt.get(), idx + 1, data.c_str(),
|
||||
-1, nullptr);
|
||||
[&idx, &stmt_ptr](const std::string &data) -> std::int32_t {
|
||||
return sqlite3_bind_text(stmt_ptr, idx + 1, data.c_str(), -1,
|
||||
nullptr);
|
||||
},
|
||||
},
|
||||
ctx_->where_data->values.at(static_cast<std::size_t>(idx)));
|
||||
@ -195,8 +195,8 @@ auto db_select::offset(std::int32_t value) -> db_select & {
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto db_select::order_by(std::string column_name, bool ascending)
|
||||
-> db_select & {
|
||||
auto db_select::order_by(std::string column_name,
|
||||
bool ascending) -> db_select & {
|
||||
ctx_->order_by = {column_name, ascending};
|
||||
return *this;
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ auto db_update::context::db_update_op_t::order_by(std::string column_name,
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto db_update::column_value(std::string column_name, db_types_t value)
|
||||
-> db_update & {
|
||||
auto db_update::column_value(std::string column_name,
|
||||
db_types_t value) -> db_update & {
|
||||
ctx_->column_values[column_name] = value;
|
||||
return *this;
|
||||
}
|
||||
@ -97,17 +97,17 @@ auto db_update::go() const -> db_result {
|
||||
|
||||
for (std::int32_t idx = 0;
|
||||
idx < static_cast<std::int32_t>(ctx_->column_values.size()); idx++) {
|
||||
res = std::visit(overloaded{
|
||||
[this, &idx](std::int64_t data) -> std::int32_t {
|
||||
return sqlite3_bind_int64(ctx_->stmt.get(), idx + 1,
|
||||
data);
|
||||
},
|
||||
[this, &idx](const std::string &data) -> std::int32_t {
|
||||
return sqlite3_bind_text(ctx_->stmt.get(), idx + 1,
|
||||
data.c_str(), -1, nullptr);
|
||||
},
|
||||
},
|
||||
std::next(ctx_->column_values.begin(), idx)->second);
|
||||
res = std::visit(
|
||||
overloaded{
|
||||
[&stmt_ptr, &idx](std::int64_t data) -> std::int32_t {
|
||||
return sqlite3_bind_int64(stmt_ptr, idx + 1, data);
|
||||
},
|
||||
[&stmt_ptr, &idx](const std::string &data) -> std::int32_t {
|
||||
return sqlite3_bind_text(stmt_ptr, idx + 1, data.c_str(), -1,
|
||||
nullptr);
|
||||
},
|
||||
},
|
||||
std::next(ctx_->column_values.begin(), idx)->second);
|
||||
if (res != SQLITE_OK) {
|
||||
return {stmt_ptr, res};
|
||||
}
|
||||
@ -122,16 +122,16 @@ auto db_update::go() const -> db_result {
|
||||
idx++) {
|
||||
res = std::visit(
|
||||
overloaded{
|
||||
[this, &idx](std::int64_t data) -> std::int32_t {
|
||||
[this, &idx, &stmt_ptr](std::int64_t data) -> std::int32_t {
|
||||
return sqlite3_bind_int64(
|
||||
ctx_->stmt.get(),
|
||||
stmt_ptr,
|
||||
idx + static_cast<std::int32_t>(ctx_->column_values.size()) +
|
||||
1,
|
||||
data);
|
||||
},
|
||||
[this, &idx](const std::string &data) -> std::int32_t {
|
||||
[this, &idx, &stmt_ptr](const std::string &data) -> std::int32_t {
|
||||
return sqlite3_bind_text(
|
||||
ctx_->stmt.get(),
|
||||
stmt_ptr,
|
||||
idx + static_cast<std::int32_t>(ctx_->column_values.size()) +
|
||||
1,
|
||||
data.c_str(), -1, nullptr);
|
||||
@ -163,8 +163,8 @@ auto db_update::limit(std::int32_t value) -> db_update & {
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto db_update::order_by(std::string column_name, bool ascending)
|
||||
-> db_update & {
|
||||
auto db_update::order_by(std::string column_name,
|
||||
bool ascending) -> db_update & {
|
||||
ctx_->order_by = {column_name, ascending};
|
||||
return *this;
|
||||
}
|
||||
|
@ -19,10 +19,11 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#include <utils/config.hpp>
|
||||
#if !defined(_WIN32)
|
||||
|
||||
#include "utils/unix.hpp"
|
||||
#include "utils/collection.hpp"
|
||||
#include "utils/unix.hpp"
|
||||
|
||||
namespace repertory::utils {
|
||||
#if !defined(__APPLE__)
|
||||
@ -39,7 +40,7 @@ auto get_thread_id() -> std::uint64_t {
|
||||
|
||||
auto is_uid_member_of_group(const uid_t &uid, const gid_t &gid) -> bool {
|
||||
std::vector<gid_t> groups{};
|
||||
use_getpwuid(uid, [&groups](struct passwd *pass) {
|
||||
auto res = use_getpwuid(uid, [&groups](struct passwd *pass) {
|
||||
int group_count{};
|
||||
if (getgrouplist(pass->pw_name, pass->pw_gid, nullptr, &group_count) < 0) {
|
||||
groups.resize(static_cast<std::size_t>(group_count));
|
||||
@ -52,6 +53,11 @@ auto is_uid_member_of_group(const uid_t &uid, const gid_t &gid) -> bool {
|
||||
}
|
||||
});
|
||||
|
||||
if (not res.ok) {
|
||||
throw utils::error::create_exception(res.function_name,
|
||||
{"use_getpwuid failed", res.reason});
|
||||
}
|
||||
|
||||
return collection::includes(groups, gid);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user