return pass_grp_ptr->gr_gid;
}
-void OS::change_owner_and_group(fs::path path, const int session_uid, const int group_id)
+void OS::change_owner_and_group(const fs::path& path, const int session_uid, const int group_id)
{
if (lchown(path.c_str(), session_uid, group_id) == -1)
throw std::system_error(errno, std::system_category(),
+ "` file/directory");
}
-std::string OS::get_smack_label(fs::path src_path, smack_label_type type)
+std::string OS::get_smack_label(const fs::path& src_path, smack_label_type type)
{
char *label_raw = nullptr;
int ret = smack_lgetlabel(src_path.c_str(), &label_raw, type);
return out_str;
}
-static int copy_label(std::string label, fs::path dest_path, smack_label_type type)
+static int copy_label(const std::string& label, const fs::path& dest_path, smack_label_type type)
{
if (type != SMACK_LABEL_TRANSMUTE)
return smack_lsetlabel(dest_path.c_str(), label.c_str(), type);
return ret;
}
-void OS::copy_smack_attributes(fs::path src_path, fs::path dest_path)
+void OS::copy_smack_attributes(const fs::path& src_path, const fs::path& dest_path)
{
static const enum smack_label_type label_types[] = {
SMACK_LABEL_ACCESS,
}
}
-void OS::set_ownership_and_perms(fs::path src_path, fs::path dest_path, fs::perms permissions,
+void OS::set_ownership_and_perms(const fs::path& src_path, const fs::path& dest_path, fs::perms permissions,
const int session_uid, const int gid, bool copy_perms_from_skel)
{
const auto info = fs::symlink_status (src_path);
fs::permissions(dest_path, permissions);
}
-static std::optional <dev_t> get_stat_dev(fs::path path)
+static std::optional <dev_t> get_stat_dev(const fs::path& path)
{
struct stat info;
const int ret = lstat(path.c_str(), &info);
return info.st_dev;
}
-bool OS::is_mountpoint(fs::path path)
+bool OS::is_mountpoint(const fs::path& path)
{
const auto path_dev = get_stat_dev(path);
if (!path_dev)
int get_gid_from_name(std::string_view group_name);
- void change_owner_and_group(fs::path path, const int session_uid, const int group_id);
+ void change_owner_and_group(const fs::path& path, const int session_uid, const int group_id);
- std::string get_smack_label(fs::path src_path, smack_label_type type);
+ std::string get_smack_label(const fs::path& src_path, smack_label_type type);
- void copy_smack_attributes(fs::path src_path, fs::path dest_path);
+ void copy_smack_attributes(const fs::path& src_path, const fs::path& dest_path);
- void set_ownership_and_perms(fs::path src_path, fs::path dest_path, fs::perms permissions,
+ void set_ownership_and_perms(const fs::path& src_path, const fs::path& dest_path, fs::perms permissions,
const int session_uid, const int gid, bool copy_perms_from_skel);
- bool is_mountpoint(fs::path path);
+ bool is_mountpoint(const fs::path& path);
}
registered.emplace(name, std::move(match));
}
- void on_start(Primary v, Secondary a)
+ void on_start(const Primary& v, const Secondary& a)
{
// See the comment in on_timeout.
timeouts.erase(std::remove_if(timeouts.begin(), timeouts.end(),
}
}
- void on_client_done(Primary v, const std::string &name)
+ void on_client_done(const Primary& v, const std::string &name)
{
if (!waiting.contains(v))
return; // This could be an error, but then we would have a race condition with the timeout.
}
}
- void drop_name(Primary v, std::unordered_set<std::string> &waits, Secondary aux, const std::string &name)
+ void drop_name(const Primary& v, std::unordered_set<std::string> &waits, const Secondary& aux, const std::string &name)
{
waits.erase(name);
finalize_if_empty(v, aux);
}
- void on_timeout(Primary v)
+ void on_timeout(const Primary& v)
{
if (!waiting.contains(v))
return;
// What we do instead, is clearing the array up a bit when adding a new timeout in on_start.
}
- void finalize_if_empty(Primary v, Secondary a)
+ void finalize_if_empty(const Primary& v, const Secondary& a)
{
// TODO: I don't like this, somehow.
// Refactor suggestions are more than welcome.
// Again, let's clean up in on_start instead.
}
- void signal(Primary v, Secondary a)
+ void signal(const Primary& v, const Secondary& a)
{
GError *err = nullptr;
if (!g_dbus_connection_emit_signal(connection, nullptr, bus_object.data(), bus_iface.data(), completion_signal.data(),