summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-02-10 18:04:50 +0100
committerChristian Poessinger <christian@poessinger.com>2020-02-10 18:04:50 +0100
commit4ce00b51405688e42d9b3364ac814446cb4e01f6 (patch)
tree1dc633e3f4af5c4eb6b7b9cb5f3639bae53e22eb
parenta268c8e6ae7ea17c6178c1e7b857e4dc477d5e30 (diff)
downloadvyatta-cfg-system-4ce00b51405688e42d9b3364ac814446cb4e01f6.tar.gz
vyatta-cfg-system-4ce00b51405688e42d9b3364ac814446cb4e01f6.zip
banner: T2024: migrate "system login banner" to XML/Python representation
-rw-r--r--Makefile.am1
-rwxr-xr-xscripts/rl-system.init12
-rwxr-xr-xscripts/vyatta-banner.pl151
-rw-r--r--templates/system/login/banner/node.def1
-rw-r--r--templates/system/login/banner/post-login/node.def10
-rw-r--r--templates/system/login/banner/pre-login/node.def11
6 files changed, 2 insertions, 184 deletions
diff --git a/Makefile.am b/Makefile.am
index 55b6b2da..82f6e613 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -49,7 +49,6 @@ sbin_SCRIPTS += scripts/vyatta-interfaces.pl
sbin_SCRIPTS += scripts/vyatta-address
sbin_SCRIPTS += scripts/vyatta-tunnel-cleanup
sbin_SCRIPTS += scripts/vyatta-raid-event
-sbin_SCRIPTS += scripts/vyatta-banner.pl
sbin_SCRIPTS += scripts/vyatta-load-user-key.pl
sbin_SCRIPTS += scripts/install/install-get-partition
sbin_SCRIPTS += scripts/install/install-functions
diff --git a/scripts/rl-system.init b/scripts/rl-system.init
index a6d8d27a..c183aeeb 100755
--- a/scripts/rl-system.init
+++ b/scripts/rl-system.init
@@ -189,22 +189,14 @@ start () {
update_version_info
- # Clear out login banner changes
- for f in /etc/issue /etc/issue.net /etc/motd
- do
- if [ -f $f.old ]
- then mv $f.old $f
- fi
- done
-
# Remove links from the post-commit hooks directory.
# note that this approach only supports hooks that are "configured",
# i.e., it does not support hooks that need to always be present.
cpostdir=$(cli-shell-api getPostCommitHookDir)
-
+
# exclude commits hooks from vyatta-cfg
excluded="10vyatta-log-commit.pl 99vyos-user-postcommit-hooks"
-
+
if [ -d "$cpostdir" ]; then
for f in $cpostdir/*
do
diff --git a/scripts/vyatta-banner.pl b/scripts/vyatta-banner.pl
deleted file mode 100755
index 9f7c5ddb..00000000
--- a/scripts/vyatta-banner.pl
+++ /dev/null
@@ -1,151 +0,0 @@
-#!/usr/bin/perl
-#
-# **** License ****
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# A copy of the GNU General Public License is available as
-# `/usr/share/common-licenses/GPL' in the Debian GNU/Linux distribution
-# or on the World Wide Web at `http://www.gnu.org/copyleft/gpl.html'.
-# You can also obtain it by writing to the Free Software Foundation,
-# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
-# MA 02110-1301, USA.
-#
-# This code was originally developed by Vyatta, Inc.
-# Portions created by Vyatta are Copyright (C) 2009 Vyatta, Inc.
-# All Rights Reserved.
-#
-# Author: Stig Thormodsrud
-# Date: April 2009
-# Description: Script to setup login banner
-#
-# **** End License ****
-#
-
-use lib '/opt/vyatta/share/perl5/';
-use Vyatta::Config;
-
-use Getopt::Long;
-use File::Copy;
-use File::Compare;
-use strict;
-use warnings;
-
-my $prelogin_file = '/etc/issue';
-my $prelogin_net_file = '/etc/issue.net';
-my $postlogin_file = '/etc/motd';
-
-
-sub save_orig_file {
- my $file = shift;
-
- move($file, "$file.old") if ! -e "$file.old";
- return;
-}
-
-sub restore_orig_file {
- my $file = shift;
-
- move("$file.old", $file)if -e "$file.old";
- return;
-}
-
-sub is_same_as_file {
- my ($file, $value) = @_;
-
- return if ! -e $file;
-
- my $mem_file = ' ';
- open my $MF, '+<', \$mem_file or die "couldn't open memfile $!\n";
- print $MF $value;
- seek($MF, 0, 0);
-
- my $rc = compare($file, $MF);
- return 1 if $rc == 0;
- return;
-}
-
-sub write_file_value {
- my ($file, $value) = @_;
-
- # Avoid unnecessary writes. At boot the file will be the
- # regenerated with the same content.
- return if is_same_as_file($file, $value);
-
- open my $F, '>', $file or die "Error: opening $file [$!]";
- print $F "$value";
- close $F;
-}
-
-sub get_banner {
- my $banner_type = shift;
-
- my $config = new Vyatta::Config;
- $config->setLevel('system login banner');
- my $text = $config->returnValue($banner_type);
- $text =~ s|\\n|\n|g;
- $text =~ s|\\t|\t|g;
- return $text;
-}
-
-sub add_prelogin {
- save_orig_file($prelogin_file);
- save_orig_file($prelogin_net_file);
- my $text = get_banner('pre-login');
- write_file_value($prelogin_file, $text);
- write_file_value($prelogin_net_file, $text);
- return;
-}
-
-sub add_postlogin {
- save_orig_file($postlogin_file);
- my $text = get_banner('post-login');
- write_file_value($postlogin_file, $text);
- return;
-}
-
-
-#
-# main
-#
-my ($action, $banner_type);
-
-GetOptions("action=s" => \$action,
- "banner-type=s" => \$banner_type,
-);
-
-die "Error: no action" if ! defined $action;
-die "Error: no banner-type" if ! defined $banner_type;
-
-if ($action eq 'update') {
- if ($banner_type eq 'pre-login') {
- add_prelogin();
- exit 0;
- }
- if ($banner_type eq 'post-login') {
- add_postlogin();
- exit 0;
- }
-}
-
-if ($action eq 'delete') {
- if ($banner_type eq 'pre-login') {
- restore_orig_file($prelogin_file);
- restore_orig_file($prelogin_net_file);
- exit 0;
- }
- if ($banner_type eq 'post-login') {
- restore_orig_file($postlogin_file);
- exit 0;
- }
-}
-
-exit 1;
-
-#end of file
diff --git a/templates/system/login/banner/node.def b/templates/system/login/banner/node.def
deleted file mode 100644
index f6857109..00000000
--- a/templates/system/login/banner/node.def
+++ /dev/null
@@ -1 +0,0 @@
-help: System login banners
diff --git a/templates/system/login/banner/post-login/node.def b/templates/system/login/banner/post-login/node.def
deleted file mode 100644
index 36db657d..00000000
--- a/templates/system/login/banner/post-login/node.def
+++ /dev/null
@@ -1,10 +0,0 @@
-help: System loging banner post-login
-type: txt
-
-update: sudo /opt/vyatta/sbin/vyatta-banner.pl \
- --action=update --banner-type=post-login
-
-delete: sudo /opt/vyatta/sbin/vyatta-banner.pl \
- --action=delete --banner-type=post-login
-
-comp_help: Example: "\\n\\n\\tWelcome to VyOS!\\n"
diff --git a/templates/system/login/banner/pre-login/node.def b/templates/system/login/banner/pre-login/node.def
deleted file mode 100644
index eda6bdc5..00000000
--- a/templates/system/login/banner/pre-login/node.def
+++ /dev/null
@@ -1,11 +0,0 @@
-help: System loging banner pre-login
-type: txt
-
-update: sudo /opt/vyatta/sbin/vyatta-banner.pl \
- --action=update --banner-type=pre-login
-
-delete: sudo /opt/vyatta/sbin/vyatta-banner.pl \
- --action=delete --banner-type=pre-login
-
-comp_help: Example: "\\n\\n\\tUNAUTHORIZED USE OF THIS SYSTEM\\nIS PROHIBITED!\\n"
-