diff options
author | Dmytro Aleksandrov <alkersan@gmail.com> | 2019-08-14 01:20:42 +0300 |
---|---|---|
committer | Dmytro Aleksandrov <alkersan@gmail.com> | 2019-08-16 18:39:48 +0300 |
commit | d77874da2cee5824996061cf52f432fec29a6aa7 (patch) | |
tree | 5a81164102459712aadd0855fa3c5cb8f1585b50 /scripts | |
parent | 69c24c0ec2299cbe07d5f0ce0351f47286d5b095 (diff) | |
download | vyatta-op-d77874da2cee5824996061cf52f432fec29a6aa7.tar.gz vyatta-op-d77874da2cee5824996061cf52f432fec29a6aa7.zip |
T1590 remove 'show system' operations after xml-style rewrite
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/show-users.pl | 129 | ||||
-rwxr-xr-x | scripts/vyatta-sudo | 21 | ||||
-rw-r--r-- | scripts/vyos-show-ram.sh | 34 |
3 files changed, 0 insertions, 184 deletions
diff --git a/scripts/show-users.pl b/scripts/show-users.pl deleted file mode 100755 index 321fbcb..0000000 --- a/scripts/show-users.pl +++ /dev/null @@ -1,129 +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. -# -# This code was originally developed by Vyatta, Inc. -# Portions created by Vyatta are Copyright (C) 2007 Vyatta, Inc. -# All Rights Reserved. -# -# Author: Stephen Hemminger -# Date: Sept 2009 -# Description: Show password accounts -# -# **** End License **** - -use lib "/opt/vyatta/share/perl5"; -use Vyatta::Config; -use IO::Seekable; - -use strict; -use warnings; - -sub usage { - print "Usage: $0 {type}\n"; - print " type := all | vyatta | locked | other | color\n"; - exit 1; -} - -use constant { - VYATTA => 0x1, - OTHER => 0x2, - LOCKED => 0x4, -}; - -my %filters = ( - 'vyatta' => VYATTA, - 'other' => OTHER, - 'locked' => OTHER|LOCKED, - 'all' => VYATTA|OTHER|LOCKED, -); - -my $filter = 0; -for (@ARGV) { - my $mask = $filters{$_}; - unless ($mask) { - warn "Unknown type $_\n"; - usage(); - } - $filter |= $mask; -} -# Default is everything but locked accounts -$filter |= VYATTA|OTHER if ($filter == 0); - -# Read list of Vyatta users -my $cfg = new Vyatta::Config; -$cfg->setLevel('system login user'); -my %vuser = map { $_ => 1 } $cfg->listOrigNodes(); - -# Setup to access lastlog -open (my $lastlog, '<', "/var/log/lastlog") - or die "can't open /var/log/lastlog:$!"; -# Magic values based on binary format of last log -# See /usr/include/bits/utm.h -my $typedef = 'L Z32 Z256'; -my $reclen = length(pack($typedef)); - -sub lastlog { - my $uid = shift; - - sysseek($lastlog, $uid * $reclen, SEEK_SET) - or die "seek failed: $!"; - - my ($rec, $line, $host, $time); - if (sysread($lastlog, $rec, $reclen) == $reclen) { - my ($time, $line, $host) = unpack($typedef, $rec); - return scalar(localtime($time)), $line, $host - if ($time != 0); - } - - return ("never logged in", "", ""); -} - - -# Walk password file -# Note: this only works as root -my %users; -setpwent(); -while ( my ($u, $p, $uid) = getpwent()) { - my $l = length($p); - my $status; - my $flag = 0; - - my $type = defined($vuser{$u}) ? 'vyatta' : 'other'; - if ($type eq 'vyatta') { - $flag |= VYATTA; - } elsif ($l != 1) { - $flag |= OTHER; - } - - # only works as root, otherwise shadow file is inaccessible - if ($l == 0) { - $type .= '!'; - } if ($l == 1) { - $flag |= LOCKED; - $type .= '-'; - } - - next if (($flag & $filter) == 0); - - my ($time, $line, $host) = lastlog($uid); - # fields to printf - $users{$u} = [ $type, $line, $host, $time ]; -} -endpwent(); -close $lastlog; - -my $fmt = "%-15s %-7s %-8s %-19s %s\n"; -printf $fmt, "Username","Type","Tty", "From","Last login"; - -foreach my $u (sort keys %users) { - printf $fmt, $u, @{$users{$u}}; -} diff --git a/scripts/vyatta-sudo b/scripts/vyatta-sudo deleted file mode 100755 index bb95ae5..0000000 --- a/scripts/vyatta-sudo +++ /dev/null @@ -1,21 +0,0 @@ -#! /usr/bin/perl -# - -# Look if user is in sudo group -use strict; -use warnings; - -sub isadmin { - my $gid = getgrnam("sudo"); - return unless $gid; - - # is $gid in list of current groups - return grep { $_ eq $gid } split / /, $(; -} - -die "Missing command arguement\n" unless @ARGV; - -exec ('sudo', @ARGV ) if (isadmin()); - -print "This account is not authorized to run this command\n"; -exit 1; diff --git a/scripts/vyos-show-ram.sh b/scripts/vyos-show-ram.sh deleted file mode 100644 index 11ead79..0000000 --- a/scripts/vyos-show-ram.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# -# Module: vyos-show-ram.sh -# Displays memory usage information in minimalistic format -# -# Copyright (C) 2013 SO3Group -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -MB_DIVISOR=1024 - -TOTAL=$(cat /proc/meminfo | grep -E "^MemTotal:" | awk -F ' ' '{print $2}') -FREE=$(cat /proc/meminfo | grep -E "^MemFree:" | awk -F ' ' '{print $2}') -BUFFERS=$(cat /proc/meminfo | grep -E "^Buffers:" | awk -F ' ' '{print $2}') -CACHED=$(cat /proc/meminfo | grep -E "^Cached:" | awk -F ' ' '{print $2}') - -DISPLAY_FREE=$(( ($FREE + $BUFFERS + $CACHED) / $MB_DIVISOR )) -DISPLAY_TOTAL=$(( $TOTAL / $MB_DIVISOR )) -DISPLAY_USED=$(( $DISPLAY_TOTAL - $DISPLAY_FREE )) - -echo "Total: $DISPLAY_TOTAL" -echo "Free: $DISPLAY_FREE" -echo "Used: $DISPLAY_USED" - |