-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
require users to always enter their password when using sudo Signed-off-by: Alex Hearn <[email protected]>
- Loading branch information
1 parent
a444a10
commit a583b28
Showing
2 changed files
with
41 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import argparse | ||
import textwrap | ||
|
||
from nilrt_snac._configs._base_config import _BaseConfig | ||
from nilrt_snac._configs._config_file import _ConfigFile | ||
|
||
from nilrt_snac import logger | ||
|
||
|
||
class _SudoConfig(_BaseConfig): | ||
def __init__(self): | ||
pass # Nothing to do for now | ||
|
||
def configure(self, args: argparse.Namespace) -> None: | ||
print("Configuring sudo...") | ||
config_file = _ConfigFile("/etc/sudoers.d/snac") | ||
dry_run: bool = args.dry_run | ||
if not config_file.exists(): | ||
config_file.add( | ||
textwrap.dedent( | ||
""" | ||
# NILRT SNAC configuration sudoers. Do not hand-edit. | ||
Defaults timestamp_timeout=0 | ||
""" | ||
) | ||
) | ||
config_file.save(dry_run) | ||
|
||
def verify(self, args: argparse.Namespace) -> bool: | ||
print("Verifying sudo configuration...") | ||
config_file = _ConfigFile("/etc/sudoers.d/snac") | ||
valid = True | ||
if not config_file.exists(): | ||
valid = False | ||
logger.error(f"MISSING: {config_file.path} not found") | ||
if not config_file.contains("Defaults timestamp_timeout=0"): | ||
valid = False | ||
logger.error("MISSING: immediate timestamp_timeout") | ||
return valid |