-
Notifications
You must be signed in to change notification settings - Fork 2k
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
sys/shell: new module shell_lock #13082
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2284f87
sys/shell: add module shell_lock
HendrikVE ccc7951
sys/shell: add pseudomodule shell_lock_auto_locking
HendrikVE 2f91557
tests/shell_lock: add test
HendrikVE 7029572
sys/net/telnet: add telnet_server_disconnect()
benpicco d5d08e1
sys/shell_lock: add telnet support
benpicco 80b7b79
examples/telnet_server: fix build with shell_lock
benpicco 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 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,84 @@ | ||
/* | ||
* Copyright (C) 2020 Freie Universität Berlin | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @defgroup sys_shell_lock Shell lock | ||
* @ingroup sys | ||
* @brief Simple module to provide a password protection for the shell. | ||
* @experimental This module is an experimental feature and only shows as a proof of concept how | ||
* the shell could be protected with a password. Do not expect relevant security from | ||
* it for production, since Man-in-the-Middle attacks are possible depending on the | ||
* used connection method! | ||
* | ||
* @{ | ||
* | ||
* @file | ||
* @brief Shell interface definition | ||
*/ | ||
|
||
#ifndef SHELL_LOCK_H | ||
#define SHELL_LOCK_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include "shell.h" | ||
|
||
#ifdef MODULE_SHELL_LOCK | ||
#ifndef CONFIG_SHELL_LOCK_PASSWORD | ||
#error Using MODULE_SHELL_LOCK requires defining CONFIG_SHELL_LOCK_PASSWORD | ||
#endif /* CONFIG_SHELL_LOCK_PASSWORD */ | ||
#endif /* MODULE_SHELL_LOCK */ | ||
|
||
/** | ||
* @brief Lock the login process after given attempts of failed logins for | ||
* a few seconds | ||
*/ | ||
#define CONFIG_SHELL_LOCK_ATTEMPTS_BEFORE_TIME_LOCK 3 | ||
|
||
#ifndef CONFIG_SHELL_LOCK_AUTO_LOCK_TIMEOUT_MS | ||
/** | ||
* @brief Lock the shell after this time span without user input | ||
* Defaults to 5 minutes but can be overwritten in the applications | ||
* Makefile. | ||
*/ | ||
#define CONFIG_SHELL_LOCK_AUTO_LOCK_TIMEOUT_MS (5 * 60 * 1000) | ||
#endif | ||
|
||
/** | ||
* @brief Entry point for the lock mechanism. If locked, the user will | ||
* be asked for a password. This function won't return until the | ||
* correct password has been entered. | ||
* | ||
* @param[in] line_buf Buffer for reading in the password from stdin | ||
* @param[in] buf_size Buffer size | ||
*/ | ||
void shell_lock_checkpoint(char *line_buf, int buf_size); | ||
|
||
/** | ||
* @brief Returns true, if the shell is in the locked state. | ||
* | ||
* @return Whether the shell is locked or not. | ||
*/ | ||
bool shell_lock_is_locked(void); | ||
|
||
#ifdef MODULE_SHELL_LOCK_AUTO_LOCKING | ||
/** | ||
* @brief Restart the timeout interval before the shell is locked | ||
* automatically. | ||
*/ | ||
void shell_lock_auto_lock_refresh(void); | ||
#endif /* MODULE_SHELL_LOCK_AUTO_LOCKING */ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* SHELL_LOCK_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include $(RIOTBASE)/Makefile.base |
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,4 @@ | ||
$(shell $(COLOR_ECHO) "$(COLOR_YELLOW)shell_lock is an experimental feature and only shows as a \ | ||
proof of concept how the shell could be protected with a password. Do not expect relevant \ | ||
security from it for production, since Man-in-the-Middle attacks are possible depending on the \ | ||
used connection method!$(COLOR_RESET)" 1>&2) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are doing that you might as well
and avoid cluttering the code further down with
if (IS_USED(…))
blocksThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mh I don't see the benefit of doing this. At the moment it is in line with
MODULE_SHELL_HOOKS
andMODULE_SHELL_COMMANDS
. Since these are just forward declarations we don't need empty definitions in case the module is not used at all.