34int main(
int argc,
char const* argv[])
38 return_if(argc != 3, EXIT_FAILURE,
"E::Incorrect # of arguments for bwrap-apparmor");
40 fs::path path_file_log = std::string{argv[1]};
45 fs::path path_file_bwrap_src{argv[2]};
46 fs::path path_dir_bwrap{
"/opt/flatimage"};
47 fs::path path_file_bwrap_dst{path_dir_bwrap /
"bwrap"};
48 fs::path path_file_profile{
"/etc/apparmor.d/flatimage"};
50 Try(fs::create_directories(path_dir_bwrap));
52 Try(fs::copy_file(path_file_bwrap_src, path_file_bwrap_dst, fs::copy_options::overwrite_existing));
55 auto perms = owner_all | group_read | group_exec | others_read | others_exec;
56 Catch(fs::permissions(path_file_bwrap_dst, perms, fs::perm_options::replace))
57 .discard(
"C::Failed to set permissions to '{}'", path_file_bwrap_dst);
59 std::ofstream file_profile(path_file_profile);
60 return_if(not file_profile.is_open(), EXIT_FAILURE,
"E::Could not open profile file");
61 file_profile << profile_bwrap;
65 .with_args(
"-r", path_file_profile)