Skip to content

Commit

Permalink
Initial check-in. Doesn't work yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
swelljoe committed Jan 20, 2017
1 parent cd2fe8a commit 54df0cb
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jailkit_config_dir=/etc/jailkit
jk_init_ini=/etc/jailkit/jk_init.ini
2 changes: 2 additions & 0 deletions config.info
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions help/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<header>Jailkit</header>
<p>
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.
</p>
39 changes: 39 additions & 0 deletions index.cgi
Original file line number Diff line number Diff line change
@@ -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'});
14 changes: 14 additions & 0 deletions install_check.pl
Original file line number Diff line number Diff line change
@@ -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;
}
51 changes: 51 additions & 0 deletions jailkit-lib.pl
Original file line number Diff line number Diff line change
@@ -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;
8 changes: 8 additions & 0 deletions lang/en
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions module.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name=Jailkit
desc=Jailkit Jail Manager
os_support=*-linux
category=system
version=0.1
69 changes: 69 additions & 0 deletions save_jk_init.cgi
Original file line number Diff line number Diff line change
@@ -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("");

0 comments on commit 54df0cb

Please sign in to comment.