security: Allow console login access to user plinth

Fixes #1295

This change is necessary to support sudo 1.8.23+ which came with the following
major change:
- PAM account management modules and BSD auth approval modules are now run even
	when no password is required.

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati authored and James Valleroy committed 2018-05-07 12:14:04 -04:00
1 parent 0c334b7231
commit b9c36e41e2
2 files changed
+21 -17

No files matched your search

+15 -8
View File
@@ -21,8 +21,8 @@ Helper for security configuration
import argparse
ACCESS_CONF_FILE = '/etc/security/access.conf'
ACCESS_CONF_SNIPPET = '-:ALL EXCEPT root fbx (admin) (sudo):ALL'
from plinth.modules.security import (ACCESS_CONF_FILE, ACCESS_CONF_SNIPPET,
ACCESS_CONF_SNIPPETS)
def parse_arguments():
@@ -46,12 +46,19 @@ def subcommand_enable_restricted_access(_):
with open(ACCESS_CONF_FILE, 'r') as conffile:
lines = conffile.readlines()
for line in lines:
if ACCESS_CONF_SNIPPET == line.strip():
return
is_upgrading = False
with open(ACCESS_CONF_FILE, 'a') as conffile:
conffile.write(ACCESS_CONF_SNIPPET + '\n')
with open(ACCESS_CONF_FILE, 'w') as conffile:
for line in lines:
if line.strip() in ACCESS_CONF_SNIPPETS:
conffile.write(ACCESS_CONF_SNIPPET + '\n')
is_upgrading = True
else:
conffile.write(line)
if not is_upgrading:
with open(ACCESS_CONF_FILE, 'a') as conffile:
conffile.write(ACCESS_CONF_SNIPPET + '\n')
def subcommand_disable_restricted_access(_):
@@ -61,7 +68,7 @@ def subcommand_disable_restricted_access(_):
with open(ACCESS_CONF_FILE, 'w') as conffile:
for line in lines:
if ACCESS_CONF_SNIPPET != line.strip():
if line.strip() not in ACCESS_CONF_SNIPPETS:
conffile.write(line)