From 54df0cbd531737fde9a957e94bd41bd17e4228bb Mon Sep 17 00:00:00 2001 From: Joe Cooper Date: Thu, 19 Jan 2017 17:06:43 -0800 Subject: [PATCH] Initial check-in. Doesn't work yet. --- config | 2 ++ config.info | 2 ++ help/index.html | 4 +++ index.cgi | 39 +++++++++++++++++++++++++++ install_check.pl | 14 ++++++++++ jailkit-lib.pl | 51 +++++++++++++++++++++++++++++++++++ lang/en | 8 ++++++ module.info | 5 ++++ save_jk_init.cgi | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 194 insertions(+) create mode 100644 config create mode 100644 config.info create mode 100644 help/index.html create mode 100644 index.cgi create mode 100644 install_check.pl create mode 100644 jailkit-lib.pl create mode 100644 lang/en create mode 100644 module.info create mode 100644 save_jk_init.cgi diff --git a/config b/config new file mode 100644 index 0000000..7aa7310 --- /dev/null +++ b/config @@ -0,0 +1,2 @@ +jailkit_config_dir=/etc/jailkit +jk_init_ini=/etc/jailkit/jk_init.ini diff --git a/config.info b/config.info new file mode 100644 index 0000000..e026554 --- /dev/null +++ b/config.info @@ -0,0 +1,2 @@ +jailkit_config_dir=Path to Jailkit configuration directory,0 +jk_init_ini=Path to the jk_init.ini configuration file,0 diff --git a/help/index.html b/help/index.html new file mode 100644 index 0000000..e4acc70 --- /dev/null +++ b/help/index.html @@ -0,0 +1,4 @@ +
Jailkit
+

+Jailkit is a set of utilities to limit user accounts to specific files using chroot() and or specific commands. Setting up a chroot shell, a shell limited to some specific command, or a daemon inside a chroot jail is a lot easier and can be automated using these utilities. +

