-
Notifications
You must be signed in to change notification settings - Fork 38
Plugins configuration files #210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
joaomeira26
wants to merge
14
commits into
multipath-tcp:main
Choose a base branch
from
MPTCP-Lab:plugins_confs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2dabc50
added plugins configuration directory option
d73de81
added default plugins_conf_dir
54086ff
create default dir at install
d2907b1
added internal read config function
78b72c5
added plugin read config op
0a609a9
updated tests
e42841c
fixed mkdir
8169b07
fixed mptcpd_parse_func_t const
95c6c76
reverted return l_settings_load_from_file success
47dc8ed
workaround ell/cleanup.h c++ error
ae30db3
Revert "workaround ell/cleanup.h c++ error"
0003544
declared struct l_settings in types.h
e8c5f7e
Merge branch 'master' into plugins_confs
c99c691
fixed test plugins
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,84 @@ | ||
| #include <stdlib.h> | ||
| #include <stdlib.h> | ||
| #include <stdbool.h> | ||
| #include <assert.h> | ||
| #include <sys/stat.h> | ||
| #include <errno.h> | ||
|
|
||
| #include <ell/log.h> | ||
| #include <ell/util.h> | ||
| #include <ell/settings.h> | ||
|
|
||
| #include <mptcpd/types.h> | ||
|
|
||
| #include <mptcpd/private/configuration.h> | ||
|
|
||
| /** | ||
| * @brief Verify file permissions are secure. | ||
| * | ||
| * Mptcpd requires that its files are only writable by the owner and | ||
| * group. Verify that the "other" write mode, @c S_IWOTH, isn't set. | ||
| * | ||
| * @param[in] f Name of file to check for expected permissions. | ||
| * | ||
| * @note There is a TOCTOU race condition between this file | ||
| * permissions check and subsequent calls to functions that | ||
| * access the given file @a f, such as the call to | ||
| * @c l_settings_load_from_file(). There is currently no way | ||
| * to avoid that with the existing ELL API. | ||
| */ | ||
| static bool check_file_perms(char const *f) | ||
| { | ||
| struct stat sb; | ||
| bool perms_ok = false; | ||
|
|
||
| if (stat(f, &sb) == 0) { | ||
| perms_ok = S_ISREG(sb.st_mode) | ||
| && (sb.st_mode & S_IWOTH) == 0; | ||
|
|
||
| if (!perms_ok) | ||
| l_error("\"%s\" should be a file that is not " | ||
| "world writable.", | ||
| f); | ||
| } else if (errno == ENOENT) { | ||
| perms_ok = true; | ||
|
|
||
| l_debug("File \"%s\" does not exist.", f); | ||
| } else { | ||
| l_debug("Unexpected error during file " | ||
| "permissions check."); | ||
| } | ||
|
|
||
| return perms_ok; | ||
| } | ||
|
|
||
| bool mptcpd_config_read(char const *filename, | ||
| mptcpd_parse_func_t fun, | ||
| void *user_data) | ||
| { | ||
| assert(filename != NULL); | ||
| assert(fun != NULL); | ||
|
|
||
| if (!check_file_perms(filename)) | ||
| return false; | ||
|
|
||
| struct l_settings *const settings = l_settings_new(); | ||
| if (settings == NULL) { | ||
| l_error("Unable to create mptcpd settings."); | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| bool success = l_settings_load_from_file(settings, filename); | ||
|
|
||
| if (success) | ||
| fun(settings, user_data); | ||
| else | ||
| l_debug("Unable to load mptcpd settings from file '%s'", | ||
| filename); | ||
|
|
||
| l_settings_free(settings); | ||
|
|
||
| return success; | ||
| } | ||
|
|
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -32,10 +32,12 @@ libpath_manager_la_LIBADD = \ | |
| $(top_builddir)/lib/libmptcpd.la \ | ||
| $(ELL_LIBS) $(CODE_COVERAGE_LIBS) | ||
|
|
||
| libpath_manager_la_CPPFLAGS = \ | ||
| $(AM_CPPFLAGS) \ | ||
| libpath_manager_la_CPPFLAGS = \ | ||
| $(AM_CPPFLAGS) \ | ||
| -DMPTCPD_CONFIG_FILE='"$(sysconfdir)/@PACKAGE@/@[email protected]"' \ | ||
| -DMPTCPD_DEFAULT_PLUGINDIR='"$(libdir)/@PACKAGE@"' | ||
| -DMPTCPD_DEFAULT_PLUGINDIR='"$(libdir)/@PACKAGE@"' \ | ||
| -DMPTCPD_DEFAULT_PLUGINSCONFDIR='"$(sysconfdir)/@PACKAGE@/$\ | ||
| plugins.conf.d/"' | ||
|
|
||
| EXTRA_DIST = mptcp.service.in | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.