gocage/cmd/struct.go

477 lines
14 KiB
Go
Raw Normal View History

2021-12-18 13:13:25 +01:00
package cmd
2021-12-20 22:10:38 +01:00
// To allow sorting, just duplicate fields in JailSort below
2021-12-18 13:13:25 +01:00
type Jail struct {
Name string
InternalName string
JID int
Config JailConfig
RootPath string
ConfigPath string
2022-04-02 14:17:10 +02:00
ConfigUpdated bool
2021-12-18 13:13:25 +01:00
Running bool
// No need, Config.Release always represent what is running (plus it know release for non-running jails)
//Release string
Zpool string
2021-12-18 13:13:25 +01:00
}
// iocage struct as stored in config.json
// CONFIG_VERSION = 27
2021-12-20 22:10:38 +01:00
//
// Fields in this struct are acquired by their name using reflection
// So these char are forbidden for field name: -+.
2022-04-02 14:17:10 +02:00
// Array should be forbidden, or else you'll need to rewrite setJailProperty()
2021-12-20 22:10:38 +01:00
//
// To allow sorting, just duplicate fields in JailConfigSort below
2021-12-18 13:13:25 +01:00
type JailConfig struct {
Config_version string `json:"CONFIG_VERSION"`
Allow_chflags int `json:"allow_chflags"`
Allow_mlock int `json:"allow_mlock"`
Allow_mount int `json:"allow_mount"`
Allow_mount_devfs int `json:"allow_mount_devfs"`
Allow_mount_fusefs int `json:"allow_mount_fusefs"`
Allow_mount_nullfs int `json:"allow_mount_nullfs"`
Allow_mount_procfs int `json:"allow_mount_procfs"`
Allow_mount_tmpfs int `json:"allow_mount_tmpfs"`
Allow_mount_zfs int `json:"allow_mount_zfs"`
Allow_quotas int `json:"allow_quotas"`
Allow_raw_sockets int `json:"allow_raw_sockets"`
Allow_set_hostname int `json:"allow_set_hostname"`
Allow_socket_af int `json:"allow_socket_af"`
Allow_sysvipc int `json:"allow_sysvipc"`
Allow_tun int `json:"allow_tun"`
Allow_vmm int `json:"allow_vmm"`
Assign_localhost int `json:"assign_localhost"`
Available string `json:"available"`
Basejail int `json:"basejail"`
Boot int `json:"boot"`
Bpf int `json:"bpf"`
Children_max string `json:"children_max"`
Cloned_release string `json:"cloned_release"`
Comment string `json:"comment"`
Compression string `json:"compression"`
Compressratio string `json:"compressratio"`
Coredumpsize string `json:"coredumpsize"`
Count string `json:"count"`
Cpuset string `json:"cpuset"`
Cputime string `json:"cputime"`
Datasize string `json:"datasize"`
Dedup string `json:"dedup"`
Defaultrouter string `json:"defaultrouter"`
Defaultrouter6 string `json:"defaultrouter6"`
Depends string `json:"depends"`
Devfs_ruleset string `json:"devfs_ruleset"`
Dhcp int `json:"dhcp"`
Enforce_statfs string `json:"enforce_statfs"`
Exec_clean int `json:"exec_clean"`
Exec_created string `json:"exec_created"`
Exec_fib string `json:"exec_fib"`
Exec_jail_user string `json:"exec_jail_user"`
Exec_poststart string `json:"exec_poststart"`
Exec_poststop string `json:"exec_poststop"`
Exec_prestart string `json:"exec_prestart"`
Exec_prestop string `json:"exec_prestop"`
Exec_start string `json:"exec_start"`
Exec_stop string `json:"exec_stop"`
Exec_system_jail_user string `json:"exec_system_jail_user"`
Exec_system_user string `json:"exec_system_user"`
Exec_timeout string `json:"exec_timeout"`
Host_domainname string `json:"host_domainname"`
Host_hostname string `json:"host_hostname"`
Host_hostuuid string `json:"host_hostuuid"`
Host_time int `json:"host_time"`
Hostid string `json:"hostid"`
Hostid_strict_check int `json:"hostid_strict_check"`
Interfaces string `json:"interfaces"`
Ip4 string `json:"ip4"`
Ip4_addr string `json:"ip4_addr"`
Ip4_saddrsel string `json:"ip4_saddrsel"`
Ip6 string `json:"ip6"`
Ip6_addr string `json:"ip6_addr"`
Ip6_saddrsel string `json:"ip4_saddrsel"`
Ip_hostname int `json:"ip_hostname"`
Jail_zfs int `json:"jail_zfs"`
Jail_zfs_dataset string `json:"jail_zfs_dataset"`
Jail_zfs_mountpoint string `json:"jail_zfs_mountpoint"`
Last_started string `json:"last_started"`
Localhost_ip string `json:"localhost_ip"`
Login_flags string `json:"login_flags"`
Mac_prefix string `json:"mac_prefix"`
Maxproc string `json:"maxproc"`
Memorylocked string `json:"memorylocked"`
Memoryuse string `json:"memoryuse"`
Min_dyn_devfs_ruleset string `json:"min_dyn_devfs_ruleset"`
Mount_devfs int `json:"mount_devfs"`
Mount_fdescfs int `json:"mount_fdescfs"`
Mount_linprocfs int `json:"mount_linprocfs"`
Mount_procfs int `json:"mount_procfs"`
Mountpoint string `json:"mountpoint"`
Msgqqueued string `json:"msgqqueued"`
Msgqsize string `json:"msgqsize"`
Nat int `json:"nat"`
Nat_backend string `json:"nat_backend"`
Nat_forwards string `json:"nat_forwards"`
Nat_interface string `json:"nat_interface"`
Nat_prefix string `json:"nat_prefix"`
Nmsgq string `json:"nmsgq"`
Notes string `json:"notes"`
Nsem string `json:"nsem"`
Nsemop string `json:"nsemop"`
Nshm string `json:"nshm"`
Nthr string `json:"nthr"`
Openfiles string `json:"openfiles"`
Origin string `json:"origin"`
Owner string `json:"owner"`
Pcpu string `json:"pcpu"`
Plugin_name string `json:"plugin_name"`
Plugin_repository string `json:"plugin_repository"`
Priority string `json:"priority"`
Pseudoterminals string `json:"pseudoterminals"`
Quota string `json:"quota"`
Readbps string `json:"readbps"`
Readiops string `json:"readiops"`
Release string `json:"release"`
Reservation string `json:"reservation"`
Resolver string `json:"resolver"`
Rlimits string `json:"rlimits"`
Rtsold int `json:"rtsold"`
Securelevel string `json:"securelevel"`
Shmsize string `json:"shmsize"`
Stacksize string `json:"stacksize"`
Stop_timeout string `json:"stop_timeout"`
Swapuse string `json:"swapuse"`
Sync_state string `json:"sync_state"`
Sync_target string `json:"sync_target"`
Sync_tgt_zpool string `json:"sync_tgt_zpool"`
Sysvmsg string `json:"sysvmsg"`
Sysvsem string `json:"sysvsem"`
Sysvshm string `json:"sysvshm"`
Template int `json:"template"`
// Go don't like a variable named "type" (And i dont care about finding a cleaner way)
Jailtype string `json:"type"`
Used string `json:"used"`
Vmemoryuse string `json:"vmemoryuse"`
Vnet int `json:"vnet"`
Vnet0_mac string `json:"vnet0_mac"`
Vnet1_mac string `json:"vnet1_mac"`
Vnet2_mac string `json:"vnet2_mac"`
Vnet3_mac string `json:"vnet3_mac"`
Vnet_default_interface string `json:"vnet_default_interface"`
Vnet_interfaces string `json:"vnet_interfaces"`
Wallclock string `json:"wallclock"`
Writebps string `json:"writebps"`
Writeiops string `json:"writeiops"`
}
2022-04-02 14:17:10 +02:00
// Represent an fstab line
type Mount struct {
Device string
Mountpoint string
Type string
Options []string
Fs_Freq int
Fs_Passno int
}
2021-12-20 22:10:38 +01:00
// This struct hold "sort by jail fields" functions
type lessFunc func(j1 *Jail, j2 *Jail) bool
// Fields in this struct are acquired by their name using reflection
// So these char are forbidden for field name: -+.
//
type JailSort struct {
NameInc lessFunc
NameDec lessFunc
InternalNameInc lessFunc
InternalNameDec lessFunc
JIDInc lessFunc
JIDDec lessFunc
RootPathInc lessFunc
RootPathDec lessFunc
ConfigPathInc lessFunc
ConfigPathDec lessFunc
RunningInc lessFunc
RunningDec lessFunc
ZpoolInc lessFunc
ZpoolDec lessFunc
Config JailConfigSort
}
type JailConfigSort struct {
Config_versionInc lessFunc
Config_versionDec lessFunc
Allow_chflagsInc lessFunc
Allow_chflagsDec lessFunc
Allow_mlockInc lessFunc
Allow_mlockDec lessFunc
Allow_mountInc lessFunc
Allow_mountDec lessFunc
Allow_mount_devfsInc lessFunc
Allow_mount_devfsDec lessFunc
Allow_mount_fusefsInc lessFunc
Allow_mount_fusefsDec lessFunc
Allow_mount_nullfsInc lessFunc
Allow_mount_nullfsDec lessFunc
Allow_mount_procfsInc lessFunc
Allow_mount_procfsDec lessFunc
Allow_mount_tmpfsInc lessFunc
Allow_mount_tmpfsDec lessFunc
Allow_mount_zfsInc lessFunc
Allow_mount_zfsDec lessFunc
Allow_quotasInc lessFunc
Allow_quotasDec lessFunc
Allow_raw_socketsInc lessFunc
Allow_raw_socketsDec lessFunc
Allow_set_hostnameInc lessFunc
Allow_set_hostnameDec lessFunc
Allow_socket_afInc lessFunc
Allow_socket_afDec lessFunc
Allow_sysvipcInc lessFunc
Allow_sysvipcDec lessFunc
Allow_tunInc lessFunc
Allow_tunDec lessFunc
Allow_vmmInc lessFunc
Allow_vmmDec lessFunc
Assign_localhostInc lessFunc
Assign_localhostDec lessFunc
AvailableInc lessFunc
AvailableDec lessFunc
BasejailInc lessFunc
BasejailDec lessFunc
BootInc lessFunc
BootDec lessFunc
BpfInc lessFunc
BpfDec lessFunc
Children_maxInc lessFunc
Children_maxDec lessFunc
Cloned_releaseInc lessFunc
Cloned_releaseDec lessFunc
CommentInc lessFunc
CommentDec lessFunc
CompressionInc lessFunc
CompressionDec lessFunc
CompressratioInc lessFunc
CompressratioDec lessFunc
CoredumpsizeInc lessFunc
CoredumpsizeDec lessFunc
CountInc lessFunc
CountDec lessFunc
CpusetInc lessFunc
CpusetDec lessFunc
CputimeInc lessFunc
CputimeDec lessFunc
DatasizeInc lessFunc
DatasizeDec lessFunc
DedupInc lessFunc
DedupDec lessFunc
DefaultrouterInc lessFunc
DefaultrouterDec lessFunc
Defaultrouter6Inc lessFunc
Defaultrouter6Dec lessFunc
DependsInc lessFunc
DependsDec lessFunc
Devfs_rulesetInc lessFunc
Devfs_rulesetDec lessFunc
DhcpInc lessFunc
DhcpDec lessFunc
Enforce_statfsInc lessFunc
Enforce_statfsDec lessFunc
Exec_cleanInc lessFunc
Exec_cleanDec lessFunc
Exec_createdInc lessFunc
Exec_createdDec lessFunc
Exec_fibInc lessFunc
Exec_fibDec lessFunc
Exec_jail_userInc lessFunc
Exec_jail_userDec lessFunc
Exec_poststartInc lessFunc
Exec_poststartDec lessFunc
Exec_poststopInc lessFunc
Exec_poststopDec lessFunc
Exec_prestartInc lessFunc
Exec_prestartDec lessFunc
Exec_prestopInc lessFunc
Exec_prestopDec lessFunc
Exec_startInc lessFunc
Exec_startDec lessFunc
Exec_stopInc lessFunc
Exec_stopDec lessFunc
Exec_system_jail_userInc lessFunc
Exec_system_jail_userDec lessFunc
Exec_system_userInc lessFunc
Exec_system_userDec lessFunc
Exec_timeoutInc lessFunc
Exec_timeoutDec lessFunc
Host_domainnameInc lessFunc
Host_domainnameDec lessFunc
Host_hostnameInc lessFunc
Host_hostnameDec lessFunc
Host_hostuuidInc lessFunc
Host_hostuuidDec lessFunc
Host_timeInc lessFunc
Host_timeDec lessFunc
HostidInc lessFunc
HostidDec lessFunc
Hostid_strict_checkInc lessFunc
Hostid_strict_checkDec lessFunc
InterfacesInc lessFunc
InterfacesDec lessFunc
Ip4Inc lessFunc
Ip4Dec lessFunc
Ip4_addrInc lessFunc
Ip4_addrDec lessFunc
Ip4_saddrselInc lessFunc
Ip4_saddrselDec lessFunc
Ip6Inc lessFunc
Ip6Dec lessFunc
Ip6_addrInc lessFunc
Ip6_addrDec lessFunc
Ip6_saddrselInc lessFunc
Ip6_saddrselDec lessFunc
Ip_hostnameInc lessFunc
Ip_hostnameDec lessFunc
Jail_zfsInc lessFunc
Jail_zfsDec lessFunc
Jail_zfs_datasetInc lessFunc
Jail_zfs_datasetDec lessFunc
Jail_zfs_mountpointInc lessFunc
Jail_zfs_mountpointDec lessFunc
Last_startedInc lessFunc
Last_startedDec lessFunc
Localhost_ipInc lessFunc
Localhost_ipDec lessFunc
Login_flagsInc lessFunc
Login_flagsDec lessFunc
Mac_prefixInc lessFunc
Mac_prefixDec lessFunc
MaxprocInc lessFunc
MaxprocDec lessFunc
MemorylockedInc lessFunc
MemorylockedDec lessFunc
MemoryuseInc lessFunc
MemoryuseDec lessFunc
Min_dyn_devfs_rulesetInc lessFunc
Min_dyn_devfs_rulesetDec lessFunc
Mount_devfsInc lessFunc
Mount_devfsDec lessFunc
Mount_fdescfsInc lessFunc
Mount_fdescfsDec lessFunc
Mount_linprocfsInc lessFunc
Mount_linprocfsDec lessFunc
Mount_procfsInc lessFunc
Mount_procfsDec lessFunc
MountpointInc lessFunc
MountpointDec lessFunc
MsgqqueuedInc lessFunc
MsgqqueuedDec lessFunc
MsgqsizeInc lessFunc
MsgqsizeDec lessFunc
NatInc lessFunc
NatDec lessFunc
Nat_backendInc lessFunc
Nat_backendDec lessFunc
Nat_forwardsInc lessFunc
Nat_forwardsDec lessFunc
Nat_interfaceInc lessFunc
Nat_interfaceDec lessFunc
Nat_prefixInc lessFunc
Nat_prefixDec lessFunc
NmsgqInc lessFunc
NmsgqDec lessFunc
NotesInc lessFunc
NotesDec lessFunc
NsemInc lessFunc
NsemDec lessFunc
NsemopInc lessFunc
NsemopDec lessFunc
NshmInc lessFunc
NshmDec lessFunc
NthrInc lessFunc
NthrDec lessFunc
OpenfilesInc lessFunc
OpenfilesDec lessFunc
OriginInc lessFunc
OriginDec lessFunc
OwnerInc lessFunc
OwnerDec lessFunc
PcpuInc lessFunc
PcpuDec lessFunc
Plugin_nameInc lessFunc
Plugin_nameDec lessFunc
Plugin_repositoryInc lessFunc
Plugin_repositoryDec lessFunc
PriorityInc lessFunc
PriorityDec lessFunc
PseudoterminalsInc lessFunc
PseudoterminalsDec lessFunc
QuotaInc lessFunc
QuotaDec lessFunc
ReadbpsInc lessFunc
ReadbpsDec lessFunc
ReadiopsInc lessFunc
ReadiopsDec lessFunc
ReleaseInc lessFunc
ReleaseDec lessFunc
ReservationInc lessFunc
ReservationDec lessFunc
ResolverInc lessFunc
ResolverDec lessFunc
RlimitsInc lessFunc
RlimitsDec lessFunc
RtsoldInc lessFunc
RtsoldDec lessFunc
SecurelevelInc lessFunc
SecurelevelDec lessFunc
ShmsizeInc lessFunc
ShmsizeDec lessFunc
StacksizeInc lessFunc
StacksizeDec lessFunc
Stop_timeoutInc lessFunc
Stop_timeoutDec lessFunc
SwapuseInc lessFunc
SwapuseDec lessFunc
Sync_stateInc lessFunc
Sync_stateDec lessFunc
Sync_targetInc lessFunc
Sync_targetDec lessFunc
Sync_tgt_zpoolInc lessFunc
Sync_tgt_zpoolDec lessFunc
SysvmsgInc lessFunc
SysvmsgDec lessFunc
SysvsemInc lessFunc
SysvsemDec lessFunc
SysvshmInc lessFunc
SysvshmDec lessFunc
TemplateInc lessFunc
TemplateDec lessFunc
JailtypeInc lessFunc
JailtypeDec lessFunc
UsedInc lessFunc
UsedDec lessFunc
VmemoryuseInc lessFunc
VmemoryuseDec lessFunc
VnetInc lessFunc
VnetDec lessFunc
Vnet0_macInc lessFunc
Vnet0_macDec lessFunc
Vnet1_macInc lessFunc
Vnet1_macDec lessFunc
Vnet2_macInc lessFunc
Vnet2_macDec lessFunc
Vnet3_macInc lessFunc
Vnet3_macDec lessFunc
Vnet_default_interfaceInc lessFunc
Vnet_default_interfaceDec lessFunc
Vnet_interfacesInc lessFunc
Vnet_interfacesDec lessFunc
WallclockInc lessFunc
WallclockDec lessFunc
WritebpsInc lessFunc
WritebpsDec lessFunc
WriteiopsInc lessFunc
WriteiopsDec lessFunc
}