-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings-tui-jail.subr
949 lines (780 loc) · 23.4 KB
/
settings-tui-jail.subr
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
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
# JAIL-related TUI function
if [ ! "$_CBSD_SETTINGS_TUI_JAIL_SUBR" ]; then
_CBSD_SETTINGS_TUI_JAIL_SUBR=1
###
allow_devfs_msg="Allow privileged users inside the jail mount and unmount DEVFS file system"
allow_dying_msg="Allow making changes to a dying Jail"
allow_fdescfs_msg="Jail may mount the fdescfs file system"
allow_fusefs_msg="Allow privileged users inside the jail mount and unmount fuse-based file systems."
allow_linprocfs_msg="Allow privileged users inside the jail mount and unmount linprocfs."
allow_linsysfs_msg="Allow privileged users inside the jail mount and unmount linsysfs."
allow_kmem_msg="Allow kmem and /dev/io devices for jail. Warning: this is insecure options. Use it only for private purposes/X-jails"
allow_mount_msg="Allow privileged users inside the jail mount and unmount file system"
allow_nullfs_msg="Allow privileged users inside the jail mount and unmount NULLFS file system"
allow_procfs_msg="Allow privileged users inside the jail mount and unmount PROCFS file system"
allow_raw_sockets_msg="The jail root is allowed to create raw sockets"
allow_read_msgbuf_msg="Allow an unprivileged user to read the kernel message buffer"
allow_reserved_ports_msg="Allow the jail root may bind to ports lower than 1024. For FreeBSD 11.1+"
sysvsem_msg="Controls access to SYSV semaphores"
sysvshm_msg="Controls access to shared memory"
sysvmsg_msg="Controls access to SYSV message queues"
allow_tmpfs_msg="Allow privileged users inside the jail mount and unmount TMPFS file system"
allow_mlock_msg="Allow mlock(2) or munlock(2) within jail"
allow_unprivileged_proc_debug_msg="Unprivileged processes in the jail may use debugging facilities"
allow_vmm_msg="The jail may access vmm(4). Useful for jailed bhyve"
allow_zfs_msg="Privileged users inside the jail will be able to mount and unmount the ZFS file system"
applytpl_msg="1,yes - Apply CBSD templates for Jail environment"
arch_msg="Target architecture, i386/amd64 or qemu-users arch"
basename_msg="Alternative jailbase name"
baserw_msg="1,yes - Jail have personal copy of base system with write access, no NULLFS mount. 0,no - read-only and NULLFS"
b_order_msg="Set integer for boot order."
childrenmax_msg="Enable hierarchical jails and set limit max children"
cpuset_msg="Associate group of CPUs to jail. 0 - for all cores, See man 1 cpuset for valid value"
data_msg="Data directory for Jail"
depend_msg="Specify a Jail or jails that this jail depends on"
devfs_ruleset_msg="DEVFS ruleset number for Jail devfs"
enforce_statfs_msg="This determines what information processes in a jail are able to get about mount points"
exec_consolelog_msg="Jail consolelog file for stdout/stderr output. Possible values: path_to_file, 0 - for disable log to file, 1 - for automatic $logdir/jname.log"
exec_fib_msg="The FIB routing table to set when running commands inside the prison"
exec_timeout_msg="The maximum amount of time to wait for a command to complete"
floatresolv_msg="1,yes - Floating /etc/resolv.conf content"
jdomain_msg="Specify CBSD node group name for jail"
kernelmount_msg="1,yes - Jail have mounted /boot/kernel tree in read-only. Useful for DTRACE stuff in Jail"
mdsize_msg="Enter size for the images"
mkhostsfile_msg="Automatically set IP/NAME in /etc/hosts when jail started"
mount_devfs_msg="Mount DEVFS filesystem in the jail"
mount_fdescfs_msg="Mount a FDESCFS filesystem on the chrooted /dev/fd directory"
mount_kernel_msg="1,yes - Jail have mounted /boot/kernel tree in read-only. Useful for DTRACE stuff in Jail"
mount_obj_msg="1,yes - Jail have mounted /usr/obj tree in read-only"
mount_ports_msg="1,yes - Jail have /usr/ports /usr/ports tree in read-only"
mount_src_msg="1,yes - Jail have shared /usr/src tree in read-only"
path_msg="Mount point for Jail"
persist_msg="Allows a jail to exist without any processes."
stop_timeout_msg="The maximum amount of time to wait for a jailed processes to exit after sending them a SIGTERM signal"
ver_msg="Jail base source version"
vnet_msg="1.yes - Enable VIMAGE/VNet feature"
ip4_addr_msg="Jail IPv4 and/or IPv6 address"
ip4_addr_desc="Current CBSD IPv4 pool: ${nodeippool}\n\
Use IP/PREFIX form, comma-separated for aliases.\n\
'0' to disable IP creating by CBSD (useful for vnet jails)\n\
'DHCP' for determine free IPv4 automatically\n\
'DHCPv6' for determine free IPv6 automatically\n\
'REALDHCP' when DHCP server is used (uses dhclient - useful for vnet jails)\n\
'nic1#ip_addr,nic2#ip_addr' for multiple NIC form\n"
GET_JAILPROFILE_MSG="Profile for jcreate"
# jail form for $pkglist
get_construct_pkglist()
{
local _i
[ -z "${pkglist}" -o "${pkglist}" = "NO" ] && pkglist="${ftmpdir}/tui.$$"
# load pkg list from profile
if [ -n "${tpl_pkglist}" ]; then
if [ -r "${tpl_pkglist}" ]; then
${CAT_CMD} ${tpl_pkglist} >> ${pkglist}
else
for _i in ${tpl_pkglist}; do
echo ${_i} >> ${pkglist}
done
fi
fi
pkgbrowser controlmaster="${pkglist}"
[ ! -s "${pkglist}" ] && pkglist="NO"
}
# jail form for $srvlist
get_construct_services()
{
local msg_ok="Got it"
if [ -z "${ver}" ]; then
f_dialog_msgbox "Please select ver for jail version first"
return 0
fi
if [ -z "${arch}" ]; then
f_dialog_msgbox "Please select arch for jail architecture first"
return 0
fi
init_basedir
if [ -z "${BASE_DIR}" ]; then
f_dialog_msgbox "BASE_DIR empty"
return 0
fi
if [ ! -x ${BASE_DIR}/bin/sh ]; then
f_dialog_msgbox "No such basejail: ${BASE_DIR}\n Please fetch this first"
return 0
fi
srvlist="${ftmpdir}/srv.$$"
srvbrowser controlmaster="${srvlist}" baseonly=1 path=${BASE_DIR}
[ ! -s "${srvlist}" ] && srvlist="NO"
}
# jail form for $ver
get_construct_ver()
{
title=" ver "
prompt="${ver_msg}"
defaultitem="${ver}"
cbsd_inputbox_simple && ver="${mtag}"
}
# print available/registered jail bases for $ver/$arch
# -v $ver
# -a $arch
# return 0 when exist
# return 1 when not
# list=$( get_basebame_list [-v $ver -a $arch] )
# [ $? -eq 0 ] && echo "base list: ${list}"
get_basename_list()
{
local _arch _ver _sver _basename_list
while getopts "a:v:" opt; do
case "${opt}" in
a) _arch="${OPTARG}" ;;
v) _ver="${OPTARG}" ;;
esac
shift $(($OPTIND - 1))
done
[ -z "${_arch}" ] && _arch="${arch}"
[ -z "${_ver}" ] && _ver="${ver}"
_sver=${_ver%%.*}
_basename_list=$( cbsdsqlro ${dbdir}/local.sqlite SELECT basename FROM bsdbase WHERE basename != '0' AND \( ver=\"${_ver}\" OR ver=\"${_sver}\" \) AND arch=\"${_arch}\" 2>/dev/null | ${XARGS_CMD} )
if [ -z "${_basename_list}" ]; then
return 1
else
printf "${_basename_list}"
return 0
fi
}
# jail form for $basename
# -m 1 - add "manual" choice
# -v $ver
# -a $arch
get_construct_basename()
{
local menu_list _arch _manual _ver _sver _basename_list
local i
local title=" basename "
local prompt="${basename_msg}"
hline=
_basename_list=$( get_basename_list )
local menu_list="
'EXIT' 'EXIT' 'Exit'
" # END-QUOTE
defaultitem="${basename}"
while getopts "a:m:v:" opt; do
case "${opt}" in
a) _arch="${OPTARG}" ;;
m) _manual="${OPTARG}" ;;
v) _ver="${OPTARG}" ;;
esac
shift $(($OPTIND - 1))
done
_basename_list=$( get_basename_list )
[ -z "${_arch}" ] && _arch="${arch}"
[ -z "${_ver}" ] && _ver="${ver}"
menu_list=
if [ "${_manual}" = "1" ]; then
menu_list="${menu_list} 'manual' 'manual' 'Enter basename by hand.'"
fi
_basename_list=$( get_basename_list -a ${_arch} -v ${_ver} )
menu_list="${menu_list} '-' '-' ''"
for i in ${_basename_list}; do
menu_list="${menu_list} '${i}' '${i}' 'Description: ${i}'"
done
cbsd_menubox
_retval=$?
case ${_retval} in
${DIALOG_OK})
case "${mtag}" in
"-")
continue
;;
EXIT)
return 1
;;
manual)
cbsd_inputbox_simple && basename="${mtag}"
;;
*)
[ -n "${mtag}" ] && basename="${mtag}"
;;
esac
;;
*)
;;
esac
return ${_retval}
}
# jail form for $exec_stop
get_construct_exec_stop()
{
title=" exec_stop "
prompt=" Redefine for exec_stop "
defaultitem="${exec_stop}"
cbsd_inputbox_simple && exec_stop="${mtag}"
}
# jail form for $exec_start
get_construct_exec_start()
{
title=" exec_start "
prompt=" Redefine for exec_start "
defaultitem="${exec_start}"
cbsd_inputbox_simple && exec_start="${mtag}"
}
# jail form for $childrenmax
get_construct_childrenmax()
{
title=" childrenmax "
prompt="${childrenmax_msg}"
defaultitem="${childrenmax}"
cbsd_inputbox_simple && childrenmax="${mtag}"
}
# jail form for $enforce_statfs
get_construct_enforce_statfs()
{
title=" enforce_statfs "
prompt="${enforce_statfs_msg}"
defaultitem="${enforce_statfs}"
cbsd_inputbox_simple && enforce_statfs="${mtag}"
}
# jail form for $user_pw_root
get_construct_user_pw_root()
{
if get_password; then
user_pw_root_crypt=$( ${miscdir}/pwcrypt ${mtag} )
if [ $? -eq 0 ]; then
unset user_pw_root
else
user_pw_root="${mtag}"
unset user_pw_root_crypt
fi
fi
}
# jail form for $path
get_construct_path()
{
title=" path "
prompt="${path_msg}"
defaultitem="${path}"
cbsd_inputbox_simple && path="${mtag}"
}
# jail form for $data
get_construct_data()
{
title=" data "
prompt="${data_msg}"
defaultitem="${data}"
cbsd_inputbox_simple && data="${mtag}"
}
# jail form for $devfs_ruleset
get_construct_devfs_ruleset()
{
title=" devfs_ruleset "
prompt="${devfs_ruleset_msg}"
defaultitem="${devfs_ruleset}"
cbsd_inputbox_simple && devfs_ruleset="${mtag}"
}
# jail form for $mdsize
get_construct_mdsize()
{
title=" mdsize "
prompt="${mdsize_msg}"
defaultitem="${mdsize}"
cbsd_inputbox_simple && mdsize="${mtag}"
}
# jail form for $exec_timeout
get_construct_exec_timeout()
{
local _input
f_dialog_title " exec_timeout "
f_dialog_input _input "${exec_timeout_msg}" "${exec_timeout}" \
"${_message}" || return $?
exec_timeout="${_input}"
}
# jail form for $exec_fib
get_construct_exec_fib()
{
local _input
f_dialog_title " exec_fib "
f_dialog_input _input "${exec_fib_msg}" "${exec_fib}" \
"${_message}" || return $?
exec_fib="${_input}"
}
# jail form for $exec_consolelog
get_construct_exec_consolelog()
{
local _input
f_dialog_title " exec_consolelog "
f_dialog_input _input "${exec_consolelog_msg}" "${exec_consolelog}" \
"${_message}" || return $?
exec_consolelog="${_input}"
}
# jail form for $stop_timeout
get_construct_stop_timeout()
{
local _input
f_dialog_title " stop_timeout "
f_dialog_input _input "${stop_timeout_msg}" "${stop_timeout}" \
"${_message}" || return $?
stop_timeout="${_input}"
}
# jail form for $depend
get_jail_depend()
{
local _input
f_dialog_title " depend "
f_dialog_input _input "${depend_msg}" \
"${_message}" || return $?
depend="${_input}"
}
# jail form for $cpuset
get_construct_cpuset()
{
local _input
f_dialog_title " cpuset "
f_dialog_input _input "${cpuset_msg}" "${cpuset}" \
"${_message}" || return $?
cpuset="${_input}"
}
# jail form for $arch
get_construct_arch()
{
local _input _res
local title="${arch_msg}"
local defaultitem="${arch}"
local qemu_mips64=$( which qemu-mips64-static 2>/dev/null )
local qemu_arm=$( which qemu-arm-static 2>/dev/null )
local qemu_aarch64=$( which qemu-aarch64-static 2>/dev/null )
local qemu_ppc64=$( which qemu-ppc64-static 2>/dev/null )
local amd64_menu=
local i386_menu=
local amd64_desc=
local i386_desc=
local arm_menu=
local mips_menu=
local arm_desc=
local mips_desc=
local qemu_mips64_desc=
local qemu_arm_desc=
local qemu_aarch64_desc=
local qemu_mips64_enable=
local qemu_arm_enable=
local qemu_aarch64_enable=
local qemu_mips64_menu="MIPS64"
local qemu_arm_menu="ARMv6"
local qemu_aarch64_menu="ARMv8"
local qemu_powerpc64_enable=
local qemu_powerpc64_menu="powerpc64"
# test for qemu_mips64
if [ -n "${qemu_mips64}" ]; then
_res=$( 2>&1 ${LDD_CMD} ${qemu_mips64} | ${GREP_CMD} -q "not a dynamic ELF executable" )
if [ $? -eq 0 ]; then
qemu_mips64_enable=1
qemu_mips64_desc="MIPS64 via ${qemu_mips64}"
else
qemu_mips64_enable=0
qemu_mips64_desc="${qemu_mips64} is not static. Please rebuild with STATIC ( emulators/qemu-user-static )"
fi
else
qemu_mips64_enable=0
qemu_mips64_desc="You have no qemu-user: please install qemu-devel with BSD_USER and STATIC ops ( emulators/qemu-user-static )"
fi
# test for qemu_arm
if [ -n "${qemu_arm}" ]; then
_res=$( 2>&1 ${LDD_CMD} ${qemu_arm} | ${GREP_CMD} -q "not a dynamic ELF executable" )
if [ $? -eq 0 ]; then
qemu_arm_enable=1
qemu_arm_desc="ARM via ${qemu_arm}"
else
qemu_arm_enable=0
qemu_arm_desc="${qemu_arm} is not static. Please rebuild with STATIC ( emulators/qemu-user-static )"
fi
else
qemu_arm_enable=0
qemu_arm_desc="You have no qemu-user: please install qemu-devel with BSD_USER and STATIC ops ( emulators/qemu-user-static )"
fi
# test for qemu_aarch64
if [ -n "${qemu_aarch64}" ]; then
_res=$( 2>&1 ${LDD_CMD} ${qemu_aarch64} | ${GREP_CMD} -q "not a dynamic ELF executable" )
if [ $? -eq 0 ]; then
qemu_aarch64_enable=1
qemu_aarch64_desc="aarch64 aka ARMv8 and arm-64 via ${qemu_arm}"
else
qemu_aarch64_enable=0
qemu_aarch64_desc="${qemu_aarch64} is not static. Please rebuild with STATIC ( emulators/qemu-user-static )"
fi
else
qemu_aarch64_enable=0
qemu_aarch64_desc="You have no qemu-user: please install qemu-devel with BSD_USER and STATIC ops ( emulators/qemu-user-static )"
fi
# test for qemu_ppc64
if [ -n "${qemu_ppc64}" ]; then
_res=$( 2>&1 ${LDD_CMD} ${qemu_ppc64} | ${GREP_CMD} -q "not a dynamic ELF executable" )
if [ $? -eq 0 ]; then
qemu_powerpc64_enable=1
qemu_powerpc64_desc="POWERC64 via ${qemu_arm}"
else
qemu_powerpc64_enable=0
qemu_powerpc64_desc="${qemu_ppc64} is not static. Please rebuild with STATIC ( emulators/qemu-user-static )"
fi
else
qemu_powerpc64_enable=0
qemu_powerpc64_desc="You have no qemu-user: please install qemu-devel with BSD_USER and STATIC ops ( emulators/qemu-user-static )"
fi
case "${hostarch}" in
"amd64")
amd64_menu="*"
amd64_desc="This is native architecture for this node"
;;
"i386")
i386_menu="*"
i386_desc="This is native architecture for this node"
;;
"arm")
arm_menu="*"
arm_desc="This is native architecture for this node"
;;
"aarch64")
aarch64_menu="*"
aarch64_desc="This is native architecture for this node"
;;
"mips")
mips_menu="*"
mips_desc="This is native architecture for this node"
;;
"ppc64")
ppc64_menu="*"
ppc64_desc="This is native architecture for this node"
;;
esac
case "${arch}" in
amd64)
local menu_list="
'amd64' 'x86-64 ${amd64_menu}' '64 bit architecture. ${amd64_desc}'
'i386' 'x86 ${i386_menu}' '32 bit architecture. ${i386_desc}'
" # END-QUOTE
;;
i386)
local menu_list="
'i386' 'x86 ${i386_menu}' '32 bit architecture. ${i386_desc}'
" # END-QUOTE
;;
arm)
local menu_list="
'arm' 'arm ${arm_menu}' 'ARM architecture. ${arm_desc}'
" # END-QUOTE
;;
aarch64)
local menu_list="
'arm' 'aarch64 ${aarch64_menu}' 'ARM architecture. ${aarch64_desc}'
" # END-QUOTE
;;
mips)
local menu_list="
'mips' 'mips ${mips_menu}' 'MIPS architecture. ${mips_desc}'
" # END-QUOTE
;;
ppc64)
local menu_list="
'powerpc' 'ppc64 ${ppc64_menu}' 'POWERPC64 architecture. ${ppc64_desc}'
" # END-QUOTE
;;
*)
local menu_list="
'amd64' 'x86-64 ${amd64_menu}' '64 bit architecture. ${amd64_desc}'
'i386' 'x86 ${i386_menu}' '32 bit architecture. ${i386_desc}'
" # END-QUOTE
;;
esac
if [ ${qemu_arm_enable} -eq 1 ]; then
menu_list="${menu_list} 'arm' '${qemu_arm_menu}' '${qemu_arm_desc}'"
else
menu_list="${menu_list} '' 'armv6 unsupported' '${qemu_arm_desc}'"
fi
if [ ${qemu_aarch64_enable} -eq 1 ]; then
menu_list="${menu_list} 'aarch64' '${qemu_aarch64_menu}' '${qemu_aarch64_desc}'"
else
menu_list="${menu_list} '' 'aarch64 unsupported' '${qemu_aarch64_desc}'"
fi
if [ ${qemu_mips64_enable} -eq 1 ]; then
menu_list="${menu_list} 'mips' '${qemu_mips64_menu}' '${qemu_mips64_desc}'"
else
menu_list="${menu_list} '' 'mips unsupported' '${qemu_mips64_desc}'"
fi
if [ ${qemu_powerpc64_enable} -eq 1 ]; then
menu_list="${menu_list} 'powerpc' '${qemu_powerpc64_menu}' '${qemu_powerpc64_desc}'"
else
menu_list="${menu_list} '' 'ppc64 unsupported' '${qemu_powerpc64_desc}'"
fi
cbsd_menubox
retval=$?
case ${retval} in
${DIALOG_OK})
if [ -n "${mtag}" ]; then
arch="${mtag}"
else
arch="${hostarch}"
fi
;;
*)
;;
esac
return ${retval}
}
# jail form for $sysvsem
get_construct_sysvsem()
{
local _input _res
local title="${sysvsem_msg}"
local defaultitem="${sysvsem}"
local menu_list="
'new' 'new' 'New sysvsem: separated isolated segments for jail'
'inherit' 'inherit' 'Inherit (shared) from parent environment'
'disable' 'disable' 'Disable sysvsem within jail'
" # END-QUOTE
cbsd_menubox
retval=$?
case ${retval} in
${DIALOG_OK})
[ -n "${mtag}" ] && sysvsem="${mtag}"
;;
*)
;;
esac
return ${retval}
}
# jail form for $sysvshm
get_construct_sysvshm()
{
local _input _res
local title="${sysvshm_msg}"
local defaultitem="${sysvshm}"
local menu_list="
'new' 'new' 'New sysvshm: separated isolated segments for jail'
'inherit' 'inherit' 'Inherit (shared) from parent environment'
'disable' 'disable' 'Disable sysvsem within jail'
" # END-QUOTE
cbsd_menubox
retval=$?
case ${retval} in
${DIALOG_OK})
[ -n "${mtag}" ] && sysvshm="${mtag}"
;;
*)
;;
esac
return ${retval}
}
# jail form for $sysvmsg
get_construct_sysvmsg()
{
local _input _res
local title="${sysvmsg_msg}"
local defaultitem="${sysvmsg}"
local menu_list="
'new' 'new' 'New sysvmsg: separated isolated segments for jail'
'inherit' 'inherit' 'Inherit (shared) from parent environment'
'disable' 'disable' 'Disable sysvmsg within jail'
" # END-QUOTE
cbsd_menubox
retval=$?
case ${retval} in
${DIALOG_OK})
[ -n "${mtag}" ] && sysvmsg="${mtag}"
;;
*)
;;
esac
return ${retval}
}
# todo: custom skip list, from jsetup-tui
# jail form for jail options in jconstruct-tui
# -c "alternative checkbox list" ( or global variable: ${get_construct_jail_options_menu_checkbox} )
# -p "alternative params list" ( or global variable: ${get_construct_jail_options_menu_params} )
get_construct_jail_options_menu()
{
local _input _res item_let=A _mark _desc i VAL
local title="additional jail options"
local defaultitem=
local menu_choice=
local _checkbox
while getopts "c:p:" opt; do
case "${opt}" in
c) _checkbox="${OPTARG}" ;;
p) _params="${OPTARG}" ;;
esac
shift $(($OPTIND - 1))
done
# default checkbox list
if [ -z "${_checkbox}" ]; then
# via global variable?
if [ -n "${get_construct_jail_options_menu_checkbox}" ]; then
_checkbox="${get_construct_jail_options_menu_checkbox}"
else
# default checkbox list
_checkbox="allow_devfs allow_dying allow_fusefs allow_linprocfs allow_linsysfs allow_kmem allow_mount \
allow_nullfs allow_fdescfs allow_procfs allow_raw_sockets allow_read_msgbuf allow_reserved_ports allow_sysvipc \
allow_tmpfs allow_unprivileged_proc_debug allow_vmm allow_zfs mount_devfs mount_fdescfs mount_procfs mount_linprocfs \
mount_linsysfs mount_fstab mount_kernel mount_obj mount_ports mount_src persist allow_mlock"
fi
fi
# sorted list
_checkbox=$( echo ${_checkbox} | ${SORT_CMD} )
# default params list
if [ -z "${_params}" ]; then
# via global variable?
if [ -n "${get_construct_jail_options_menu_params}" ]; then
_params="${get_construct_jail_options_menu_params}"
else
# default params list
_params="mnt_start mnt_stop"
fi
fi
# sorted list
_params=$( echo ${_params} | ${SORT_CMD} )
f_dialog_default_fetch defaultitem
local menu_list=
# build main menu: params first
for i in ${_params}; do
eval VAL=\$$i
_mydesc=
eval _mydesc=\$${i}_msg
[ -z "${_mydesc}" ] && _mydesc="no description"
if [ -z "${VAL}" ]; then
menu_list="${menu_list} '${item_let} ${i}' ' ' '${_mydesc}'"
else
menu_list="${menu_list} '${item_let} ${i}' '${VAL}' '${_mydesc}'"
fi
inc_menu_index item_let
done
# build main menu: append checkbox list
for i in ${_checkbox}; do
eval _mytest=\$$i
if [ "${_mytest}" = "1" ]; then
export ${i}_mark="X"
_mark="X"
else
export ${i}_mark=" "
_mark=" "
fi
eval _desc="\${${i}_msg}"
menu_list="${menu_list} '${item_let} ${i}' '[${_mark}]' '${_desc}'"
inc_menu_index item_let
done
menu_list="${menu_list} 'Save' 'Save changes and quit' 'Save!'"
cbsd_menubox
retval=$?
f_dialog_data_sanitize menu_choice
f_dialog_menutag_store "${menu_choice}"
f_dialog_default_store "${menu_choice}"
return ${retval}
}
# Submenu for jail options
get_construct_jail_options()
{
local mychoice index
local old_defaultitem="${mtag}"
while [ 1 ]; do
get_construct_jail_options_menu || break
index=${mtag%% *}
mychoice=${mtag##* }
case "${mychoice}" in
"-")
continue
;;
mnt_start|mnt_stop)
get_construct_${mychoice}
continue
;;
"Save")
break
;;
*)
invert_checkbox ${mychoice}
continue
;;
esac
done
f_dialog_default_store "${old_defaultitem}"
}
# jail form for $gw4
get_construct_gw4()
{
local _input
f_dialog_title " gw4 "
f_dialog_input _input "${GET_GW4_MSG}" "${gw4}" \
"${_message}" || return $?
gw4="${_input}"
}
# jail form for $jdomain
get_construct_jdomain()
{
title=" jdomain "
prompt="${jdomain_msg}"
defaultitem="${jdomain}"
cbsd_inputbox_simple && jdomain="${mtag}"
}
# jail emulator part for qemu
make_emulator_part()
{
${SYSRC_CMD} -qf ${TMPFILE} exec_start="/usr/local/bin/${emulator} ${exec_start}" > /dev/null 2>&1
${SYSRC_CMD} -qf ${TMPFILE} exec_stop="/usr/local/bin/${emulator} ${exec_stop}" > /dev/null 2>&1
}
# jail emulator part for jconf
make_jail_part()
{
[ -n "${jailskeldir}" ] && ${SYSRC_CMD} -qf ${TMPFILE} jailskeldir="${jailskeldir}" > /dev/null 2>&1
[ -n "${customskel}" ] && ${SYSRC_CMD} -qf ${TMPFILE} customskel="${customskel}" > /dev/null 2>&1
[ -n "${jailsysskeldir}" ] && ${SYSRC_CMD} -qf ${TMPFILE} jailsysskeldir="${jailsysskeldir}" > /dev/null 2>&1
if [ -z "${profile}" ]; then
${SYSRC_CMD} -qf ${TMPFILE} jail_profile="default" > /dev/null 2>&1
else
${SYSRC_CMD} -qf ${TMPFILE} jail_profile="${profile}" > /dev/null 2>&1
fi
${CAT_CMD} >> ${TMPFILE} << EOF
mount_devfs="${mount_devfs}";
allow_mount="${allow_mount}";
allow_devfs="${allow_devfs}";
allow_nullfs="${allow_nullfs}";
allow_fusefs="${allow_fusefs}";
allow_linsysfs="${allow_linsysfs}";
allow_linprocfs="${allow_linprocfs}";
allow_raw_sockets="${allow_raw_sockets}";
mount_fstab="${mount_fstab}";
mount_fstab_old="${mount_fstab_old}";
arch="${arch}";
mkhostsfile="${mkhostsfile}";
devfs_ruleset="${devfs_ruleset}";
ver="${ver}";
basename="${basename}";
baserw="${baserw}";
mount_src="${mount_src}";
mount_obj="${mount_obj}";
mount_kernel="${mount_kernel}";
mount_ports="${mount_ports}";
vnet="${vnet}";
applytpl="${applytpl}";
mdsize="${mdsize}";
floatresolv="${floatresolv}";
exec_poststart="${exec_poststart}";
exec_poststop="${exec_portstop}";
exec_prestart="${exec_prestart}";
exec_prestop="${exec_prestop}";
exec_master_poststart="${exec_master_poststart}";
exec_master_poststop="${exec_master_poststop}";
exec_master_prestart="${exec_master_prestart}";
exec_master_prestop="${exec_master_prestop}";
pkg_bootstrap="${pkg_bootstrap}";
with_img_helpers="";
allow_reserved_ports="${allow_reserved_ports}";
allow_unprivileged_proc_debug="${allow_unprivileged_proc_debug}";
persist="${persist}";
childrenmax="${childrenmax}";
enforce_statfs="${enforce_statfs}";
sysrc_enable="";
mnt_start="${mnt_start}";
mnt_stop="${mnt_stop}";
allow_mlock="${allow_mlock}";
jailnic_temp_sql="${jailnic_temp_sql}";
EOF
${SYSRC_CMD} -qf ${TMPFILE} exec_start="${exec_start}" > /dev/null 2>&1
${SYSRC_CMD} -qf ${TMPFILE} exec_stop="${exec_stop}" > /dev/null 2>&1
}
###
fi