4 Copyright (C) Amitay Isaacs 2018
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "system/filesys.h"
22 #include "system/dir.h"
24 #include "lib/util/debug.h"
26 #include "common/conf.h"
27 #include "common/path.h"
29 #include "event/event_conf.h"
31 static bool event_conf_validate_debug_script(const char *key
,
32 const char *old_script
,
33 const char *new_script
,
34 enum conf_update_mode mode
)
36 char script
[PATH_MAX
];
37 char script_path
[PATH_MAX
];
42 len
= strlcpy(script
, new_script
, sizeof(script
));
43 if (len
>= sizeof(script
)) {
44 D_ERR("debug script name too long\n");
48 ret
= snprintf(script_path
,
53 if (ret
>= sizeof(script_path
)) {
54 D_ERR("debug script path too long\n");
58 ret
= stat(script_path
, &st
);
60 D_ERR("debug script %s does not exist\n", script_path
);
64 if (! S_ISREG(st
.st_mode
)) {
65 D_ERR("debug script %s is not a file\n", script_path
);
68 if (! (st
.st_mode
& S_IXUSR
)) {
69 D_ERR("debug script %s is not executable\n", script_path
);
76 void event_conf_init(struct conf_context
*conf
)
78 conf_define_section(conf
, EVENT_CONF_SECTION
, NULL
);
80 conf_define_string(conf
,
82 EVENT_CONF_DEBUG_SCRIPT
,
84 event_conf_validate_debug_script
);