Skip to content

Commit

Permalink
Fix perms
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Jun 27, 2020
2 parents fb0b2a5 + c699822 commit fdc1472
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 110 deletions.
13 changes: 13 additions & 0 deletions .perltidyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-pbp # Start with Perl Best Practices
-nst # Non-standard output (allow operate in-place)
-w # Show all warnings
-iob # Ignore old breakpoints
-l=80 # 80 characters per line
-mbl=2 # No more than 2 blank lines
-i=2 # Indentation is 2 columns
-ci=2 # Continuation indentation is 2 columns
-vt=0 # Less vertical tightness
-pt=2 # High parenthesis tightness
-bt=2 # High brace tightness
-sbt=2 # High square bracket tightness
-isbc # Don't indent comments without leading space
8 changes: 5 additions & 3 deletions delete_jail.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require './jailkit-lib.pl';
ReadParse();

my $jk_init_ini = get_jk_init_ini();
my @sections = $jk_init_ini->Sections();
my @sections = $jk_init_ini->Sections();
my %jail_params;

my @d = split(/\0/, $in{'d'});
Expand All @@ -20,7 +20,7 @@ if (defined $in{'confirmed'}) {
}
else {
# Does this jail exist?
error( text('error_jail_not_found', "$jail", "<br>\n"));
error(text('error_jail_not_found', "$jail", "<br>\n"));
}
}
write_jk_init_ini($jk_init_ini);
Expand All @@ -33,6 +33,7 @@ else {
# Check to be sure we really want these jails gone
print ui_form_start("delete_jail.cgi", "post");
foreach my $jail (@d) {

# Re-send all of the d_* items with a confirmed field
print ui_hidden("d", $jail);
}
Expand All @@ -45,8 +46,9 @@ else {
print "</p>\n";

print ui_hidden("confirmed", "1");

#print ui_submit($text{delete_confirm}, "confirm");
print ui_form_end([ [ "confirm", $text{'delete_confirm'} ] ]);
print ui_form_end([["confirm", $text{'delete_confirm'}]]);
print "</center>\n";
ui_print_footer("");
}
Expand Down
95 changes: 62 additions & 33 deletions edit_jail.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -7,66 +7,95 @@ require './jailkit-lib.pl';
ReadParse();

my $jk_init_ini = get_jk_init_ini();
my @sections = $jk_init_ini->Sections();
my @sections = $jk_init_ini->Sections();
my %jail_params;

# Make a new section?
if($in{'new'}) {
if ($in{'new'}) {
ui_print_header(undef, $text{'index_create_jail'}, '', 'create_jail');

# Keep new defined so we add a new section on save
print ui_hidden("new", $in{'new'});
}
else {
ui_print_header(undef, $text{'index_edit_jail'}, '', 'edit_jail');
unless ( $jk_init_ini->SectionExists( $in{'jail'} )) {
error( $text{'edit_jail_not_found'} );
};
unless ($jk_init_ini->SectionExists($in{'jail'})) {
error($text{'edit_jail_not_found'});
}

# Populate the jail hash
my @params = $jk_init_ini->Parameters( $in{'jail'} );
foreach my $param (@params){
$jail_params{$param} = $jk_init_ini->val( $in{'jail'}, $param );
my @params = $jk_init_ini->Parameters($in{'jail'});
foreach my $param (@params) {
$jail_params{$param} = $jk_init_ini->val($in{'jail'}, $param);
}
}

print ui_form_start("save_jail.cgi");
print ui_hidden("orig_jail", $in{'jail'});

print ui_
print ui_hidden_table_start($text{'edit_jail_metadata'}, undef, 1, 'metadata', 1);
print ui_hidden_table_start($text{'edit_jail_metadata'}, undef, 1,
'metadata', 1);

# name
print ui_table_row( hlink($text{'edit_jail_name'}, 'name'),
print ui_table_row(hlink($text{'edit_jail_name'}, 'name'),
ui_textbox('jail', $in{'jail'}));

# comment/description
print ui_table_row( hlink($text{'edit_jail_comment'}, 'comment'),
ui_textbox('comment', $jail_params{'comment'}));
print ui_table_row(
hlink($text{'edit_jail_comment'}, 'comment'),
ui_textbox('comment', $jail_params{'comment'})
);
print ui_hidden_table_end('metadata');

print ui_hidden_table_start($text{'edit_jail_includes'}, undef, 1, 'includes', 1);
print ui_hidden_table_start($text{'edit_jail_includes'}, undef, 1, 'includes',
1);

# paths
print ui_table_row( hlink($text{'edit_jail_paths'}, 'paths'),
ui_textarea('paths', $jail_params{'paths'}));
print ui_table_row( hlink($text{'edit_jail_paths_w_owner'}, 'paths_w_owner'),
ui_textarea('paths_w_owner', $jail_params{'paths_w_owner'}));
print ui_table_row( hlink($text{'edit_jail_paths_w_setuid'}, 'paths_w_setuid'),
ui_textarea('paths_w_setuid', $jail_params{'paths_w_setuid'}));
print ui_table_row( hlink($text{'edit_jail_includesections'}, 'includesections'),
ui_textarea('includesections'), $jail_params{'includesections'});
print ui_table_row( hlink($text{'edit_jail_emptydirs'}, 'emptydirs'),
ui_textarea('emptydirs', $jail_params{'emptydirs'}));
print ui_table_row( hlink($text{'edit_jail_devices'}, 'devices'),
ui_textbox('devices', $jail_params{'devices'}));
print ui_table_row( hlink($text{'edit_jail_need_logsocket'}, 'need_logsocket'),
ui_checkbox('need_logsocket', 1,
undef, $jail_params{'need_logsocket'} ? 1 : 0));
print ui_table_row(
hlink($text{'edit_jail_paths'}, 'paths'),
ui_textarea('paths', $jail_params{'paths'})
);
print ui_table_row(
hlink($text{'edit_jail_paths_w_owner'}, 'paths_w_owner'),
ui_textarea('paths_w_owner', $jail_params{'paths_w_owner'})
);
print ui_table_row(
hlink($text{'edit_jail_paths_w_setuid'}, 'paths_w_setuid'),
ui_textarea('paths_w_setuid', $jail_params{'paths_w_setuid'})
);
print ui_table_row(
hlink($text{'edit_jail_includesections'}, 'includesections'),
ui_textarea('includesections'),
$jail_params{'includesections'}
);
print ui_table_row(
hlink($text{'edit_jail_emptydirs'}, 'emptydirs'),
ui_textarea('emptydirs', $jail_params{'emptydirs'})
);
print ui_table_row(
hlink($text{'edit_jail_devices'}, 'devices'),
ui_textbox('devices', $jail_params{'devices'})
);
print ui_table_row(
hlink($text{'edit_jail_need_logsocket'}, 'need_logsocket'),
ui_checkbox(
'need_logsocket', 1, undef, $jail_params{'need_logsocket'} ? 1 : 0
)
);
print ui_hidden_table_end('includes');

print ui_hidden_table_start($text{'edit_jail_ug'}, undef, 1, 'usergroups', 1);
print ui_table_row( hlink($text{'edit_jail_users'}, 'users'),
ui_textarea('users', $jail_params{'users'}));
print ui_table_row( hlink($text{'edit_jail_groups'}, 'groups'),
ui_textarea('groups', $jail_params{'groups'}));
print ui_table_row(
hlink($text{'edit_jail_users'}, 'users'),
ui_textarea('users', $jail_params{'users'})
);
print ui_table_row(
hlink($text{'edit_jail_groups'}, 'groups'),
ui_textarea('groups', $jail_params{'groups'})
);
print ui_hidden_table_end('usergroups');

print ui_form_end([ [undef, $text{'save_jail'}] ]);
print ui_form_end([[undef, $text{'save_jail'}]]);

&ui_print_footer("index.cgi", $text{'edit_jail_return'});
40 changes: 15 additions & 25 deletions index.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,34 @@ my $jk_init_ini = get_jk_init_ini();

my @sections = $jk_init_ini->Sections();

ui_print_header(undef, $text{'index_title'}, "", "index", 1, 1, 0,
undef, undef, undef, undef);
ui_print_header(undef, $text{'index_title'}, "", "index", 1, 1, 0, undef,
undef, undef, undef);

my @table;
foreach my $jail (@sections) {
push(@table, [
{ 'type' => 'checkbox', 'name' => 'd', 'value' => $jail },
"<a href=\"edit_jail.cgi?jail=$jail\">".&html_escape($jail)."</a>",
$jk_init_ini->val("$jail", 'comment')
]);
push(
@table,
[
{'type' => 'checkbox', 'name' => 'd', 'value' => $jail},
"<a href=\"edit_jail.cgi?jail=$jail\">" . &html_escape($jail) . "</a>",
$jk_init_ini->val("$jail", 'comment')
]
);
}

my @buttons;
push(@buttons, [
[ "delete", $text{'index_delete_jail'} ]
]);
push(@buttons, [["delete", $text{'index_delete_jail'}]]);

my @actions;
push(@actions, [
[ "edit_jail.cgi?new=1", $text{'index_create_jail'} ]
]);
push(@actions, [["edit_jail.cgi?new=1", $text{'index_create_jail'}]]);

#use Data::Dumper;
#print "<!-- " . Dumper(@table) . " -->\n";

print ui_form_columns_table(
'delete_jail.cgi',
@buttons,
1,
@actions,
undef,
[ $text{'index_delete'}, $text{'index_jail_id'}, $text{'index_comment'} ],
undef,
\@table,
undef,
1,
$text{'index_jail_list'},
$text{'index_no_jails'}
'delete_jail.cgi', @buttons, 1, @actions, undef,
[$text{'index_delete'}, $text{'index_jail_id'}, $text{'index_comment'}],
undef, \@table, undef, 1, $text{'index_jail_list'}, $text{'index_no_jails'}
);

ui_print_footer("");
13 changes: 8 additions & 5 deletions install_check.pl
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# install_check.pl
use strict;
use warnings;

our %config;
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
{
my ($mode) = @_;
sub is_installed {
my ($mode) = @_;

# Available config file in the default location?
return 0 if (!-r $config{'jailkit_init_ini'});
return $mode ? 2 : 0;
return 0 if (!-r $config{'jailkit_init_ini'});
return $mode ? 2 : 0;
}
24 changes: 12 additions & 12 deletions jailkit-lib.pl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/perl

use strict;
use warnings;

Expand All @@ -17,7 +16,7 @@ =head1 jailkit-lib.pl
=cut

BEGIN { push(@INC, ".."); };
BEGIN { push(@INC, ".."); }
use WebminCore;
init_config();

Expand All @@ -28,10 +27,11 @@ =head2 get_jk_init_ini()
=cut

sub get_jk_init_ini {
use Config::IniFiles;
use Config::IniFiles;

my $jk_init_ini = new Config::IniFiles( -file=>"$config{'jailkit_config_dir'}/jk_init.ini" );
return $jk_init_ini;
my $jk_init_ini = new Config::IniFiles(
-file => "$config{'jailkit_config_dir'}/jk_init.ini");
return $jk_init_ini;
}

=head2 write_jk_init_ini(\%jk_init_ini)
Expand All @@ -41,13 +41,13 @@ =head2 write_jk_init_ini(\%jk_init_ini)
=cut

sub write_jk_init_ini {
use Config::IniFiles;
my ($jk_init_ini) = @_;
my $result = $jk_init_ini->RewriteConfig($config{'jk_init_ini'});
unless ($result) {
error($text{'error_save_failed'});
}
return;
use Config::IniFiles;
my ($jk_init_ini) = @_;
my $result = $jk_init_ini->RewriteConfig($config{'jk_init_ini'});
unless ($result) {
error($text{'error_save_failed'});
}
return;
}

1;
Loading

0 comments on commit fdc1472

Please sign in to comment.