diff --git a/index.cgi b/index.cgi new file mode 100644 index 0000000..eb5937f --- /dev/null +++ b/index.cgi @@ -0,0 +1,39 @@ +#!/usr/bin/perl + +use warnings; +use strict; + +our %text; + +require 'jailkit-lib.pl'; + +my $jk_init_ini = get_jk_init_ini(); + +ui_print_header(undef, $text{'index_title'}, "", "index", 1, 1, 0, + undef, undef, undef, undef); + +my @table; +foreach my $jail (keys %$jk_init_ini) { + push(@table, [ + { 'type' => 'checkbox', 'name' => 'd', + 'value' => $jail, + 'comment' => "$jk_init_ini->{$jail}{'comment'}" + } + ]); +} + +my @buttons; +push(@buttons, [ + [ "delete", $text{'jk_delete'} ] +]); + +my @actions; +push(@actions, [ + [ "create", $text{'jk_create'} ] +]); + +ui_form_columns_table('delete_jk_init.cgi', @buttons, 1, @actions, \@table); + +print ui_form_end([ [ "save", $text{'form_save'} ] ]); # save_config + +ui_print_footer("/", $text{'index'}); diff --git a/install_check.pl b/install_check.pl new file mode 100644 index 0000000..0fc77f8 --- /dev/null +++ b/install_check.pl @@ -0,0 +1,14 @@ +# install_check.pl + +do 'jailkit-lib.pl'; + +# is_installed(mode) +# For mode 1, returns 2 if the server is installed and configured for use by +# Webmin, 1 if installed but not configured, or 0 otherwise. +# For mode 0, returns 1 if installed, 0 if not +sub is_installed +{ +# Available config file in the default location? +#return 0 if (!-x $config{'jailkit_init_ini'}); +return 1; +} diff --git a/jailkit-lib.pl b/jailkit-lib.pl new file mode 100644 index 0000000..a67ba9b --- /dev/null +++ b/jailkit-lib.pl @@ -0,0 +1,51 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Error qw(:try); + +our %config; + +=head1 jailkit-lib.pl + +Functions for the Jailkit Webmin module + + foreign_require("jailkit", "jailkit-lib.pl"); + $jk_init_ini = jailkit::get_jk_init_ini(); + +$jk_init_ini will contain a list of hashrefs of configuration +directives from jk_init.ini. + +=cut + +BEGIN { push(@INC, ".."); }; +use WebminCore; +init_config(); + +=head2 get_jk_init_ini() + +Returns the jailkit configuration as a list of hash references with name and key value keys. + +=cut + +sub get_jk_init_ini { + use Config::INI::Reader; + + my $config = Config::INI::Reader->read_file($config{'jk_init_ini'}); + return $config; +} + +=head2 write_jk_init_config(\%jk_init_ini) + +Write configuration file array to config file. May return an error object, if write fails. + +=cut + +sub write_jk_init_ini { + use Config::INI::Writer; + my ($jk_init_ini) = @_; + Config::INI::Writer->write_file($jk_init_ini, $config{'jk_init_ini'}); + return; +} + +1; diff --git a/lang/en b/lang/en new file mode 100644 index 0000000..722cacd --- /dev/null +++ b/lang/en @@ -0,0 +1,8 @@ +index_title=Jailkit + +index_jails=Available Jails +index_create_jail=Create a new Jail configuration +index_delete_jail=Delete selected +index_initialize=Initialize Jail for user +index_edit_jail=Edit Jail +index_comment=Comment diff --git a/module.info b/module.info new file mode 100644 index 0000000..c645608 --- /dev/null +++ b/module.info @@ -0,0 +1,5 @@ +name=Jailkit +desc=Jailkit Jail Manager +os_support=*-linux +category=system +version=0.1 diff --git a/save_jk_init.cgi b/save_jk_init.cgi new file mode 100644 index 0000000..6d412e3 --- /dev/null +++ b/save_jk_init.cgi @@ -0,0 +1,69 @@ +#!/usr/bin/perl +# save_config.cgi +# Write updated settings.ini for bloctweet + +use warnings; +use strict; + +our %in; +our %text; + +require './jailkit-lib.pl'; + +my $jk_init_config = get_jk_init_config(); + +ReadParse(); + +#ui_print_header(undef, $text{'index_title'}, "". undef, 1, 1); + +# Keys +if (defined $in{'keys_access_token_secret'}) { + $bloctweet_config->{'keys'}{'access_token_secret'} = $in{'keys_access_token_secret'}; +} + +if (defined $in{'keys_access_token'}) { + $bloctweet_config->{'keys'}{'access_token'} = $in{'keys_access_token'}; +} + +if (defined $in{'keys_consumer_secret'}) { + $bloctweet_config->{'keys'}{'consumer_secret'} = $in{'keys_consumer_secret'}; +} + +if (defined $in{'keys_consumer_key'}) { + $bloctweet_config->{'keys'}{'consumer_key'} = $in{'keys_consumer_key'}; +} + +# Settings +if (defined $in{'settings_refresh_rate'}) { + $bloctweet_config->{'settings'}{'refresh_rate'} = $in{'settings_refresh_rate'}; +} + +if (defined $in{'settings_dm_refresh_rate'}) { + $bloctweet_config->{'settings'}{'dm_refresh_rate'} = $in{'settings_dm_refresh_rate'}; +} + +if (defined $in{'settings_search_hash'}) { + $bloctweet_config->{'settings'}{'search_hash'} = $in{'settings_search_hash'}; +} + +if (defined $in{'settings_hashtag_enabled'}) { + $bloctweet_config->{'settings'}{'hashtag_enabled'} = $in{'settings_search_hash'}; +} + +if (defined $in{'settings_dm_enabled'}) { + $bloctweet_config->{'settings'}{'dm_enabled'} = $in{'settings_dm_enabled'}; +} + +# Contributors +if (defined $in{'contributors'}) { + my @contributors = split(' ', $in{'contributors'}); + foreach my $contributor (@contributors) { + $bloctweet_config->{'contributors'}{$contributor} = '0'; + } +} + +#Config::INI::Writer->write_file($bloctweet_config, $config{'bloctweet_config'}); +write_bloctweet_config($bloctweet_config); + +redirect(""); +