diff options
Diffstat (limited to 'src/conf_mode/system-login-banner.py')
-rwxr-xr-x | src/conf_mode/system-login-banner.py | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/conf_mode/system-login-banner.py b/src/conf_mode/system-login-banner.py index e66d409bb..5a34a0b06 100755 --- a/src/conf_mode/system-login-banner.py +++ b/src/conf_mode/system-login-banner.py @@ -16,6 +16,7 @@ from sys import exit from vyos.config import Config +from vyos import ConfigError motd=""" The programs included with the Debian GNU/Linux system are free software; @@ -24,6 +25,7 @@ individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. + """ PRELOGIN_FILE = r'/etc/issue' @@ -31,8 +33,8 @@ PRELOGIN_NET_FILE = r'/etc/issue.net' POSTLOGIN_FILE = r'/etc/motd' default_config_data = { - 'issue': 'Welcome to VyOS - \n \l', - 'issue_net': 'Welcome to VyOS', + 'issue': 'Welcome to VyOS - \n \l\n', + 'issue_net': 'Welcome to VyOS\n', 'motd': motd } @@ -49,15 +51,29 @@ def get_config(): # Post-Login banner if conf.exists(['post-login']): tmp = conf.return_value(['post-login']) - tmp = tmp.replace('\\n','\n') - tmp = tmp.replace('\\t','\t') + # post-login banner can be empty as well + if tmp: + tmp = tmp.replace('\\n','\n') + tmp = tmp.replace('\\t','\t') + # always add newline character + tmp += '\n' + else: + tmp = '' + banner['motd'] = tmp # Pre-Login banner if conf.exists(['pre-login']): tmp = conf.return_value(['pre-login']) - tmp = tmp.replace('\\n','\n') - tmp = tmp.replace('\\t','\t') + # pre-login banner can be empty as well + if tmp: + tmp = tmp.replace('\\n','\n') + tmp = tmp.replace('\\t','\t') + # always add newline character + tmp += '\n' + else: + tmp = '' + banner['issue'] = banner['issue_net'] = tmp return banner |