This commit is contained in:
parent
84fc05acc0
commit
18c53fad9a
@ -218,8 +218,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void unlink_root_file(const std::string &file_path) {
|
static void unlink_root_file(const std::string &file_path) {
|
||||||
auto api_path =
|
auto api_path = utils::path::create_api_path(
|
||||||
utils::path::create_api_path(utils::path::strip_to_filename(file_path));
|
utils::path::strip_to_file_name(file_path));
|
||||||
|
|
||||||
provider->set_item_meta(api_path, {
|
provider->set_item_meta(api_path, {
|
||||||
{META_UID, std::to_string(getuid())},
|
{META_UID, std::to_string(getuid())},
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
|
#if 0
|
||||||
|
|
||||||
#include "fixtures/fuse_fixture.hpp"
|
#include "fixtures/fuse_fixture.hpp"
|
||||||
|
|
||||||
@ -646,4 +647,5 @@ TYPED_TEST(fuse_test, can_not_chown_user_if_not_root) {
|
|||||||
}
|
}
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
|
||||||
|
#endif // 0
|
||||||
#endif // !defined(_WIN32)
|
#endif // !defined(_WIN32)
|
||||||
|
@ -48,8 +48,6 @@ public:
|
|||||||
std::unique_ptr<wd_t> where_data;
|
std::unique_ptr<wd_t> where_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
using row = db_row<context>;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
db_delete(sqlite3 &db3, std::string table_name)
|
db_delete(sqlite3 &db3, std::string table_name)
|
||||||
: ctx_(std::make_shared<context>(&db3, table_name)) {}
|
: ctx_(std::make_shared<context>(&db3, table_name)) {}
|
||||||
@ -64,8 +62,8 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] auto go() const -> db_result;
|
[[nodiscard]] auto go() const -> db_result;
|
||||||
|
|
||||||
[[nodiscard]] auto group(context::w_t::group_func_t func)
|
[[nodiscard]] auto
|
||||||
-> context::w_t::wn_t;
|
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;
|
[[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)
|
[[nodiscard]] auto order_by(std::string column_name, bool ascending)
|
||||||
|
|
||||||
|
|
||||||
-> db_update_op_t;
|
-> db_update_op_t;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -57,11 +56,8 @@ public:
|
|||||||
std::optional<std::pair<std::string, bool>> order_by;
|
std::optional<std::pair<std::string, bool>> order_by;
|
||||||
|
|
||||||
std::unique_ptr<wd_t> where_data;
|
std::unique_ptr<wd_t> where_data;
|
||||||
clear();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
using row = db_row<context>;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
db_update(sqlite3 &db3, std::string table_name)
|
db_update(sqlite3 &db3, std::string table_name)
|
||||||
: ctx_(std::make_shared<context>(&db3, table_name)) {}
|
: ctx_(std::make_shared<context>(&db3, table_name)) {}
|
||||||
@ -74,7 +70,6 @@ private:
|
|||||||
public:
|
public:
|
||||||
[[nodiscard]] auto column_value(std::string column_name, db_types_t value)
|
[[nodiscard]] auto column_value(std::string column_name, db_types_t value)
|
||||||
|
|
||||||
|
|
||||||
-> db_update &;
|
-> db_update &;
|
||||||
|
|
||||||
[[nodiscard]] auto dump() const -> std::string;
|
[[nodiscard]] auto dump() const -> std::string;
|
||||||
@ -83,14 +78,12 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] auto group(context::w_t::group_func_t func)
|
[[nodiscard]] auto group(context::w_t::group_func_t func)
|
||||||
|
|
||||||
|
|
||||||
-> context::w_t::wn_t;
|
-> context::w_t::wn_t;
|
||||||
|
|
||||||
[[nodiscard]] auto limit(std::int32_t value) -> db_update &;
|
[[nodiscard]] auto limit(std::int32_t value) -> db_update &;
|
||||||
|
|
||||||
[[nodiscard]] auto order_by(std::string column_name, bool ascending)
|
[[nodiscard]] auto order_by(std::string column_name, bool ascending)
|
||||||
|
|
||||||
|
|
||||||
-> db_update &;
|
-> db_update &;
|
||||||
|
|
||||||
[[nodiscard]] auto where(std::string column_name) const -> context::w_t::cn_t;
|
[[nodiscard]] auto where(std::string column_name) const -> context::w_t::cn_t;
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
#include "utils/db/sqlite/db_insert.hpp"
|
#include "utils/db/sqlite/db_insert.hpp"
|
||||||
|
|
||||||
namespace repertory::utils::db::sqlite {
|
namespace repertory::utils::db::sqlite {
|
||||||
auto db_insert::column_value(std::string column_name, db_types_t value)
|
auto db_insert::column_value(std::string column_name,
|
||||||
-> db_insert & {
|
db_types_t value) -> db_insert & {
|
||||||
ctx_->values[column_name] = value;
|
ctx_->values[column_name] = value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -71,14 +71,14 @@ auto db_insert::go() const -> db_result {
|
|||||||
|
|
||||||
for (std::int32_t idx = 0;
|
for (std::int32_t idx = 0;
|
||||||
idx < static_cast<std::int32_t>(ctx_->values.size()); idx++) {
|
idx < static_cast<std::int32_t>(ctx_->values.size()); idx++) {
|
||||||
res = std::visit(overloaded{
|
res = std::visit(
|
||||||
[this, &idx](std::int64_t data) -> std::int32_t {
|
overloaded{
|
||||||
return sqlite3_bind_int64(ctx_->stmt.get(), idx + 1,
|
[&idx, &stmt_ptr](std::int64_t data) -> std::int32_t {
|
||||||
data);
|
return sqlite3_bind_int64(stmt_ptr, idx + 1, data);
|
||||||
},
|
},
|
||||||
[this, &idx](const std::string &data) -> std::int32_t {
|
[&idx, &stmt_ptr](const std::string &data) -> std::int32_t {
|
||||||
return sqlite3_bind_text(ctx_->stmt.get(), idx + 1,
|
return sqlite3_bind_text(stmt_ptr, idx + 1, data.c_str(), -1,
|
||||||
data.c_str(), -1, nullptr);
|
nullptr);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
std::next(ctx_->values.begin(), idx)->second);
|
std::next(ctx_->values.begin(), idx)->second);
|
||||||
|
@ -62,8 +62,8 @@ auto db_select::column(std::string column_name) -> db_select & {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto db_select::count(std::string column_name, std::string as_column_name)
|
auto db_select::count(std::string column_name,
|
||||||
-> db_select & {
|
std::string as_column_name) -> db_select & {
|
||||||
ctx_->count_columns[column_name] = as_column_name;
|
ctx_->count_columns[column_name] = as_column_name;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -151,12 +151,12 @@ auto db_select::go() const -> db_result {
|
|||||||
idx++) {
|
idx++) {
|
||||||
res = std::visit(
|
res = std::visit(
|
||||||
overloaded{
|
overloaded{
|
||||||
[this, &idx](std::int64_t data) -> std::int32_t {
|
[&idx, &stmt_ptr](std::int64_t data) -> std::int32_t {
|
||||||
return sqlite3_bind_int64(ctx_->stmt.get(), idx + 1, data);
|
return sqlite3_bind_int64(stmt_ptr, idx + 1, data);
|
||||||
},
|
},
|
||||||
[this, &idx](const std::string &data) -> std::int32_t {
|
[&idx, &stmt_ptr](const std::string &data) -> std::int32_t {
|
||||||
return sqlite3_bind_text(ctx_->stmt.get(), idx + 1, data.c_str(),
|
return sqlite3_bind_text(stmt_ptr, idx + 1, data.c_str(), -1,
|
||||||
-1, nullptr);
|
nullptr);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ctx_->where_data->values.at(static_cast<std::size_t>(idx)));
|
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;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto db_select::order_by(std::string column_name, bool ascending)
|
auto db_select::order_by(std::string column_name,
|
||||||
-> db_select & {
|
bool ascending) -> db_select & {
|
||||||
ctx_->order_by = {column_name, ascending};
|
ctx_->order_by = {column_name, ascending};
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ auto db_update::context::db_update_op_t::order_by(std::string column_name,
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto db_update::column_value(std::string column_name, db_types_t value)
|
auto db_update::column_value(std::string column_name,
|
||||||
-> db_update & {
|
db_types_t value) -> db_update & {
|
||||||
ctx_->column_values[column_name] = value;
|
ctx_->column_values[column_name] = value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -97,14 +97,14 @@ auto db_update::go() const -> db_result {
|
|||||||
|
|
||||||
for (std::int32_t idx = 0;
|
for (std::int32_t idx = 0;
|
||||||
idx < static_cast<std::int32_t>(ctx_->column_values.size()); idx++) {
|
idx < static_cast<std::int32_t>(ctx_->column_values.size()); idx++) {
|
||||||
res = std::visit(overloaded{
|
res = std::visit(
|
||||||
[this, &idx](std::int64_t data) -> std::int32_t {
|
overloaded{
|
||||||
return sqlite3_bind_int64(ctx_->stmt.get(), idx + 1,
|
[&stmt_ptr, &idx](std::int64_t data) -> std::int32_t {
|
||||||
data);
|
return sqlite3_bind_int64(stmt_ptr, idx + 1, data);
|
||||||
},
|
},
|
||||||
[this, &idx](const std::string &data) -> std::int32_t {
|
[&stmt_ptr, &idx](const std::string &data) -> std::int32_t {
|
||||||
return sqlite3_bind_text(ctx_->stmt.get(), idx + 1,
|
return sqlite3_bind_text(stmt_ptr, idx + 1, data.c_str(), -1,
|
||||||
data.c_str(), -1, nullptr);
|
nullptr);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
std::next(ctx_->column_values.begin(), idx)->second);
|
std::next(ctx_->column_values.begin(), idx)->second);
|
||||||
@ -122,16 +122,16 @@ auto db_update::go() const -> db_result {
|
|||||||
idx++) {
|
idx++) {
|
||||||
res = std::visit(
|
res = std::visit(
|
||||||
overloaded{
|
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(
|
return sqlite3_bind_int64(
|
||||||
ctx_->stmt.get(),
|
stmt_ptr,
|
||||||
idx + static_cast<std::int32_t>(ctx_->column_values.size()) +
|
idx + static_cast<std::int32_t>(ctx_->column_values.size()) +
|
||||||
1,
|
1,
|
||||||
data);
|
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(
|
return sqlite3_bind_text(
|
||||||
ctx_->stmt.get(),
|
stmt_ptr,
|
||||||
idx + static_cast<std::int32_t>(ctx_->column_values.size()) +
|
idx + static_cast<std::int32_t>(ctx_->column_values.size()) +
|
||||||
1,
|
1,
|
||||||
data.c_str(), -1, nullptr);
|
data.c_str(), -1, nullptr);
|
||||||
@ -163,8 +163,8 @@ auto db_update::limit(std::int32_t value) -> db_update & {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto db_update::order_by(std::string column_name, bool ascending)
|
auto db_update::order_by(std::string column_name,
|
||||||
-> db_update & {
|
bool ascending) -> db_update & {
|
||||||
ctx_->order_by = {column_name, ascending};
|
ctx_->order_by = {column_name, ascending};
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,11 @@
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
#include <utils/config.hpp>
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
|
|
||||||
#include "utils/unix.hpp"
|
|
||||||
#include "utils/collection.hpp"
|
#include "utils/collection.hpp"
|
||||||
|
#include "utils/unix.hpp"
|
||||||
|
|
||||||
namespace repertory::utils {
|
namespace repertory::utils {
|
||||||
#if !defined(__APPLE__)
|
#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 {
|
auto is_uid_member_of_group(const uid_t &uid, const gid_t &gid) -> bool {
|
||||||
std::vector<gid_t> groups{};
|
std::vector<gid_t> groups{};
|
||||||
use_getpwuid(uid, [&groups](struct passwd *pass) {
|
auto res = use_getpwuid(uid, [&groups](struct passwd *pass) {
|
||||||
int group_count{};
|
int group_count{};
|
||||||
if (getgrouplist(pass->pw_name, pass->pw_gid, nullptr, &group_count) < 0) {
|
if (getgrouplist(pass->pw_name, pass->pw_gid, nullptr, &group_count) < 0) {
|
||||||
groups.resize(static_cast<std::size_t>(group_count));
|
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);
|
return collection::includes(groups, gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user