From ebb05288b2846466ff26ea1076c4e9ea6fbe98b9 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 11 Feb 2011 19:15:44 +0100 Subject: Add makefile, fix filename --- Makefile | 18 ++++++++++++++++++ lib/forcecommand | 37 ------------------------------------- lib/ssh-forcecommand | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 37 deletions(-) create mode 100644 Makefile delete mode 100755 lib/forcecommand create mode 100755 lib/ssh-forcecommand diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..86f9f45 --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +PREFIX ?= /usr/local + +main_dir = ${DESTDIR}${PREFIX} +lib_dir = ${main_dir}/lib + +all: + @echo "There is nothing to make, you can just make install" + +install: + @echo installing lib/ssh-forcecommand to ${lib_dir} + @mkdir -p ${lib_dir} + @cp lib/ssh-forcecommand ${lib_dir} + @chmod 755 ${lib_dir}/ssh-forcecommand + +uninstall: + rm -f ${lib_dir}/ssh-forcecommand + +.PHONY: all install uninstall diff --git a/lib/forcecommand b/lib/forcecommand deleted file mode 100755 index 16e04c5..0000000 --- a/lib/forcecommand +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env perl -# Copyright © 2010 by Daniel Friesel -# License: WTFPL: -# 0. You just DO WHAT THE FUCK YOU WANT TO. -# -# SSH forcecommand to be used for nagios ssh checks etc. -# Example line for ssh authorized_keys file: -# command="/usr/local/lib/nagios/forcecommand /etc/nagios/forcecommand.cfg",no-agent-forwarding,no-port-forwarding,no-pty,no-X11-forwarding $key -# -# Configfile format: -# ssh_command = real_command -# Example: -# check_users = /usr/lib/nagios/plugins/check_users -w 5 -c 10 - -use strict; -use warnings; - -my $conffile = shift or die("Usage: $0 \n"); -my %commands; -my $input = $ENV{'SSH_ORIGINAL_COMMAND'} or die("No command\n");; - -open(my $conf, '<', $conffile) or die("Can't open $conffile: $!\n"); - -while (my $line = <$conf>) { - my ($key, $value) = split(/ \s* = \s* /x, $line); - if ($key and $value) { - $commands{$key} = $value; - } -} -close($conf) or die("Cannot close $conffile: $!\n"); - -if (exists $commands{$input}) { - exec($commands{$input}); - exit 1; -} - -die("Unknown command\n"); diff --git a/lib/ssh-forcecommand b/lib/ssh-forcecommand new file mode 100755 index 0000000..16e04c5 --- /dev/null +++ b/lib/ssh-forcecommand @@ -0,0 +1,37 @@ +#!/usr/bin/env perl +# Copyright © 2010 by Daniel Friesel +# License: WTFPL: +# 0. You just DO WHAT THE FUCK YOU WANT TO. +# +# SSH forcecommand to be used for nagios ssh checks etc. +# Example line for ssh authorized_keys file: +# command="/usr/local/lib/nagios/forcecommand /etc/nagios/forcecommand.cfg",no-agent-forwarding,no-port-forwarding,no-pty,no-X11-forwarding $key +# +# Configfile format: +# ssh_command = real_command +# Example: +# check_users = /usr/lib/nagios/plugins/check_users -w 5 -c 10 + +use strict; +use warnings; + +my $conffile = shift or die("Usage: $0 \n"); +my %commands; +my $input = $ENV{'SSH_ORIGINAL_COMMAND'} or die("No command\n");; + +open(my $conf, '<', $conffile) or die("Can't open $conffile: $!\n"); + +while (my $line = <$conf>) { + my ($key, $value) = split(/ \s* = \s* /x, $line); + if ($key and $value) { + $commands{$key} = $value; + } +} +close($conf) or die("Cannot close $conffile: $!\n"); + +if (exists $commands{$input}) { + exec($commands{$input}); + exit 1; +} + +die("Unknown command\n"); -- cgit v1.2.3