|
@@ -1,4 +1,4 @@
|
|
|
-
|
|
|
+
|
|
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
|
|
* Copyright (c) 2007-2016, The Tor Project, Inc. */
|
|
@@ -447,6 +447,56 @@ sb_open(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+static int
|
|
|
+sb_chmod(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|
|
+{
|
|
|
+ int rc;
|
|
|
+ sandbox_cfg_t *elem = NULL;
|
|
|
+
|
|
|
+
|
|
|
+ for (elem = filter; elem != NULL; elem = elem->next) {
|
|
|
+ smp_param_t *param = elem->param;
|
|
|
+
|
|
|
+ if (param != NULL && param->prot == 1 && param->syscall
|
|
|
+ == SCMP_SYS(chmod)) {
|
|
|
+ rc = seccomp_rule_add_1(ctx, SCMP_ACT_ALLOW, SCMP_SYS(chmod),
|
|
|
+ SCMP_CMP_STR(0, SCMP_CMP_EQ, param->value));
|
|
|
+ if (rc != 0) {
|
|
|
+ log_err(LD_BUG,"(Sandbox) failed to add open syscall, received "
|
|
|
+ "libseccomp error %d", rc);
|
|
|
+ return rc;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+static int
|
|
|
+sb_chown(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|
|
+{
|
|
|
+ int rc;
|
|
|
+ sandbox_cfg_t *elem = NULL;
|
|
|
+
|
|
|
+
|
|
|
+ for (elem = filter; elem != NULL; elem = elem->next) {
|
|
|
+ smp_param_t *param = elem->param;
|
|
|
+
|
|
|
+ if (param != NULL && param->prot == 1 && param->syscall
|
|
|
+ == SCMP_SYS(chown)) {
|
|
|
+ rc = seccomp_rule_add_1(ctx, SCMP_ACT_ALLOW, SCMP_SYS(chown),
|
|
|
+ SCMP_CMP_STR(0, SCMP_CMP_EQ, param->value));
|
|
|
+ if (rc != 0) {
|
|
|
+ log_err(LD_BUG,"(Sandbox) failed to add open syscall, received "
|
|
|
+ "libseccomp error %d", rc);
|
|
|
+ return rc;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
static int
|
|
|
sb__sysctl(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|
|
{
|
|
@@ -980,6 +1030,8 @@ static sandbox_filter_func_t filter_func[] = {
|
|
|
#ifdef __NR_mmap2
|
|
|
sb_mmap2,
|
|
|
#endif
|
|
|
+ sb_chown,
|
|
|
+ sb_chmod,
|
|
|
sb_open,
|
|
|
sb_openat,
|
|
|
sb__sysctl,
|
|
@@ -1255,6 +1307,40 @@ sandbox_cfg_allow_open_filename(sandbox_cfg_t **cfg, char *file)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+int
|
|
|
+sandbox_cfg_allow_chmod_filename(sandbox_cfg_t **cfg, char *file)
|
|
|
+{
|
|
|
+ sandbox_cfg_t *elem = NULL;
|
|
|
+
|
|
|
+ elem = new_element(SCMP_SYS(chmod), file);
|
|
|
+ if (!elem) {
|
|
|
+ log_err(LD_BUG,"(Sandbox) failed to register parameter!");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ elem->next = *cfg;
|
|
|
+ *cfg = elem;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+int
|
|
|
+sandbox_cfg_allow_chown_filename(sandbox_cfg_t **cfg, char *file)
|
|
|
+{
|
|
|
+ sandbox_cfg_t *elem = NULL;
|
|
|
+
|
|
|
+ elem = new_element(SCMP_SYS(chown), file);
|
|
|
+ if (!elem) {
|
|
|
+ log_err(LD_BUG,"(Sandbox) failed to register parameter!");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ elem->next = *cfg;
|
|
|
+ *cfg = elem;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
int
|
|
|
sandbox_cfg_allow_rename(sandbox_cfg_t **cfg, char *file1, char *file2)
|
|
|
{
|