const struct security_token *token,
const char *name,
bool *match);
-void set_namearray(TALLOC_CTX *mem_ctx,
+bool set_namearray(TALLOC_CTX *mem_ctx,
const char *namelist,
const struct security_token *token,
struct name_compare_entry **_name_array);
if possible.
********************************************************************/
-void set_namearray(TALLOC_CTX *mem_ctx,
+bool set_namearray(TALLOC_CTX *mem_ctx,
const char *namelist_in,
const struct security_token *token,
struct name_compare_entry **_name_array)
*_name_array = NULL;
if ((namelist_in == NULL) || (namelist_in[0] == '\0')) {
- return;
+ return true;
}
namelist = path_to_strv(mem_ctx, namelist_in);
if (namelist == NULL) {
DBG_ERR("path_to_strv failed\n");
- return;
+ return false;
}
num_entries = strv_count(namelist);
if (name_array == NULL) {
DBG_ERR("talloc failed\n");
TALLOC_FREE(namelist);
- return;
+ return false;
}
namelist = talloc_reparent(mem_ctx, name_array, namelist);
if (p == NULL) {
DBG_ERR("Missing username\n");
TALLOC_FREE(namelist);
- return;
+ return false;
}
username = p;
DBG_ERR("Missing filename after username '%s'\n",
username);
TALLOC_FREE(namelist);
- return;
+ return false;
}
ok = token_contains_name(talloc_tos(),
username,
&match);
if (!ok) {
- continue;
+ TALLOC_FREE(namelist);
+ return false;
}
if (!match) {
continue;
}
*_name_array = name_array;
- return;
+ return true;
}
int connect_timeout = 0;
int io_timeout = 0;
int ret = -1;
+ bool ok;
config = talloc_zero(handle, struct virusfilter_config);
if (config == NULL) {
exclude_files = lp_parm_const_string(
snum, "virusfilter", "exclude files", NULL);
if (exclude_files != NULL) {
- set_namearray(config,
- exclude_files,
- NULL,
- &config->exclude_files);
+ ok = set_namearray(config,
+ exclude_files,
+ NULL,
+ &config->exclude_files);
+ if (!ok) {
+ DBG_ERR("set_namearray failed\n");
+ return -1;
+ }
}
infected_files = lp_parm_const_string(
snum, "virusfilter", "infected files", NULL);
if (infected_files != NULL) {
- set_namearray(config,
- infected_files,
- NULL,
- &config->infected_files);
+ ok = set_namearray(config,
+ infected_files,
+ NULL,
+ &config->infected_files);
+ if (!ok) {
+ DBG_ERR("set_namearray failed\n");
+ return -1;
+ }
}
config->cache_entry_limit = lp_parm_int(
* and becoming root over and over.
*/
if (config->infected_file_action == VIRUSFILTER_ACTION_QUARANTINE) {
- bool ok = true;
bool dir_exists;
+ ok = true;
/*
* Do SMB_VFS_NEXT_MKDIR(config->quarantine_dir)
/* Add veto/hide lists */
if (!IS_IPC(conn) && !IS_PRINT(conn)) {
- set_namearray(conn,
- lp_veto_oplock_files(talloc_tos(), lp_sub, snum),
- NULL,
- &conn->veto_oplock_list);
- set_namearray(conn,
- lp_aio_write_behind(talloc_tos(), lp_sub, snum),
- NULL,
- &conn->aio_write_behind_list);
+ ok = set_namearray(conn,
+ lp_veto_oplock_files(talloc_tos(), lp_sub, snum),
+ NULL,
+ &conn->veto_oplock_list);
+ if (!ok) {
+ status = NT_STATUS_NO_MEMORY;
+ goto err_root_exit;
+ }
+ ok = set_namearray(conn,
+ lp_aio_write_behind(talloc_tos(), lp_sub, snum),
+ NULL,
+ &conn->aio_write_behind_list);
+ if (!ok) {
+ status = NT_STATUS_NO_MEMORY;
+ goto err_root_exit;
+ }
}
smb_fname_cpath = synthetic_smb_fname(talloc_tos(),
conn->connectpath,
/* Add veto/hide lists */
if (!IS_IPC(conn) && !IS_PRINT(conn)) {
- set_namearray(conn,
- lp_veto_files(talloc_tos(), lp_sub, snum),
- session_info->security_token,
- &ent->veto_list);
- set_namearray(conn,
- lp_hide_files(talloc_tos(), lp_sub, snum),
- session_info->security_token,
- &ent->hide_list);
+ ok = set_namearray(conn,
+ lp_veto_files(talloc_tos(), lp_sub, snum),
+ session_info->security_token,
+ &ent->veto_list);
+ if (!ok) {
+ return false;
+ }
+ ok = set_namearray(conn,
+ lp_hide_files(talloc_tos(), lp_sub, snum),
+ session_info->security_token,
+ &ent->hide_list);
+ if (!ok) {
+ return false;
+ }
}
free_conn_state_if_unused(conn);
d_fprintf(stderr, "namelist: %s\n", namelist);
- set_namearray(talloc_tos(), namelist, NULL, &name_entries);
- SMB_ASSERT(name_entries != NULL);
+ ret = set_namearray(talloc_tos(), namelist, NULL, &name_entries);
+ SMB_ASSERT(ret && name_entries != NULL);
status = samba_path_matching_mswild_create(talloc_tos(),
true, /* case_sensitive */