/* ok_to_open - true if it is OK to open the file under * the security model implied by secure_read_path * and safe_write_path */ int ok_to_open(const char *filename, const char *mode) { char fullname[STRMAX]; if (index(mode, 'r')) { /* asking for read permission */ if (secure_read_path) { /* filename must be in path */ find_full_path(filename, fullname); if (!in_tree(fullname, secure_read_path)) return FALSE; } } if (index(mode, 'w')) { /* asking for write permission */ if (safe_write_path) { /* filename must be in path */ find_full_path(filename, fullname); if (!in_tree(fullname, safe_write_path)) return FALSE; } } return TRUE; }
static int action_tree_cb(const char *xpath, const sr_node_t *input, const size_t input_cnt, sr_node_t **output, size_t *output_cnt, void *private_ctx) { S_Trees in_tree(new Trees(input, input_cnt, nullptr)); S_Trees_Holder out_tree(new Trees_Holder(output, output_cnt)); Callback *wrap = (Callback*) private_ctx; return wrap->action_tree(xpath, in_tree, out_tree, wrap->private_ctx["action_tree"]); }