From 2c96336702b1f08a2c6f997463a0aa48b0d8c0af Mon Sep 17 00:00:00 2001
From: Christian Poessinger <christian@poessinger.com>
Date: Sat, 11 Dec 2021 20:47:23 +0100
Subject: T3912: migrate "Welcome to VyOS" from issue file to motd to not
 silently expose OS

(cherry picked from commit 9ccc353893a3a9a1dc7dfd59463d34449bf05afb)
---
 src/conf_mode/system-login-banner.py | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

(limited to 'src')

diff --git a/src/conf_mode/system-login-banner.py b/src/conf_mode/system-login-banner.py
index 2220d7b66..9642b2aae 100755
--- a/src/conf_mode/system-login-banner.py
+++ b/src/conf_mode/system-login-banner.py
@@ -15,13 +15,16 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from sys import exit
+
 from vyos.config import Config
+from vyos.util import write_file
 from vyos import ConfigError
-
 from vyos import airbag
 airbag.enable()
 
 motd="""
+Welcome to VyOS
+
 Check out project news at https://blog.vyos.io
 and feel free to report bugs at https://phabricator.vyos.net
 
@@ -38,7 +41,7 @@ POSTLOGIN_FILE = r'/etc/motd'
 
 default_config_data = {
     'issue': 'Welcome to VyOS - \\n \\l\n\n',
-    'issue_net': 'Welcome to VyOS\n',
+    'issue_net': '',
     'motd': motd
 }
 
@@ -92,14 +95,9 @@ def generate(banner):
     pass
 
 def apply(banner):
-    with open(PRELOGIN_FILE, 'w') as f:
-        f.write(banner['issue'])
-
-    with open(PRELOGIN_NET_FILE, 'w') as f:
-        f.write(banner['issue_net'])
-
-    with open(POSTLOGIN_FILE, 'w') as f:
-        f.write(banner['motd'])
+    write_file(PRELOGIN_FILE, banner['issue'])
+    write_file(PRELOGIN_NET_FILE, banner['issue_net'])
+    write_file(POSTLOGIN_FILE, banner['motd'])
 
     return None
 
-- 
cgit v1.2.3