gboolean affile_open_file(gchar *name, FileOpenOptions *open_opts, FilePermOptions *perm_opts, gint *fd) { cap_t saved_caps; if (_path_is_spurious(name, spurious_paths)) { msg_error("Spurious path, logfile not created", evt_tag_str("path", name), NULL); return FALSE; } saved_caps = g_process_cap_save(); if (!_obtain_capabilities(name, open_opts, perm_opts, &saved_caps)) { g_process_cap_restore(saved_caps); return FALSE; } _validate_file_type(name, open_opts); *fd = _open_fd(name, open_opts, perm_opts); if (!is_file_device(name)) _set_fd_permission(perm_opts, *fd); g_process_cap_restore(saved_caps); msg_trace("affile_open_file", evt_tag_str("path", name), evt_tag_int("fd", *fd), NULL); return (*fd != -1); }
Test(test_pathutils, test_is_file_device) { cr_assert(is_file_device("/dev/null"), "not recognized device file"); }