Skip to content

Commit

Permalink
Merge pull request vyos#1561 from sever-sever/T4715
Browse files Browse the repository at this point in the history
login: T4715: Auto logout user after inactivity
  • Loading branch information
c-po committed Sep 28, 2022
2 parents d5e84fa + ee2dc73 commit 0af970a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions data/templates/login/autologout.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% if timeout is vyos_defined %}
TMOUT={{ timeout }}
readonly TMOUT
export TMOUT
{% endif %}
13 changes: 13 additions & 0 deletions interface-definitions/system-login.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,19 @@
#include <include/interface/vrf.xml.i>
</children>
</node>
<leafNode name="timeout">
<properties>
<help>Session timeout</help>
<valueHelp>
<format>u32:5-604800</format>
<description>Session timeout in seconds</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 5-604800"/>
</constraint>
<constraintErrorMessage>Timeout must be between 5 and 604800 seconds</constraintErrorMessage>
</properties>
</leafNode>
</children>
</node>
</children>
Expand Down
8 changes: 8 additions & 0 deletions src/conf_mode/system-login.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from vyos import airbag
airbag.enable()

autologout_file = "/etc/profile.d/autologout.sh"
radius_config_file = "/etc/pam_radius_auth.conf"

def get_local_users():
Expand Down Expand Up @@ -203,6 +204,13 @@ def generate(login):
if os.path.isfile(radius_config_file):
os.unlink(radius_config_file)

if 'timeout' in login:
render(autologout_file, 'login/autologout.j2', login,
permission=0o755, user='root', group='root')
else:
if os.path.isfile(autologout_file):
os.unlink(autologout_file)

return None


Expand Down

0 comments on commit 0af970a

Please sign in to comment.