-
Notifications
You must be signed in to change notification settings - Fork 0
/
bastille-manager-lib.pl
executable file
·660 lines (595 loc) · 17.9 KB
/
bastille-manager-lib.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
#!/usr/local/bin/perl
# bastille-manager-lib.pl
BEGIN { push(@INC, ".."); };
use WebminCore;
use File::Path qw/mkpath/;
&init_config();
# Default bastille jail list props.
# JID, IP Address, Hostname, Path
my $props_status="IP,HOSTNAME,PATH";
# Resource props.
if ($config{'show_cmd'}) {
if ($config{'show_templates'}) {
$props_res="IP,RELEASE,NIC,PATH,ACTIVE,TEMPLATE,CMD";
}
else {
$props_res="IP,RELEASE,NIC,PATH,ACTIVE,CMD";
}
}
else {
if ($config{'show_templates'}) {
$props_res="IP,RELEASE,NIC,PATH,ACTIVE,TEMPLATE";
}
else {
$props_res="IP,RELEASE,NIC,PATH,ACTIVE";
}
}
sub get_export_options
{
my $def_export_opts = &backquote_command("/usr/bin/grep 'bastille_export_options=' $config{'bastille_confpath'} | cut -d '\"' -f2");
}
# get_bastille_version()
sub get_bastille_version
{
my $version = &backquote_command("$config{'bastille_path'} -v | perl -pe 's/\e\[[][A-Za-z0-9];?[0-9]*m?//g'");
}
sub get_bastille_version_min
{
my $version = &backquote_command("$config{'bastille_path'} -v | perl -pe 's/\e\[[][A-Za-z0-9];?[0-9]*m?//g;s/\.//g'");
}
sub get_local_nics
{
my $nics = &backquote_command('ifconfig -l');
}
sub list_local_jails
{
my $localjails = &backquote_command("$config{'bastille_path'} list jails");
my @jails = split(/\s+/, $localjails);
return ( @jails );
}
sub list_local_backups
{
my $localbackups = &backquote_command("$config{'bastille_path'} list backups");
my @backups = split(/\s+/, $localbackups);
return ( @backups );
}
sub list_base_release
{
my @baserels = split(' ', $config{'bastille_releases'});
return ( @baserels );
}
sub get_local_releases
{
# Use ls command, otherwise use bastille internal command to list all bases.
my $releases = &backquote_command("echo \$(ls $config{'bastille_relpath'})");
}
sub get_installed_releases
{
# Use ls command, otherwise use bastille internal command to list all bases.
my $releases = &backquote_command("echo \$(ls $config{'bastille_relpath'}) | sed 's/\ /,\ /g'");
}
sub get_zfs_mode
{
my $zfsmode = &backquote_command("/usr/bin/grep 'bastille_zfs_enable=' $config{'bastille_confpath'} | cut -d'\"' -f2");
}
# Set action buttons.
my $start_icon = "./images/start.png";
my $stop_icon = "./images/stop.png";
my $restart_icon = "./images/restart.png";
# Check if bastille support for options
sub options_support
{
#my $options_support = &backquote_command("$config{'bastille_path'} create | /usr/bin/grep -wo 'option'");
my $options_support = "yes";
}
sub get_local_osrelease
{
my $osrelaese = &backquote_command("freebsd-version | sed 's/\-[pP].*//'");
}
sub list_ipv4_netmask
{
my @netmask = qw( /24 /16 /8 );
return ( @netmask );
}
sub list_ipv6_netmask
{
my @netmask = qw( /64 /48 /32 );
return ( @netmask );
}
sub list_local_nics
{
my $localnics = get_local_nics();
my @nics = split(/\s+/, $localnics);
return ( @nics );
}
sub list_local_rels
{
my $localrels = get_local_releases();
if (!$localrels) {
$localrels = get_local_osrelease();
}
my @rels = split(/\s+/, $localrels);
return ( @rels );
}
sub check_jail_status
{
$jail = $key;
$jailcheck = &backquote_command("/usr/sbin/jls name | /usr/bin/awk '/^$jail\$/'");
if ($jailcheck) {
# Enable stop and restart buttons and display check icon.
$iconstat = "./images/check.png";
#$showcmd = "<a href='stop.cgi?jails=$key'>Stop</a> | <a href='restart.cgi?jails=$key'>Restart</a>"
$showcmd = "<a href='stop.cgi?jails=$key'><img src=$stop_icon></a> | <a href='restart.cgi?jails=$key'><img src=$restart_icon></a>"
}
else {
# Enable start and restart buttons and display stop icon.
$iconstat = "./images/not.png";
#$showcmd = "<a href='start.cgi?jails=$key'>Start</a> | <a href='restart.cgi?jails=$key'>Restart</a>";
$showcmd = "<a href='start.cgi?jails=$key'><img src=$start_icon></a> | <a href='restart.cgi?jails=$key'><img src=$restart_icon></a>";
}
}
sub list_jails
{
my %jails=();
my $list=&backquote_command("/usr/sbin/jls | sed '1d'");
open my $fh, "<", \$list;
while (my $line =<$fh>) {
chomp ($line);
my @props = split(" ", $line);
$ct = 1;
foreach $prop (split(",", $props_status)) {
$jails{$props[0]}{$prop} = $props[$ct];
$ct++;
}
}
return %jails;
}
sub list_res
{
my %jailr=();
my $list=&backquote_command("$config{'bastille_path'} list jail");
open my $fh, "<", \$list;
while (my $line =<$fh>) {
chomp ($line);
my @props = split(" ", $line);
$ct = 1;
foreach $prop (split(",", $props_res)) {
$jailr{$props[0]}{$prop} = $props[$ct];
$ct++;
}
}
return %jailr;
}
sub list_release
{
my %jailr=();
my $list=&backquote_command("$config{'bastille_path'} list release");
open my $fh, "<", \$list;
while (my $line =<$fh>) {
chomp ($line);
my @props = split(" ", $line);
$ct = 1;
foreach $prop (split(",", $props_res)) {
$jailr{$props[0]}{$prop} = $props[$ct];
$ct++;
}
}
return %jailr;
}
# Jail resource list.
sub ui_jail_res
{
my %jailr = list_res($jailr);
@props = split(/,/, $props_res);
print &ui_columns_start([ "JID", "NAME", @props ]);
foreach $key (sort(keys %jailr)) {
@vals = ();
foreach $prop (@props) { push (@vals, $jailr{$key}{$prop}); }
# Get some jail info from either jls or config.
$jid = &backquote_command("/usr/sbin/jls -j $key | /usr/bin/awk '/$key/ {print \$1}'");
$ipvx = &backquote_command("/usr/bin/grep '.*ip.*.addr.*=.*' $config{'bastille_jailpath'}/$key/jail.conf | cut -d '=' -f2 | tr -d ' ;'");
$interface = &backquote_command("/usr/bin/grep -E '.*interface.*=.*;|.*vnet.interface.*=.*;' $config{'bastille_jailpath'}/$key/jail.conf | cut -d '=' -f2 | tr -d ' ;'");
$osrel = &backquote_command("/usr/sbin/jexec $key freebsd-version 2>/dev/null");
if (!$jid) {
$jid = "-";
}
# Try to get ipv6 instead.
#if (!$ipvx) {
# $ipvx = &backquote_command("/usr/bin/grep '.*ip6.addr.*=' $config{'bastille_jailpath'}/$key/jail.conf | cut -d '=' -f2 | tr -d ' ;'");
#}
# Try to get ip from vnet config.
if (!$ipvx) {
$ipvx = &backquote_command("$config{'bastille_path'} cmd $key cat /etc/rc.conf | /usr/bin/grep 'ifconfig_vnet0=' | cut -d'\"' -f2 | sed 's/inet //'");
}
# Try to get ip from ifconfig as last resort.
# Netmask need conversion from hex to dec.
if (!$ipvx) {
#$netmask_hex = &backquote_command("$config{'bastille_path'} cmd $key ifconfig vnet0 | /usr/bin/grep 'inet' | /usr/bin/awk '{print \$4}'");
$ipvx = &backquote_command("$config{'bastille_path'} cmd $key ifconfig vnet0 | /usr/bin/grep 'inet' | /usr/bin/awk '{print \$2}'");
}
if (!$ipvx) {
$ipvx = "-";
}
if (!$interface) {
$interface = "-";
}
if (!$osrel) {
$osrel = "-";
}
# Display custom template icons if available.
$custom_icon = "./images/addons/$key\_icon.png";
$plugin_icon = "$config{'bastille_jailpath'}/$key/plugin_icon.png";
if ((-e $plugin_icon) && (!-e $custom_icon)) {
&backquote_command("/bin/cp $plugin_icon $custom_icon");
}
if (-e $custom_icon) {
$template_icon = "./images/addons/$key\_icon.png";
} else {
$is_linuxjail = &backquote_command("/usr/bin/grep linsysfs $config{'bastille_jailpath'}/$key/fstab");
if ($is_linuxjail) {
$template_icon = "./images/linux_icon.png";
} else {
$template_icon = "./images/bsd_icon.png";
}
}
if ($config{'show_cmd'}) {
&check_jail_status($key);
if ($config{'show_templates'}) {
print &ui_columns_row(["$jid", $key, "$ipvx", "$osrel", "$interface", "<a href='../filemin/index.cgi?path=$config{'bastille_jailpath'}/$key'>$config{'bastille_jailpath'}/$key</a>",
"<img src=$iconstat>", "<img src=$template_icon>", "$showcmd"]);
}
else {
print &ui_columns_row(["$jid", $key, "$ipvx", "$osrel", "$interface", "<a href='../filemin/index.cgi?path=$config{'bastille_jailpath'}/$key'>$config{'bastille_jailpath'}/$key</a>",
"<img src=$iconstat>", "$showcmd"]);
}
}
else {
&check_jail_status($key);
if ($config{'show_templates'}) {
print &ui_columns_row(["$jid", $key, "$ipvx", "$osrel", "$interface", "<a href='../filemin/index.cgi?path=$config{'bastille_jailpath'}/$key'>$config{'bastille_jailpath'}/$key</a>",
"<img src=$iconstat>", "<img src=$template_icon>"]);
}
else {
print &ui_columns_row(["$jid", $key, "$ipvx", "$osrel", "$interface", "<a href='../filemin/index.cgi?path=$config{'bastille_jailpath'}/$key'>$config{'bastille_jailpath'}/$key</a>",
"<img src=$iconstat>"]);
}
}
}
print &ui_columns_end();
}
sub ui_perjail_edit
{
my %jailr = list_res($jailr);
@props = split(/,/, $props_res);
print &ui_columns_start([ "NAME", "PATH" ]);
foreach $key (sort(keys %jailr)) {
@vals = ();
foreach $prop (@props) { push (@vals, $jailr{$key}{$prop}); }
print &ui_columns_row(["<a href='edit_perjail.cgi?jailr=$key'>$key</a>",
"<a href='../filemin/index.cgi?path=$config{'bastille_jailpath'}/$key'>$config{'bastille_jailpath'}/$key</a>" ]);
}
&unlink_record();
print &ui_columns_end();
}
sub ui_perjail_fstab
{
my %jailr = list_res($jailr);
@props = split(/,/, $props_res);
print &ui_columns_start([ "NAME", "PATH" ]);
foreach $key (sort(keys %jailr)) {
@vals = ();
foreach $prop (@props) { push (@vals, $jailr{$key}{$prop}); }
print &ui_columns_row(["<a href='ui_jail_fstab.cgi?jailr=$key'>$key</a>",
"<a href='../filemin/index.cgi?path=$config{'bastille_jailpath'}/$key'>$config{'bastille_jailpath'}/$key</a>" ]);
}
&unlink_record();
print &ui_columns_end();
}
sub ui_perjail_destroy
{
my %jailr = list_res($jailr);
@props = split(/,/, $props_res);
print &ui_columns_start([ "NAME", "PATH" ]);
foreach $key (sort(keys %jailr)) {
@vals = ();
foreach $prop (@props) { push (@vals, $jailr{$key}{$prop}); }
print &ui_columns_row(["<a href='ui_jail_destroy.cgi?jailr=$key'>$key</a>",
"<a href='../filemin/index.cgi?path=$config{'bastille_jailpath'}/$key'>$config{'bastille_jailpath'}/$key</a>" ]);
}
&unlink_record();
print &ui_columns_end();
}
sub ui_release_destroy
{
my %jailr = list_release($jailr);
@props = split(/,/, $props_res);
print &ui_columns_start([ "NAME", "PATH" ]);
foreach $key (sort(keys %jailr)) {
@vals = ();
foreach $prop (@props) { push (@vals, $jailr{$key}{$prop}); }
print &ui_columns_row(["<a href='ui_jail_destroy.cgi?jailr=$key'>$key</a>",
"<a href='../filemin/index.cgi?path=$config{'bastille_relpath'}/$key'>$config{'bastille_jailpath'}/$key</a>" ]);
}
&unlink_record();
print &ui_columns_end();
}
sub unlink_record
{
my $editfile = "$module_config_directory/last_edit";
if (-e $editfile ) {
# Unlink previous record file.
unlink "$module_config_directory/last_edit";
}
}
sub ui_bastille_conf
{
# Display icons for options.
if ($config{'show_conf'}) {
push(@links, "ui_perjail_edit.cgi");
push(@titles, $text{'manual_jailedit'});
push(@icons, "images/perjail.gif");
push(@links, "edit_manual.cgi");
push(@titles, $text{'manual_title'});
push(@icons, "images/manual.gif");
}
&icons_table(\@links, \@titles, \@icons, 4);
}
sub ui_bastille_advanced
{
# Display icons for options.
if ($config{'show_advanced'}) {
push(@links2, "ui_jail_create.cgi");
push(@titles2, $text{'manual_createjail'});
push(@icons2, "images/create.gif");
}
if ($config{'show_destroy'}) {
push(@links2, "ui_perjail_destroy.cgi");
push(@titles2, $text{'manual_deljail'});
push(@icons2, "images/delete.gif");
}
if ($config{'show_advanced'}) {
push(@links2, "ui_perjail_fstab.cgi");
push(@titles2, $text{'create_fstab'});
push(@icons2, "images/dirtree.gif");
}
if ($config{'show_advanced'}) {
push(@links2, "ui_release_fetch.cgi");
push(@titles2, $text{'download_icontext'});
push(@icons2, "images/download.gif");
}
if ($config{'show_advanced'}) {
push(@links2, "ui_jail_export.cgi");
push(@titles2, $text{'export_icontext'});
push(@icons2, "images/backup.gif");
}
if ($config{'show_advanced'}) {
push(@links2, "ui_jail_import.cgi");
push(@titles2, $text{'import_icontext'});
push(@icons2, "images/import.gif");
}
&icons_table(\@links2, \@titles2, \@icons2, 4);
}
sub read_last_edit
{
my $editfile = "$module_config_directory/last_edit";
if (open(my $fh, '<:encoding(UTF-8)', $editfile)) {
while (my $row = <$fh>) {
chomp $row;
$item = "$row\n";
$item =~ s/\s+//g;
}
}
}
# Start jail.
sub start_jail
{
my $jails = $in{'jails'};
if ($config{'show_cmd'}) {
local $out = &backquote_command("$config{'start_cmd'} $jails 2>&1 </dev/null");
$out =~ s/\e\[[][A-Za-z0-9];?[0-9]*m?//g;
return "<pre>$out</pre>" if ($?);
}
return undef;
}
# Stop jail.
sub stop_jail
{
my $jails = $in{'jails'};
if ($config{'show_cmd'}) {
local $out = &backquote_command("$config{'stop_cmd'} $jails 2>&1 </dev/null");
$out =~ s/\e\[[][A-Za-z0-9];?[0-9]*m?//g;
return "<pre>$out</pre>" if ($?);
}
return undef;
}
# Restart jail.
sub restart_jail
{
my $jails = $in{'jails'};
if ($config{'show_cmd'}) {
local $out = &backquote_command("$config{'restart_cmd'} $jails 2>&1 </dev/null");
$out =~ s/\e\[[][A-Za-z0-9];?[0-9]*m?//g;
return "<pre>$out</pre>" if ($?);
}
return undef;
}
# Create jail.
sub jail_create_cmd
{
if ($config{'show_advanced'}) {
$option = "";
if ($in{'emptyjail'} == 1) {
# Just create an empty container with minimal jail.conf.
$option = "-E";
} elsif ($in{'linuxjail'} == 1) {
# Just create an linux container(experimental).
$option = "-L";
} elsif (($in{'emptyjail'} == 1) && ($in{'linuxjail'} == 1)) {
# Just create an empty container, overrides all other options.
$option = "-E";
} else {
if (($in{'thick'} == 1) && ($in{'vnet'} == 1)) {
$option = "-T -V";
} elsif ($in{'thick'} == 1 ) {
$option = "-T";
} elsif ($in{'vnet'} == 1 ) {
$option = "-V";
}
}
my $cmd = "$cmdline";
local $out = &backquote_command("$config{'bastille_path'} create $option $cmd 2>&1 </dev/null");
$out =~ s/\e\[[][A-Za-z0-9];?[0-9]*m?//g;
return "<pre>$out</pre>" if ($?);
}
return undef;
}
# Destroy jail.
sub destroy_jail_cmd
{
if ($config{'show_destroy'}) {
&read_last_edit();
if ($item ne $in{'name'}) {
$item = "";
}
$template_icon = "./images/addons/$item\_icon.png";
if (-e $template_icon) {
$destroy_cmd = &backquote_command("$config{'bastille_path'} destroy $item && /bin/rm $template_icon 2>&1 </dev/null");
} else {
$destroy_cmd = &backquote_command("$config{'bastille_path'} destroy $item 2>&1 </dev/null");
}
local $out = $destroy_cmd;
$out =~ s/\e\[[][A-Za-z0-9];?[0-9]*m?//g;
return "<pre>$out</pre>" if ($?);
}
return undef;
}
# Add fstab.
sub jail_addfstab_cmd
{
if ($config{'show_advanced'}) {
&read_last_edit();
if ($item ne $in{'name'}) {
$item = "";
}
if ($makedir eq "yes") {
unless(-e $targetdir or mkpath $targetdir) {
&backquote_command("mkdir -p $targetdir");
}
}
my $cmd = $cmdline;
if ($cmd) {
local $out = &backquote_command("echo $cmd >> $config{'bastille_jailpath'}/$name/fstab 2>&1 </dev/null");
$out =~ s/\e\[[][A-Za-z0-9];?[0-9]*m?//g;
return "<pre>$out</pre>" if ($?);
}
}
return undef;
}
sub download_release_cmd
{
if ($config{'show_advanced'}) {
my $selection = $in{'release'};
my $sysrelease = &get_local_osrelease();
my $opt_distfiles = "$in{'opt_lib32'} $in{'opt_ports'} $in{'opt_src'}";
my $def_distfiles = &backquote_command("/usr/sbin/sysrc -f $config{'bastille_confpath'} -n bastille_bootstrap_archives");
$opt_distfiles =~ s/\s+$//;
$def_distfiles =~ s/\s+$//;
if ($opt_distfiles) {
# Override config distfiles list once.
$set_distfiles = &backquote_command("/usr/sbin/sysrc -f $config{'bastille_confpath'} bastille_bootstrap_archives=\"base $opt_distfiles\"");
}
if ($selection eq "DAFAULT") {
$sysrelease =~ s/\s+$//;
$cmd = $sysrelease;
} else {
$cmd = $selection;
}
local $out = &backquote_command("/bin/echo 'Y' | $config{'bastille_path'} bootstrap $cmd 2>&1 </dev/null");
$out =~ s/\e\[[][A-Za-z0-9];?[0-9]*m?//g;
return "<pre>$out</pre>" if ($?);
# Set back default distfiles.
if ($opt_distfiles) {
&backquote_command("/usr/sbin/sysrc -f $config{'bastille_confpath'} bastille_bootstrap_archives=\"$def_distfiles\"");
}
}
return undef;
}
sub export_jail_cmd
{
if ($config{'show_advanced'}) {
$export_opt="";
$export_path="";
$export_defaults = &get_export_options();
if ($export_defaults =~ /^ *$/) {
if (($in{'raw_archive'} == 1) && ($in{'safe_zfsexp'} == 1)) {
$export_opt = "--safe --raw";
}
elsif ($in{'raw_archive'} == 1) {
$export_opt = "--raw";
}
elsif (($in{'gz_archive'} == 1) && ($in{'safe_zfsexp'} == 1)) {
$export_opt = "--safe --gz";
}
elsif ($in{'gz_archive'} == 1) {
$export_opt = "--gz";
}
elsif (($in{'xz_archive'} == 1) && ($in{'safe_zfsexp'} == 1)) {
$export_opt = "--safe --xz";
}
elsif ($in{'xz_archive'} == 1) {
$export_opt = "--xz";
}
elsif (($in{'tgz_archive'} == 1) && ($in{'safe_zfsexp'} == 1)) {
$export_opt = "--tgz";
}
elsif ($in{'tgz_archive'} == 1) {
$export_opt = "--tgz";
}
elsif (($in{'txz_archive'} == 1) && ($in{'safe_zfsexp'} == 1)) {
$export_opt = "--txz";
}
elsif ($in{'txz_archive'} == 1) {
$export_opt = "--txz";
}
elsif ($in{'safe_zfsexp'} == 1) {
$export_opt = "--safe --xz";
}
}
if ($in{'exp_path'}) {
$export_path = $in{'exp_path'};
}
my $item = $in{'exp_jail'};
local $out = &backquote_command("$config{'bastille_path'} export $export_opt $item $export_path 2>&1 </dev/null");
$out =~ s/\e\[[][A-Za-z0-9];?[0-9]*m?//g;
return "<pre>$out</pre>" if ($?);
}
return undef;
}
sub import_jail_cmd
{
if ($config{'show_advanced'}) {
$force_opt="";
if ($in{'force_import'} == 1) {
$force_opt = "-f";
}
my $item = $in{'imp_jail'};
if ($in{'from_path'}) {
$item = $in{'from_path'};
}
local $out = &backquote_command("$config{'bastille_path'} import $item $force_opt 2>&1 </dev/null");
$out =~ s/\e\[[][A-Za-z0-9];?[0-9]*m?//g;
return "<pre>$out</pre>" if ($?);
}
return undef;
}
sub delete_release_cmd
{
if ($config{'show_advanced'}) {
my $cmd = $in{'release'};
local $out = &backquote_command("$config{'bastille_path'} destroy $cmd 2>&1 </dev/null");
$out =~ s/\e\[[][A-Za-z0-9];?[0-9]*m?//g;
return "<pre>$out</pre>" if ($?);
}
return undef;
}
1;