-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Work on whitelist and implemented #394 * Move code, refactor whiteliests * work on whitelist * Refactor procedures, implement more whitelisting * Upd join room with whitelist * Add whitelist functions * Test * Fix loading task * fix rename * test null * Upd changelog
- Loading branch information
Showing
38 changed files
with
1,152 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include <ti/fn/fn.h> | ||
|
||
static int do__f_whitelist_add(ti_query_t * query, cleri_node_t * nd, ex_t * e) | ||
{ | ||
const int nargs = fn_get_nargs(nd); | ||
cleri_node_t * child = nd->children; | ||
ti_user_t * user; | ||
ti_task_t * task; | ||
ti_raw_t * raw; | ||
int wid; | ||
|
||
if (fn_not_thingsdb_scope("whitelist_add", query, e) || | ||
ti_access_check_err(ti.access_thingsdb, query->user, TI_AUTH_GRANT, e) || | ||
fn_nargs_range("whitelist_add", DOC_WHITELIST_ADD, 2, 3, nargs, e) || | ||
ti_do_statement(query, child, e) || | ||
fn_arg_str_slow("whitelist_add", DOC_WHITELIST_ADD, 1, query->rval, e)) | ||
return e->nr; | ||
|
||
raw = (ti_raw_t *) query->rval; | ||
user = ti_users_get_by_namestrn((const char *) raw->data, raw->n); | ||
if (!user) | ||
return ti_raw_printable_not_found(raw, "user", e); | ||
|
||
ti_val_unsafe_drop(query->rval); | ||
query->rval = NULL; | ||
|
||
/* read whitelist */ | ||
if (ti_do_statement(query, (child = child->next->next), e) || | ||
fn_arg_str_slow("whitelist_add", DOC_WHITELIST_ADD, 2, query->rval, e)) | ||
return e->nr; | ||
|
||
raw = (ti_raw_t *) query->rval; | ||
wid = ti_whitelist_from_strn((const char *) raw->data, raw->n, e); | ||
if (e->nr) | ||
return e->nr; | ||
|
||
ti_val_unsafe_drop(query->rval); | ||
query->rval = NULL; | ||
|
||
if (nargs == 3 && ti_do_statement(query, (child = child->next->next), e)) | ||
return e->nr; | ||
|
||
if (ti_whitelist_add(&user->whitelists[wid], query->rval, e)) | ||
return e->nr; | ||
|
||
task = ti_task_get_task(query->change, ti.thing0); | ||
if (!task || ti_task_add_whitelist_add(task, user, query->rval, wid)) | ||
ex_set_mem(e); /* task cleanup is not required */ | ||
|
||
ti_val_drop(query->rval); | ||
query->rval = (ti_val_t *) ti_nil_get(); | ||
|
||
return e->nr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include <ti/fn/fn.h> | ||
|
||
static int do__f_whitelist_del(ti_query_t * query, cleri_node_t * nd, ex_t * e) | ||
{ | ||
const int nargs = fn_get_nargs(nd); | ||
cleri_node_t * child = nd->children; | ||
ti_user_t * user; | ||
ti_task_t * task; | ||
ti_raw_t * raw; | ||
int wid; | ||
|
||
if (fn_not_thingsdb_scope("whitelist_del", query, e) || | ||
ti_access_check_err(ti.access_thingsdb, query->user, TI_AUTH_GRANT, e) || | ||
fn_nargs_range("whitelist_del", DOC_WHITELIST_DEL, 2, 3, nargs, e) || | ||
ti_do_statement(query, child, e) || | ||
fn_arg_str_slow("whitelist_del", DOC_WHITELIST_DEL, 1, query->rval, e)) | ||
return e->nr; | ||
|
||
raw = (ti_raw_t *) query->rval; | ||
user = ti_users_get_by_namestrn((const char *) raw->data, raw->n); | ||
if (!user) | ||
return ti_raw_printable_not_found(raw, "user", e); | ||
|
||
ti_val_unsafe_drop(query->rval); | ||
query->rval = NULL; | ||
|
||
/* read whitelist */ | ||
if (ti_do_statement(query, (child = child->next->next), e) || | ||
fn_arg_str_slow("whitelist_del", DOC_WHITELIST_DEL, 2, query->rval, e)) | ||
return e->nr; | ||
|
||
raw = (ti_raw_t *) query->rval; | ||
wid = ti_whitelist_from_strn((const char *) raw->data, raw->n, e); | ||
if (e->nr) | ||
return e->nr; | ||
|
||
ti_val_unsafe_drop(query->rval); | ||
query->rval = NULL; | ||
|
||
if (nargs == 3 && ti_do_statement(query, (child = child->next->next), e)) | ||
return e->nr; | ||
|
||
if (ti_whitelist_del(&user->whitelists[wid], query->rval, e)) | ||
return e->nr; | ||
|
||
task = ti_task_get_task(query->change, ti.thing0); | ||
if (!task || ti_task_add_whitelist_del(task, user, query->rval, wid)) | ||
ex_set_mem(e); /* task cleanup is not required */ | ||
|
||
ti_val_drop(query->rval); | ||
query->rval = (ti_val_t *) ti_nil_get(); | ||
|
||
return e->nr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* "-rc0" | ||
* "" | ||
*/ | ||
#define TI_VERSION_PRE_RELEASE "-alpha5" | ||
#define TI_VERSION_PRE_RELEASE "-rc0" | ||
|
||
#define TI_MAINTAINER \ | ||
"Jeroen van der Heijden <[email protected]>" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* ti/whitelist.h | ||
*/ | ||
#ifndef TI_WHITELIST_H_ | ||
#define TI_WHITELIST_H_ | ||
|
||
#include <stdlib.h> | ||
#include <inttypes.h> | ||
#include <ti/name.t.h> | ||
#include <ti/user.t.h> | ||
#include <ex.h> | ||
|
||
/* Do NOT CHANGE the order as this is used and stored in tasks */ | ||
enum | ||
{ | ||
TI_WHITELIST_ROOMS, /* 0 */ | ||
TI_WHITELIST_PROCEDURES, /* 1 */ | ||
}; | ||
|
||
int ti_whitelist_add(vec_t ** whitelist, ti_val_t * val, ex_t * e); | ||
int ti_whitelist_del(vec_t ** whitelist, ti_val_t * val, ex_t * e); | ||
int ti_whitelist_from_strn(const char * str, size_t n, ex_t * e); | ||
int ti_whitelist_test(vec_t * whitelist, ti_name_t * name, ex_t * e); | ||
int ti_whitelist_check(vec_t * whitelist, ti_name_t * name); | ||
|
||
#endif /* TI_WHITELIST_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.