From d3394f35939815bb5436b7ce4ca07069444bf78c Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Wed, 20 Sep 2023 19:49:49 +0200 Subject: 52163: completion update for OpenZFS 2.2 --- Completion/Unix/Command/_zfs | 109 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 93 insertions(+), 16 deletions(-) (limited to 'Completion/Unix/Command/_zfs') diff --git a/Completion/Unix/Command/_zfs b/Completion/Unix/Command/_zfs index be4a64b33..b1135bfa7 100644 --- a/Completion/Unix/Command/_zfs +++ b/Completion/Unix/Command/_zfs @@ -1,7 +1,8 @@ -#compdef zfs zdb zpool +#compdef zfs zdb zpool zstream local curcontext="$curcontext" implementation nm="$compstate[nmatches]" local -a state curstate line state_descr expl alts args +local -a devices features typeset -A opt_args val_args local MATCH MBEGIN MEND local -a subcmds @@ -13,6 +14,7 @@ local -a ds_types sum_algorithms comp_algorithms dedup_algorithms local -a ds_propnames ro_ds_props rw_ds_props ci_ds_props # dataset properties local -a po_propnames ro_po_props rw_po_props ci_po_props # pool properties +local -a ro_vdev_props rw_vdev_props _pick_variant -r implementation -c 'zpool upgrade -v' openzfs='This system supports ZFS pool feature flags' solaris @@ -98,14 +100,32 @@ rw_ds_props=( 'volsize:size:_numbers -M "m:{a-zA-Z}={A-Za-z}" -u bytes size :B {k,M,G,T,P,E,Z}{,B}' ) +ro_vdev_props=( + capacity state guid asize psize ashift size free allocated expandsize + fragmentation parity devid physpath encpath fru parent children numchildren + read_errors write_errors checksum_errors initialize_errors + null_ops read_ops write_ops free_ops claim_ops trim_ops + null_bytes read_bytes write_bytes free_bytes claim_bytes trim_bytes + removing +) +rw_vdev_props=( + {checksum,io}'_n:number of errors' {checksum,io}'_t:threshold (seconds)' + {comment,bootsize}:value + {allocating,failfast}':value:(on off)' + 'path:device path:_files -g "*(-%)" -P / -W /' +) + case $service:$implementation in *:openzfs) ds_types+=( bookmark ) - sum_algorithms+=( noparity sha512 skein edonr ) + sum_algorithms+=( noparity sha512 skein edonr blake3 ) comp_algorithms+=( zstd zstd-{1..19} zstd-fast zstd-fast-{{1..9}{,0},100,500,1000} ) - dedup_algorithms+=( {sha512,skein}{,\,verify} edonr,verify ) + dedup_algorithms+=( {sha512,skein,blake3}{,\,verify} edonr,verify ) share_rw_properties=( sharesmb:option sharenfs:option ) ro_po_props+=( + 'bcloneratio[block cloning ratio for saved space]' + 'bclonesaved[amount of storage spared by use of block cloning]' + 'bcloneused[amount of storage used by cloned blocks]' 'expandsize[uninitialized space within the pool]' 'fragmentation[amount of fragmentation in the pool]' 'freeing[amount of space remaining to be reclaimed]' @@ -119,6 +139,7 @@ case $service:$implementation in 'autotrim[periodically trim recently freed space]:value:(on off)' 'comment[text string that is available even if the pool becomes faulted]:value' 'multihost[perform pool activity check during import]:value:(on off)' + 'feature@' ) rw_ds_props+=( 'aclmode:value:(discard groupmask passthrough restricted)' @@ -139,7 +160,8 @@ case $service:$implementation in ) ro_ds_props+=( createtxg clones filesystem_count guid logicalreferenced logicalused - receive_resume_token refcompressratio snapshot_count volblocksize written + receive_resume_token refcompressratio snapshot_count snapshots_changed + volblocksize written ) delegatable_perms=( bookmark load-key change-key userobjquota userobjused groupobjquota @@ -257,6 +279,9 @@ case $service:$implementation in list offline online reguid remove replace scrub set split status upgrade ) ;; + zstream:*) + subcmds+=( dump decompress redup token recompress ) + ;; esac case $OSTYPE in @@ -294,9 +319,8 @@ ci_ds_props+=( $rw_ds_props ) ds_propnames=( ${rw_ds_props%%:*} ) po_propnames=( ${ro_po_props%%:*} ${ci_po_props%%:*} ${rw_po_props%%:*} ) - case $service in - zfs|zpool) + zfs|zpool|zstream) _arguments -C -A "-*" \ '-?[display usage information]' \ '*::command:->subcmd' && return 0 @@ -633,7 +657,9 @@ case $service:$words[1] in '(-e --embed)'{-e,--embed}'[more compact stream for blocks stored with the embedded_data feature]' '(-c --compressed)'{-c,--compressed}'[more compact stream for compressed blocks]' '(-h --holds)'{-h,--holds}'[send snapshot holds]' - '-V[set the process title to a per-second report of how much data has been send]' + '(-V --proctitle)'{-V,--proctitle}'[set the process title to a per-second report of how much data has been sent]' + \*{-X,--exclude}'[exclude datasets (with -R)]:dataset:_sequence _zfs_dataset -t fs' + '(-s --skip-missing)'{-s,--skip-missing}'[continue even when snapshots missing in the hierarchy]' '-t[create a send stream that resumes an interrupted receive]:resume token' '(-w --raw)'{-w,--raw}'[keep encrypted data exactly as it exists on disk]' - redact @@ -763,10 +789,10 @@ case $service:$words[1] in zfs:holds) [[ $implementation = openzfs ]] && args=( '-H[suppress printing of headers, tab-delimit columns]' + '-p[use (parsable) numeric output for timestamps]' ) [[ $OSTYPE = freebsd<-12>.* ]] && args+=( # features were lost with the openzfs rebase - '-p[use exact (parsable) numeric output]' '(-r)-d+[depth]:value' ) _arguments -A "-*" -S $args \ @@ -789,6 +815,9 @@ case $service:$words[1] in '-N[enumerate new child datasets (with -r)]' '(1 -e)-E[show difference from empty]' ) + [[ $implementation = openzfs ]] && args=( + "-h[don't"' \\0ooo-escape non-ASCII paths]' + ) _arguments -A "-*" -S $args \ '-F[add column for filetype character, similar to ls(1)]' \ '-H[suppress printing of headers and arrows, tab-delimit columns]' \ @@ -981,8 +1010,10 @@ case $service:$words[1] in '-H[suppress headers and tab-delimit fields]' \ '-p[display numbers in parseable (exact) values]' \ '-o+[specify fields to display]: : _values -s , field name property value source' \ - ':property:_values -s , "property" $po_propnames' \ - '*:pool:_zfs_pool' + ':property:_values -s , "property" $po_propnames ${ro_vdev_props%:*}' \ + ':pool:_zfs_pool' \ + '::vdev:->pool-vdevs-all' \ + '*:pool:_zfs_pool -F line' ;; zpool:history) @@ -1030,9 +1061,10 @@ case $service:$words[1] in _arguments -A "-*" -S \ '(-s --suspend -c --cancel)'{-c,--cancel}'[cancel initializing on specified devices]' \ '(-s --suspend -c --cancel)'{-s,--suspend}'[suspend initializing on specified devices]' \ + '(-u --uninit)'{-u,--uninit}'[clear initialization state on specified devices]' \ '(-w --wait)'{-w,--wait}'[wait until devices have finished initializing before returning]' \ ':pool:_zfs_pool' \ - '*:device:pool-devices' + '*:device:->pool-devices' ;; zpool:iostat) @@ -1165,6 +1197,7 @@ case $service:$words[1] in [[ $implementation = openzfs ]] && args=( '(-s)-p[pause scrubbing]' '-w[wait until scrub has completed before returning]' + '-e[only scrub files with known data errors]' ) _arguments -A "-*" -S $args \ '(-p)-s[stop scrubbing]' \ @@ -1174,7 +1207,8 @@ case $service:$words[1] in zpool:set) _arguments -C -A "-*" -S \ ':property:->set-pool-properties' \ - '*:pool:_zfs_pool' + ':pool:_zfs_pool' \ + ':vdev:->pool-vdevs' ;; zpool:split) @@ -1251,6 +1285,36 @@ case $service:$words[1] in ':interval' ;; + zstream:dump) + _arguments -A "-*" -S \ + '-C[suppress the validation of checksums]' \ + '(-d)-v[print metadata for each record]' \ + '(-v)-d[dump data contained in each record]' \ + ':file:_files' + ;; + + zstream:token) + _message -e tokens 'resume token' + ;; + + zstream:decompress) + _arguments -A "-*" -S \ + '-v[print summary of decompressed records]' \ + '*:offset' + ;; + + zstream:redup) + _arguments -A "-*" -S \ + '-v[print summary of converted records]' \ + ':file:stream file' + ;; + + zstream:recompress) + _arguments -A "-*" -S \ + '-l+[specify compression level]:level' \ + '*:algorithm:compadd -a comp_algorithms' + ;; + *) _default ;; @@ -1259,6 +1323,7 @@ esac while (( $#state )); do curstate=$state state=() + devices=() case $curstate in virtual-devices) local -a vdevtypes @@ -1278,8 +1343,15 @@ while (( $#state )); do _alternative $alts 'file-vdevs:file vdev:_files -W / -P /' ;; + pool-vdevs-all) devices=( all-vdevs ) ;& + pool-vdevs) # same as pool-devices but on OpenZFS 2.2+ only features + # path field is also valid + devices+=( $(_call_program devices zpool get -H -o name state $line[CURRENT-2] all-vdevs) ) + _description devices expl "$state_descr" + compadd "$expl[@]" -a devices + ;; + pool-devices) - local -a devices devices=( ${${${(M)${(f)"$(_call_program devices zpool status $line[1])"}:#$'\t' *}##[[:blank:]]#}%%[[:blank:]]*} ) if (( $#devices )); then _description devices expl "$state_descr" @@ -1321,12 +1393,13 @@ while (( $#state )); do create-properties) args=( $ci_ds_props ) ;| set-properties) args=( $rw_ds_props ) ;| newpool-properties) args=( $rw_po_props $ci_po_props ) ;| - set-pool-properties) args=( $rw_po_props ) ;| + set-pool-properties) args=( $rw_po_props $rw_vdev_props ) ;| *-properties) if compset -P 1 '(#m)*@'; then if compset -P 1 '*='; then case $MATCH in + *feature@) _wanted states expl state compadd active enabled disabled ;; *quota@) _alternative \ 'sizes: :_numbers -M "m\:{a-zA-Z}={A-Za-z}" -u bytes size \:B {k,M,G,T,P,E,Z}{,B}' \ 'properties:property:(none)' @@ -1334,8 +1407,12 @@ while (( $#state )); do esac else case $MATCH in - user*@) _users -S = ;; - group*@) _groups -S = ;; + feature@) + features=( ${${${${${(f)"$(_call_program features zpool upgrade -v)"}[(r)---*,(R)VER *]}[2,-3]}:# *}%% *} ) + _wanted features expl feature compadd -qS= -a features + ;; + user*@) _users -qS= ;; + group*@) _groups -qS= ;; project*@) _message -e projects project ;; esac fi -- cgit v1.2.3 From 5fd8cccf54e8bda291b8f45ca9dacfa4205a1ced Mon Sep 17 00:00:00 2001 From: Christian Heusel Date: Fri, 13 Oct 2023 21:31:54 +0200 Subject: github #103: fix completion for zpool upgrade This is done by simply adding a missing backslash to the code. Fixes: 85bf9740a0 ("49668: update zfs completion") Signed-off-by: Christian Heusel --- ChangeLog | 5 +++++ Completion/Unix/Command/_zfs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'Completion/Unix/Command/_zfs') diff --git a/ChangeLog b/ChangeLog index 323ae074d..e37c0057c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2023-10-24 Matthew Martin + + * github #103: Christian Heusel: Completion/Unix/Command/_zfs: fix + completion for zpool upgrade + 2023-10-16 Mikael Magnusson * 52056: Completion/Unix/Command/_sccs: _sccs: don't handle diff --git a/Completion/Unix/Command/_zfs b/Completion/Unix/Command/_zfs index b1135bfa7..3265e1eb8 100644 --- a/Completion/Unix/Command/_zfs +++ b/Completion/Unix/Command/_zfs @@ -1269,7 +1269,7 @@ case $service:$words[1] in zpool:upgrade) _arguments -A "-*" -S \ - '(- *)-v[display ZFS versions and descriptions]' + '(- *)-v[display ZFS versions and descriptions]' \ "(-v)-V+[upgrade to given version]:version" \ '(-v *)-a[upgrade all pools]' \ '(-a -v)*:pool:_zfs_pool' -- cgit v1.2.3 From 8f0a8131fad30c627d72f24a6a88ac0053cd3790 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Fri, 17 Nov 2023 18:25:21 +0100 Subject: 52307: new completion for many SELinux tools --- ChangeLog | 7 + Completion/Linux/Command/_chcon | 24 - Completion/Linux/Command/_selinux | 781 ++++++++++++++++++++++++++++++++ Completion/Linux/Command/_setpriv | 2 +- Completion/Linux/Type/_selinux_contexts | 13 +- Completion/Linux/Type/_selinux_types | 16 +- Completion/Unix/Command/_cp | 2 +- Completion/Unix/Command/_find | 4 +- Completion/Unix/Command/_install | 2 +- Completion/Unix/Command/_mount | 6 +- Completion/Unix/Command/_zfs | 2 +- 11 files changed, 821 insertions(+), 38 deletions(-) delete mode 100644 Completion/Linux/Command/_chcon create mode 100644 Completion/Linux/Command/_selinux (limited to 'Completion/Unix/Command/_zfs') diff --git a/ChangeLog b/ChangeLog index 5b50aa342..09b854e54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2023-11-17 Oliver Kiddle + * 52307: Completion/Linux/Command/_selinux, + Completion/Linux/Command/_chcon, Completion/Linux/Command/_setpriv, + Completion/Linux/Type/_selinux_contexts, Completion/Unix/Command/_cp, + Completion/Linux/Type/_selinux_types, Completion/Unix/Command/_find, + Completion/Unix/Command/_install, Completion/Unix/Command/_mount, + Completion/Unix/Command/_zfs: new completion for many SELinux tools + * 52303: Completion/Unix/Command/_ifconfig, Completion/Unix/Command/_chown, Completion/Unix/Command/_cp, Completion/Unix/Command/_cut, Completion/Unix/Command/_date, diff --git a/Completion/Linux/Command/_chcon b/Completion/Linux/Command/_chcon deleted file mode 100644 index 2d523f287..000000000 --- a/Completion/Linux/Command/_chcon +++ /dev/null @@ -1,24 +0,0 @@ -#compdef chcon - -local ign - -(( $#words > 2 )) && ign='!' -_arguments -C -s -S \ - '(-h --no-dereference)--dereference[dereference symlinks]' \ - '(-h --no-dereference --dereference)'{-h,--no-dereference}'[operate on symlinks themselves]' \ - '(1 -u --user -r --role -l --range -t --type)--reference=[copy security context of specified file]:file:_files' \ - '(1 --reference -u --user)'{-u+,--user=}'[set user in the target security context]: :_selinux_users' \ - '(1 --reference -r --role)'{-r+,--role=}'[set role in the target security context]: :_selinux_roles' \ - '(1 --reference -t --type)'{-t+,--type=}'[set type in the target security context]: :_selinux_types' \ - '(1 --reference -l --range)'{-l+,--range=}'[set range in the target security context]:selinux range' \ - '(--recursive -R)'{--recursive,-R}'[recurse subdirectories]' \ - '(-v --verbose)'{-v,--verbose}'[output a diagnostic for every file processed]' \ - '(-H -L -P)-H[follow symlinks on the command line]' \ - '(-H -L -P)-L[follow all symlinks]' \ - "(-H -L -P)-P[don't follow symlinks (default)]" \ - '!(--preserve-root)--no-preserve-root' \ - "--preserve-root[fail to operate recursively on '/']" \ - '(--reference -u --user -r --role -l --range -t --type)1:security context:_selinux_contexts' \ - "${ign}--help[display help information]" \ - "${ign}--version[display version information]" \ - '*:file:_files' diff --git a/Completion/Linux/Command/_selinux b/Completion/Linux/Command/_selinux new file mode 100644 index 000000000..e7d4d3b2e --- /dev/null +++ b/Completion/Linux/Command/_selinux @@ -0,0 +1,781 @@ +#compdef audit2allow audit2why avcstat chcon checkmodule checkpolicy fixfiles getpidprevcon getsebool matchpathcon restorecon runcon sealert secon sedta seinfo selinuxconlist selinuxdefcon selinuxexeccon semanage semodule semodule_unpackage sepolgen sepolicy sesearch sestatus setenforce setsebool validatetrans + +# encompasses checkpolicy libselinux-utils policycoreutils +# policycoreutils-devel policycoreutils-python-utils setools-console +# setools-console-analyses setroubleshoot-server and a few utilities from +# coreutils + +_selinux_attributes() { + local -a seattrs expl + + seattrs=( ${(f)"$(_call_program selinux-attributes seinfo --flat -a)"} ) + _description selinux-attrs expl "selinux attribute" + compadd "$@" "$expl[@]" -a seattrs +} + +_selinux_bools() { + local -a sebools expl + + sebools=( ${(f)"$(_call_program selinux-bools seinfo --flat -b)"} ) + _description selinux-bools expl "selinux boolean" + compadd "$@" "$expl[@]" -a sebools +} + +_selinux_categories() { + local -a secats expl + + secats=( ${(f)"$(_call_program selinux-categories seinfo --flat --category)"} ) + _description selinux-categories expl "selinux category" + compadd "$@" "$expl[@]" -a secats +} + +_selinux_classes() { + local -a seclasses expl + + seclasses=( ${(f)"$(_call_program selinux-classes seinfo --flat -c)"} ) + _description selinux-classes expl "selinux object class" + compadd "$@" "$expl[@]" -a seclasses +} + +_selinux_commons() { + local -a secommons expl + + secommons=( ${(f)"$(_call_program selinux-commons seinfo --flat --common)"} ) + _description selinux-commons expl "selinux common permission set" + compadd "$@" "$expl[@]" -a secommons +} + +_selinux_interfaces() { + local -a seints expl + + seints=( ${(f)"$(_call_program selinux-interfaces sepolicy interface -l)"} ) + _description selinux-interfaces expl "selinux interface" + compadd "$@" "$expl[@]" -a seints +} + +_selinux_permissions() { + local -a seperms expl + + seperms=( ${${${${(f)"$(_call_program selinux-permissions seinfo -c --flat -x)"}:#[^[:blank:]]*}#[[:blank:]]}:1} ) + _description selinux-permissions expl "selinux permission" + compadd "$@" "$expl[@]" -a seperms +} + +_selinux_sids() { + local -a sesids expl + + sesids=( ${(f)"$(_call_program selinux-sids seinfo --flat --initialsid)"} ) + _description selinux-sids expl "selinux SID" + compadd "$@" "$expl[@]" -a sesids +} + +_selinux_sens() { + local -a sens expl + + sesids=( ${(f)"$(_call_program selinux-sens seinfo --flat --initialsid)"} ) + _description selinux-sensitivities expl "selinux sensitivity" + compadd "$@" "$expl[@]" -a sesids +} + +_selinux_modules() { + local -a modules expl + + modules=( ${(f)"$(_call_program selinux-modules semodule -l)"} ) + _description selinux-modules expl "selinux module" + compadd "$@" "$expl[@]" -a modules +} + +local curcontext="$curcontext" ret=1 +local -A opt_args +local -a args sepolgen state state_descr line +local ign +(( $#words > 2 )) && ign='!' + +sepolgen=( + "${ign}(-h --help)"{-h,--help}'[display help information]' + '(--application --cgi --dbus --inetd --init --admin_user --confined_admin --desktop_user --newtype --sandbox --x_user)'*{-d+,--domain=}'[specify domain to expand]:domain:_selinux_types -a domain' + \*{-r+,--role=}'[specify role(s) to which the administrator domain will transition]: :_selinux_roles' + \*{-u+,--user=}'[specify SELinux user(s) which will transition to this domain]: :_selinux_users' + \*{-a+,--admin=}'[specify domain(s) which this confined admin will administrate]:admin domain:_selinux_types' + '(-n --name)'{-n+,--name=}'[specify name of policy to generate]:name' + '(--admin_user --confined_admin --desktop_user --newtype --sandbox --x_user)*'{-t+,--type=}'[specify type(s) for which you will generate new definition and rule(s)]:type:_selinux_types' + '(-p --path)'{-p+,--path=}'[specify path in which the generated policy files will be stored]:path:_directories' + '(--newtype)*'{-w+,--writepath=}'[specify path to which the confined processes will need to write]:path:_directories' + '1:command:_files' + + '(application)' + "(-d)--application[generate 'User Application' policy]" + "(-d)--cgi[generate 'Web Application/Script (CGI)' policy]" + "(-d)--dbus[generate 'DBUS System Daemon' policy]" + "(-d)--inetd[generate 'Internet Services Daemon' policy]" + "(-d)--init[generate 'Standard Init Daemon' policy]" + "(-d -t 1)--admin_user[generate 'Administrator Login User Role' policy]" + "(-d -t 1)--confined_admin[generate 'Confined Root Administrator Role' policy]" + "(1)--customize[generate 'Existing Domain Type' policy]" + "(-d -t 1)--desktop_user[generate 'Desktop Login User Role' policy]" + "(-d -w 1)--newtype[generate 'Module information for a new type' policy]" + "(-d -t 1)--sandbox[generate 'Sandbox' policy]" + "(-d -t 1)--term_user[generate 'Minimal Terminal Login User Role' policy]" + "(-d -t 1)--x_user[generate 'Minimal X Windows Login User Role' policy]" +) + +case $service in + check(module|policy)) + args=( + '(-b --binary)'{-b,--binary}'[read an existing binary policy file rather than a source policy.conf file]' + '(-C --cil)'{-C,--cil}'[write CIL policy file rather than binary policy file]' + '(-E --werror)'{-E,--werror}'[treat warnings as errors]' + "${ign}(-h --help)"{-h,--help}'[display help information]' + '(-U --handle-unknown)'{-U+,--handle-unknown=}'[specify how the kernel should handle unknown classes or permissions]:action:(deny allow reject)' + '(-M --mls)'{-M,--mls}'[enable the MLS policy when checking and compiling the policy]' + '(-o --output)'{-o+,--output=}'[write a policy file]:file:_files' + '-c+[specify the policy version]:policy version [latest]' + ':input file:_files' + ) + ;| + + audit2(allow|why)) + args=( + '(-b --boot -i --input)'{-b,--boot}'[audit messages since last boot]' + '(-a --all -i --input -d --dmesg)'{-a,--all}'[read input from audit log]' + '(-p --policy)'{-p+,--policy=}'[specify policy file to use for analysis]:file:_files' + '(-d --dmesg -a --all -i --input)'{-d,--dmesg}'[read input from dmesg]' + '(-i --input -a --all -b --boot)'{-i+,--input=}'[read input from file]:file:_files' + '(-l --lastreload)'{-l,--lastreload}'[read input only after the last reload]' + '(-r --requires)'{-r,--requires}'[generate require statements for rules]' + '(-m --module -M --module-package -r --requires)'{-m+,--module=}'[set the module name]:module name:_selinux_modules' + '(-M --module-package -o --output -m --module)'{-M+,--module-package=}'[generate a module package]:module package:_files' + '(-o --output -M --module-package)'{-o+,--output=}'[append output to file]:file:_files' + '(-D --dontaudit)'{-D,--dontaudit}'[generate policy with dontaudit rules]' + '(-R --reference)'{-R,--reference}'[use installed macros in generated policy]' + '!(-R --reference -N --noreference)'{-N,--noreference} + '(-v --verbose)'{-v,--verbose}'[explain generated output]' + '(-e --explain)'{-e,--explain}'[fully explain generated output]' + '(-t --type)'{-t+,--type=}'[only process messages with type matching regex]:type' + '--perm-map=[specify file name of perm map]:file:_files' + '--interface-info=[specify file name of interface information]:file:_files' + '(-x --xperms)'{-x,--xperms}'[generate extended permission rules]' + '--debug[leave generated modules for -M]' + '(-w --why)'{-w,--why}'[translate SELinux audit messages into a description of why the access was denied]' + "${ign}(-h --help)"{-h,--help}'[display help information]' + "${ign}--version[display version information]" + ) + ;; + + avcstat) + args=( + '-c[cumulative]' + '-f+[specify AVC statistics file]:file [/sys/fs/selinux/avc/cache_stats]:_files' + ': :_guard "^-*" "interval (seconds)"' + ) + ;; + + chcon) + args=( -S + '(-h --no-dereference)--dereference[dereference symlinks]' \ + '(-h --no-dereference --dereference)'{-h,--no-dereference}'[operate on symlinks themselves]' \ + '(1 -u --user -r --role -l --range -t --type)--reference=[copy security context of specified file]:file:_files' \ + '(1 --reference -u --user)'{-u+,--user=}'[set user in the target security context]: :_selinux_users' \ + '(1 --reference -r --role)'{-r+,--role=}'[set role in the target security context]: :_selinux_roles' \ + '(1 --reference -t --type)'{-t+,--type=}'[set type in the target security context]: :_selinux_types' \ + '(1 --reference -l --range)'{-l+,--range=}'[set range in the target security context]:selinux range' \ + '(--recursive -R)'{--recursive,-R}'[recurse subdirectories]' \ + '(-v --verbose)'{-v,--verbose}'[output a diagnostic for every file processed]' \ + '(-H -L -P)-H[follow symlinks on the command line]' \ + '(-H -L -P)-L[follow all symlinks]' \ + "(-H -L -P)-P[don't follow symlinks (default)]" \ + '!(--preserve-root)--no-preserve-root' \ + "--preserve-root[fail to operate recursively on '/']" \ + '(--reference -u --user -r --role -l --range -t --type)1:security context:_selinux_contexts' \ + "${ign}--help[display help information]" \ + "${ign}--version[display version information]" \ + '*:file:_files' + ) + ;; + + checkmodule) + args=( + "${ign}(-)"{-V,--version}'[show policy versions created by this program]' + '-m[build a policy module instead of a base module]' + '-c+[build a policy module targeting a modular policy version]:version (4-21)' + ) + ;; + + checkpolicy) + args=( + '(-F --conf)'{-F,--conf}'[write policy.conf file rather than binary policy file]' + '(-d --debug)'{-d,--debug}'[enter debug mode after loading the policy]' + '(-S --sort)'{-S,--sort}'[sort ocontexts before writing out the binary policy]' + '(-t --target)'{-t+,--target=}'[specify the target platform]:platform:(selinux xen)' + '(-O --optimize)'{-O,--optimize}'[optimize the final kernel policy (remove redundant rules)]' + "${ign}(-)"{-V,--version}'[display version information]' + ) + ;; + + fixfiles) + args=( + '-B[record current date in /.autorelabel to speed later labeling]' + '-F[force reset of context to match file_context for customizable files]' + '-f[clear /tmp directory without prompt for removal]' + '-R+[discover files from specified rpm packages]:package' + '-C+[run a diff on the specified file]:file:_files' + '-N+[only act on files created after the specified date]:date (YYYY-MM-DD HH\:MM):_dates' + '-v[show changes in file labels]' + '-T+[specify number of threads to use]:threads' + '1::action:(check verify restore relabel onboot)' + '*:file:_files' + ) + ;; + + getpidprevcon) + _pids + return + ;; + + getsebool) + args=( + '(:)-a[show all booleans]' + '(-a):boolean:_selinux_bools' + ) + ;; + + matchpathcon) + args=( + '-m+[force file type for the lookup]:type:(file dir pipe chr_file blk_file lnk_file sock_file)' + "-n[don't display path]" + "-N[don't use translations]" + '-f+[use alternate file_context file]:file:_files' + '-p+[use prefix to speed translations]:prefix' + '-P+[use alternate policy root path]:path:_directories' + '-V[verify file context on disk matches defaults]' + '*:file path:_files' + ) + ;; + + restorecon) + args=( + '*-e+[exclude a directory]:directory:_directories' + '-f+[provide list of files to be processed]:file:_files' + '-F[force reset of context to match file_context for customizable files]' + "-i[ignore files that don't exist]" + '-I[ignore digest to force checking of labels even if SHA256 digest matches]' + '-D[set or update any directory SHA256 digests]' + '-m[include non-seclabel mounts in relabeling checks]' + "-n[don't change any file labels (passive check)]" + '(-v)-p[show progress]' + '(-R -r)'{-R,-r}'[change file labels recursively]' + '(-p)-v[show changes in file labels]' + '-W[display warnings about entries that had no matching files]' + '-0[expect NUL characters as input filename separators]' + "-x[don't cross file system boundaries]" + '-T+[specify number of threads to use]:threads' + "${ign}(-)"{-h,-\?}'[display help information]' + '*:file path:_files' + ) + ;; + + runcon) + args=( + '(1 -c --compute)'{-c,--compute}'[compute process transition context before modifying]' + '(1 -t --type=TYPE)'{-t+,--type=}'[specify type]: :_selinux_types' + '(1 -u --user=USER)'{-u+,--user=}'[specify user identity]: :_selinux_users' + '(1 -r --role=ROLE)'{-r+,--role=}'[specify role]: :_selinux_roles' + '(1 -l --range=RANGE)'{-l+,--range=}'[specify level range]:range' + '(-)1:security context:_selinux_contexts' + '*:::args:_normal' + ) + ;; + + sealert) + args=( + '(-b --browser)'{-b,--browser}'[launch the browser]' + '(-s --service -S --noservice)'{-s,--service}'[start sealert as a dbus service]' + '(-S --noservice -s --service)'{-S,--noservice}'[start sealert without dbus service as standalone app]' + '(-l --lookupid)'{-l+,--lookupid=}'[lookup alert by id, id may be wildcard * to lookup all alerts]:id' + '(-a --analyze)'{-a+,--analyze=}'[scan a log file, analyze its AVCs]:log file:_files' + '(-u --user)'{-u+,--user=}'[logon user name]:username' + '(-p --password)'{-p+,--password=}'[logon user password]:password' + '(-P --plugin)'{-P+,--plugin=}'[specify plugin name, required for -f]:plugin name' + '(-f --fix)'{-f+,--fix=}'[fix avc with the given uuid, requires plugin]:uuid' + "${ign}(-)"{-h,--help}'[display help information]' + ) + ;; + + secon) + args=( + "${ign}(-)"{-h,--help}'[display help information]' + "${ign}(-)--version[display version information]" + '(-P --prompt)'{-P,--prompt}'[output in a format good for a prompt]' + '(-u --user)'{-u,--user}'[show user of the context]' + '(-r --role)'{-r,--role}'[show role of the context]' + '(-t --type)'{-t,--type}'[show type of the context]' + '(-s --sensitivity)'{-s,--sensitivity}'[show sensitivity level of the context]' + '(-c --clearance)'{-c,--clearance}'[show clearance level of the context]' + '(-m --mls-range)'{-m,--mls-range}'[show sensitivity to clearance range of]' + '(-R --raw)'{-R,--raw}'[output context in "raw" format]' + '(-C --color)'{-C,--color}'[output using ANSI color codes (requires -P)]' + + '(context)' + {--self,--current}'[get context for the current process]' + {--self-exec,--current-exec}'[get exec context for the current process]' + {--self-fs,--current-fs}'[get fs context for the current process]' + {--self-key,--current-key}'[get key context for the current process]' + '--parent[get context for the parent process]' + '--parent-exec[get exec context for the parent process]' + '--parent-fs[get fs context for the parent process]' + '--parent-key[get key context for the parent process]' + {-p+,--pid=}'[context from the specified pid]:pid:_pids' + '--pid-exec[use exec context from the specified pid]:pid:_pids' + '--pid-fs[use fs context from the specified pid]:pid:_pids' + '--pid-key[use key context from the specified pid]:pid:_pids' + {-f+,--file=}'[use context from the specified file]:file:_files' + {-L+,--link=}"[use context from the specified file, doesn't follow symlinks]:file:_files" + ':context:_selinux_contexts' + ) + ;; + + sedta) + args=( + '(-p --policy)'{-p+,--policy=}'[specify path to SELinux policy to analyze]:policy:_files' + '(-s --source)'{-s+,--source=}'[specify source type of the analysis]:source:_selinux_types -a domain' + '(-t --target)'{-t+,--target=}'[specify target type of the analysis]:target:_selinux_types -a domain' + '--full[print rule lists for transitions]' + '--stats[display statistics at the end of the analysis]' + '(-v --verbose)'{-v,--verbose}'[extra informational messages]' + '--debug[enable debugging]' + '(-S --shortest_path)'{-S,--shortest_path}'[calculate all shortest paths]' + '(-A --all_paths)'{-A+,--all_paths=}'[calculate all paths]:max steps' + '(-r --reverse)'{-r,--reverse}'[perform a reverse DTA]' + '(-l --limit_trans)'{-l+,--limit_trans=}'[limit to the specified number of transitions]:limit' + '*:excluded domain:_selinux_types -a domain' + "${ign}(- *)"{-h,--help}'[display help information]' + "${ign}(-)--version[display version information]" + ) + ;; + + seinfo) + args=( + '(-a --attribute)'{-a,--attribute}'[list attributes or print named attribute]:: :_selinux_attributes' + '(-b --bool)'{-b,--bool}'[list booleans or print named boolean]:: :_selinux_bools' + '(-c --class)'{-c,--class}'[list object classes or print named object class]:: :_selinux_classes' + '(-r --role)'{-r,--role}'[list roles or print named role]:: :_selinux_roles' + '(-t --type)'{-t,--type}'[list types or print named type]:: :_selinux_types' + '(-u --user)'{-u,--user}'[list users or print named user]:: :_selinux_users' + '--category[list categories or print named category]:: :_selinux_categories' + '--common[list common permission sets or print named common]:: :_selinux_commons' + '--constrain[list constraints or print constraints for named object class]:: :_selinux_classes' + '--default[list default_* statements or print statements for named object class]:: :_selinux_classes' + '--fs_use[list fs_use_* statements or print statements for named filesystem type]:: :_file_systems' + '--genfscon[list genfscon statements or print statements for named filesystem type]:: :_file_systems' + '--initialsid[list initial SIDs or print named SID]:: : _selinux_sids' + '--netifcon[list netif contexts or print for named interface]:: : _net_interfaces' + '--nodecon[list node contexts or print statement for node with specified address]::address' + '--permissive[list permissive types or print named statement]::type' + '--polcap[list policy capabilities or print named statement]::type' + '--portcon[list port contexts or print statements for port range]::port range' + '--sensitivity[list sensitivities or print named sensitivity]:: :_selinux_sens' + '--typebounds[list type bounds or print named bound type]:: :_selinux_typebounds' + '--validatetrans[list validatetrans rules or print constraints for named object class]:: :_selinux_classes' + '--all[list all components]' + '(-x --expand)'{-x,--expand}'[print additional details]' + '--flat[exclude headers and indentation in output]' + '(-v --verbose)'{-v,--verbose}'[print additional informational messages]' + '--debug[enable debugging output]' + "${ign}--help[display help information]" + "${ign}--version[display version information]" + ':policy:_files' + ) + ;; + + selinuxconlist) + args=( + '-l+[specify mcs/mls level]:level' + ':user:_selinux_users' + ':context:_selinux_contexts' + ) + ;; + + selinuxdefcon) + args=( + '-l+[specify mcs/mls level]:level' + ':user:_users' + ':context:_selinux_contexts' + ) + ;; + + selinuxexeccon) + args=( + '1:command:_files -g "*(-*)"' + '2:from context:_selinux_contexts' + ) + ;; + + semanage) + _arguments -C \ + {-h,--help}'[display help information]' \ + ': :->command' \ + '*::: := ->option-or-argument' && ret=0 + + case $state in + command) + local -a subcmds + + subcmds=( + import:'import local customizations' + export:'output local customizations' + login:'manage login mappings between linux users and SELinux confined users' + user:'manage SELinux confined users (Roles and levels for an SELinux user)' + port:'manage network port type definitions' + interface:'manage network interface type definitions' + module:'manage SELinux policy modules' + node:'manage network node type definitions' + fcontext:'manage file context mapping definitions' + boolean:'manage booleans to selectively enable functionality' + permissive:'manage process type enforcement mode' + dontaudit:'disable/enable dontaudit rules in policy' + ibpkey:'manage infiniband pkey type definitions' + ibendport:'manage infiniband end port type definitions' + ) + + _describe -t commands command subcmds + return + ;; + option-or-argument) + (( $#words > 2 )) && ign='!' || ign='' + curcontext=${curcontext%:*}-$line[1]: + args=( + "${ign}(-)"{-h,--help}'[display help information]' + '(-S --store)'{-S+,--store=}'[select an alternate SELinux Policy Store to manage]:store:_files' + ) + + case $line[1] in + ^export) + args+=( '(-N --noreload)'{-N,--noreload}"[don't reload policy after commit]" ) + ;| + boolean|fcontext|ibendport|ibpkey|interface|login|module|node|port|user) + args+=( '(-C --locallist)'{-C,--locallist}'[list local customizations]' ) + ;| + boolean|fcontext|ibendport|ibpkey|interface|login|module|node|permissive|port|user) + args+=( + '(-n --noheading)'{-n,--noheading}"[don't print list heading]" + '(-l --list)'{-l,--list}'[list records]' + '(-E --extract)'{-E,--extract}'[extract customizable commands, for use within a transaction]' + ) + ;| + boolean|dontaudit|export|import) + args+=( '(-a --add)'{-a,--add}'[add a record]' ) + ;| + boolean|fcontext|ibendport|ibpkey|interface|login|node|permissive|port|user) + args+=( + '(-d --delete)'{-d,--delete}'[delete a record]' + '(-D --deleteall)'{-D,--deleteall}'[remove all local customizations]' + ) + ;| + boolean|fcontext|ibendport|ibpkey|interface|login|node|port|user) + args+=( '(-m --modify)'{-m,--modify}'[modify a record]' ) + ;| + fcontext|login) + args+=( '(-s --seuser)'{-s+,--seuser=}'[SELinux user name]:seuser:_selinux_users' ) + ;| + fcontext|ibendport|ibpkey|interface|node|port) + args+=( '(-t --type)'{-t+,--type=}'[SELinux Type for the object]:type:_selinux_contexts -a file_type' ) + ;| + fcontext|ibendport|ibpkey|interface|login|node|port|user) + args+=( '(-r --range)'{-r+,--range=}'[specify MLS/MCS Security Range]:range' ) + ;| + + import) + args+=( '(-f --input_file)'{-f+,--input_file=}'[specify input file]:input file:_files' ) + ;; + export) + args+=( '(-f --output_file)'{-f+,--output_file=}'[specify output file]:output_file' ) + ;; + login) + args+=( '(-l --list)1: :{ compset -P % && _groups || _users }' ) + ;; + user) + args+=( + '(-L --level)'{-L,--level}'[default SELinux Level for SELinux user, s0 Default. (MLS/MCS Systems only)]:level' + \*{-R,--roles}'[specify SELinux Roles]:roles:_selinux_roles' + ': :_selinux_users' + ) + ;; + port) + args+=( + '(-p --proto)'{-p+,--proto=}'[specify protocol for the specified port]:protocol:(tcp udp dccp sctp)' + ': :_ports' + ) + ;| + interface) + args+=( ': :_selinux_interfaces' ) + ;; + module) + args+=( + '(-P --priority)'{-P+,--priority=}'[select a priority for module operations]:priority [400]' + '(-E --extract)'{-E,--extract}'[extract customizable commands, for use within a transaction]' + '(-a --add)'{-a,--add}'[add a module]:module name:_selinux_modules' + '(-r --remove)'{-r,--remove}'[remove a module]:module name:_selinux_modules' + '(-d --disable)'{-d,--disable}'[disable a module]:module name:_selinux_modules' + '(-e --enable)'{-e,--enable}'[enable a module]:module name:_selinux_modules' + ) + ;; + node) + args+=( + '(-p --proto)'{-p+,--proto=}'[specify protocol for the specified node]:protocol:(ipv4 ipv6)' + '(-M --netmask)'{-M+,--netmask=}'[specify network mask]:netmask' + ':node:' + ) + ;; + fcontext) + args+=( + '(-e --equal)'{-e+,--equal=}'[substitute target path with sourcepath when generating default label]:equal' + '(-f --ftype)'{-f+,--ftype=}'[specify file type]:file type:(( + f\:regular\ file + d\:directory + c\:character\ device + b\:block device + s\:socket + l\:symbolic\ link + p\:named\ pipe))' + ':file spec (regex):_files' + ) + ;; + boolean) + args+=( + '(-)'{-1,--on}'[enable]' + '(-)'{-0,--off}'[disable]' + ':boolean:_selinux_bools' + ) + ;; + permissive) + args+=( '1:type:_selinux_types' ) + ;; + dontaudit) + args+=( '1:value:(on off)' ) + ;; + ibpkey) + args+=( + '(-x --subnet_prefix)'{-x,--subnet_prefix}'[specify subnet prefix for the specified infiniband ibpkey]:subnet prefix' + ':pkey:' + ) + ;; + ibendport) + args+=( + '(-z --ibdev_name)'{-z+,--ibdev_name=}'[specify name for the specified infiniband end port]:ibdev name' + ) + ;; + esac + ;; + esac + ;; + + semodule) + args=( + \*{-R,--reload}'[force a reload of policy]' + \*{-B,--build}'[build and reload policy]' + \*'--refresh[like --build but reuse existing linked policy if module files unchanged]' + \*{-D,--disable_dontaudit}'[remove dontaudits from policy]' + \*{-i+,--install=}'[install a new module]:module package:_files -g "*.pp(-.)"' + \!{-b,--base,-u,--upgrade}':module package:_files -g "*.pp(-.)"' + \*{-r+,--remove=}'[remove existing module at desired priority]:module name:_selinux_modules' + \*{-l+,--list-modules=-}'[display list of installed modules]::kind:(( + standard\:highest\ priority,\ enabled\ modules + full\:list\ all\ modules + ))' + \*{-X+,--priority=}'[set priority for following operations]:priority (1-999)' + \*{-e,--enable=}'[enable module]:module name:_selinux_modules' + \*{-d,--disable=}'[disable module]:module name:_selinux_modules' + \*{-E,--extract=}'[extract module]:module name:_selinux_modules' + '(-s --store)'{-s+,--store=}'[name of the store to operate on]:store' + '(-N -n --noreload)'{-N,-n,--noreload}"[don't reload policy after commit]" + '(-v --verbose)'{-v,--verbose}'[be verbose]' + '(-P --preserve_tunables)'{-P,--preserve_tunables}'[preserve tunables in policy]' + '(-C --ignore-module-cache)'{-C,--ignore-module-cache}'[rebuild CIL modules compiled from HLL files]' + '(-p --path)'{-p,--path}'[use an alternate path for the policy root]' + '(-S --store-path)'{-S+,--store-path=}'[use an alternate path for the policy store root]:path:_directories' + '(-c --cil)'{-c,--cil}'[extract module as cil; only affects module extraction]' + '(-H --hll)'{-H,--hll}'[extract module as hll; only affects module extraction]' + '(-m --checksum)'{-m,--checksum}'[add SHA256 checksum of modules to the list output]' + '!(--refresh)--rebuild-if-modules-changed' + "${ign}(-)"{-h,--help}'[display help information]' + ) + ;; + + semodule_unpackage) + args=( + ':pp file:_files -g "*.pp(-.)"' + ':mod file:_files -g "*.mod(-.)"' + ':fc file:_files -g "*.fc(-.)"' + ) + ;; + + sepolgen) + args=( $sepolgen ) + ;; + sepolicy) + _arguments -C \ + '-P+[specify policy to examine]' \ + "${ign}(- 1)-h[display help information]" \ + '1:command:(( + booleans\:"get description of booleans" + communicate\:"query if domains can communicate with each other" + generate\:"generate policy module template" + gui\:"graphical user interface for policies" + interface\:"list policy interfaces" + manpage\:"generate man pages for policies" + network\:"query policy network information" + transition\:"query policy to see how a source process domain can transition to the target process domain"))' \ + '*::: := ->option-or-argument' && ret=0 + case $state in + option-or-argument) + curcontext=${curcontext%:*}-$line[1]: + args=( '(-)'{-h,--help}'[display help information]' ) + case $line[1] in + transition|communicate) + args+=( + '(-s --source)'{-s+,--source=}'[specify source domain]:source:_selinux_types -a domain' + '(-t --target)'{-t+,--target=}'[specify target domain]:target:_selinux_types -a domain' + ) + ;| + manpage|network) + args+=( + {-d,--domain}'[specify domain]:*: :_selinux_types -a domain' + '!*'{-d-,--domain=-}': :_selinux_types -a domain' + ) + ;| + booleans) + args+=( + '(-)'{-a,--all}'[get all booleans descriptions]' + \*{-b,--boolean}'[specify boolean to show description]:*:boolean:_selinux_bools' + '!(-a --all -h --help)*'{-b-,--boolean=}': :_selinux_bools' + ) + ;; + communicate) + args+=( + '(-c --class)'{-c+,--class=}'[specify class to use for communications]:tclass [file]:_selinux_classes' + '(-S --sourceaccess)'{-S+,--sourceaccess=}'[specify permissions for the source type to use]:source access [open,write]' + '(-T --targetaccess)'{-T+,--targetaccess=}'[specify permissions for the target type to use]:target access [open,read]' + ) + ;; + generate) + args=( $sepolgen ) + ;; + interface) + args+=( + '(-c --compile)'{-c,--compile}'[run compile test for selected interface]' + '(-v --verbose)'{-v,--verbose}'[show verbose information]' + '(-f --file)'{-f+,--file=}'[specify interface file]:interface file:_files' + '(-a --list_admin)'{-a,--list_admin}'[list all domains with admin interface - DOMAIN_admin()]' + '(-u --list_user)'{-u,--list_user}'[list all domains with SELinux user role interface - DOMAIN_role()]' + '(-l --list)'{-l,--list}'[list all interfaces]' + {-i,--interfaces}'[specify interface names]:*:interface:_selinux_interfaces' + '!*'{-i-,--interfaces=-}':interface:_selinux_interfaces' + ) + ;; + manpage) + args+=( + '(-p --path)'{-p+,--path=}'[specify path in which the generated selinux man pages will be stored]:path:_directories' + '(-o --os)'{-o+,--os=}'[specify name of the OS for man pages]:OS' + '(-w --web)'(-w,--web)'[generate HTML man pages structure]' + '(-r --root)'{-r+,--root=}'[specify alternate root directory]:root [/]:_directories' + '--source_files[alternative root path needs to include file context files and policy.xml file]' + '(-a --all -d --domain)'{-a,--all}'[all domains]' + ) + ;; + network) + args+=( + '(-l --list)'{-l,--list}'[list all SELinux port types]' + {-p,--port}'[specify type related to the port]:*:port number' + '!*'{-p-,--port=-}':port number' + {-t,--type}'[show ports defined for this SELinux type]:*:port type:_selinux_types -a port_type' + '!*'{-t-,--type=-}':port type:_selinux_types -a port_type' + {-d,--domain}'[specify domain]:*:domain:_selinux_types -a domain' + '!*'{-d-,--domain=-}':domain:_selinux_types -a domain' + {-a,--application}'[show ports to which this application can bind and/or connect]:*:application:_selinux_types -a application_domain_type' + '!*'{-a-,--application=-}':domain:_selinux_types -a application_domain_type' # am not sure this is what is meant by applications + ) + ;; + esac + ;; + esac + ;; + + sesearch) + args=( + "${ign}(-h --help)"{-h,--help}'[display help information]' + "${ign}--version[display version information]" + '(-v --verbose)'{-v,--verbose}'[print extra informational messages]' + '--debug[enable debugging]' + '-A[search allow and allowxperm rules]' + '--allow[search allow rules]' + '--allowxperm[search allowxperm rules]' + '--auditallow[search auditallow rules]' + '--auditallowxperm[search auditallowxperm rules]' + '--dontaudit[search dontaudit rules]' + '--dontauditxperm[search dontauditxperm rules]' + '--neverallow[search neverallow rules]' + '--neverallowxperm[search neverallowxperm rules]' + '(-T --type_trans)'{-T,--type_trans}'[search type_transition rules]' + '--type_change[search type_change rules]' + '--type_member[search type_member rules]' + '--role_allow[find role allow rules]' + '--role_trans[find range_transition rules]' + '--range_trans[search range_transition rules]' + '(-s --source)'{-s+,--source=}'[source type/role of the TE/RBAC rule]: : _alternative + "types\:type\:_selinux_types" + "roles\:role\:_selinux_attributes"' + '(-t --target)'{-t+,--target=}'[target type/role of the TE/RBAC rule]: : _alternative + "types\:type\:_selinux_types" + "roles\:role\:_selinux_attributes"' + '(-c --class)'{-c+,--class=}'[comma separated list of object classes]:class:_sequence _selinux_classes' + '(-p --perms)'{-p+,--perms=}'[comma separated list of permissions]: :_sequence _selinux_permissions' + '(-x --xperms)'{-x+,--xperms=}'[comma separated list of extended permissions]:xperms' + '(-D --default)'{-D+,--default=}'[default of the rule. (type/role/range transition rules]:default' + '(-b --bool)'{-b+,--bool=}'[comma separated list of Booleans in the conditional expression]:bool ' + '-eb[match Boolean list exactly instead of matching any listed boolean]' + '-ep[match permission set exactly instead of matching any listed permission]' + '-ex[match extended permission set exactly instead of matching any listed permission]' + '-Sp[match rules where the listed permissions are a subset of the rule permissions]' + '-ds[match source attributes directly instead of matching member types/roles]' + '-dt[match target attributes directly instead of matching member types/roles]' + '-rs[use regular expression matching for the source type/role]' + '-rt[use regular expression matching for the target type/role]' + '-rc[use regular expression matching for the object class]' + '-rd[use regular expression matching for the default type/role]' + '-rb[use regular expression matching for booleans]' + ':policy:_files' + ) + ;; + + sestatus) + args=( '-b[booleans]' '-v[contexts of files and processes listed in the /etc/sestatus.conf]' ) + ;; + + setenforce) + _alternative \ + 'enable-args:enable:(Enforcing 1)' \ + 'disable-args:disable:(Permissive 0)' + return + ;; + + setsebool) + args=( + '-P[make changes persistent by writing pending values to disk]' + "-N[don't reload policy from disk]" + '-V[print verbose error messages]' + ':boolean:_selinux_bools' + ': : _values value + {1,on}"[enable]" + {0,off}"[disable]"' + ) + ;; + + validatetrans) + args=( + ':source context:_selinux_contexts' + ':target context:_selinux_contexts' + ':class:_selinux_classes' + ':new context:_selinux_contexts' + ) + ;; +esac + +_arguments -s $args diff --git a/Completion/Linux/Command/_setpriv b/Completion/Linux/Command/_setpriv index 9e38152b9..8b8d99785 100644 --- a/Completion/Linux/Command/_setpriv +++ b/Completion/Linux/Command/_setpriv @@ -93,7 +93,7 @@ _arguments -C -S -s \ '--reuid[set real and effective UNIX user id]:UNIX user:_users' \ '--securebits[set "process securebits"]: : _sequence __setpriv_prctl_securebits_set_elements' \ '--pdeathsig[keep, clear, or set parent death signal]: : __setpriv_death_signals' \ - '--selinux-label[request a selinux label]:SELinux labels: ' \ + '--selinux-label[request a selinux label]:SELinux label:_selinux_contexts' \ '--apparmor-profile[request an apparmor profile]:AppArmor profiles: ' \ '--reset-env[set environment as for a classic login shell]' \ '*:::command: _normal -p $service' \ diff --git a/Completion/Linux/Type/_selinux_contexts b/Completion/Linux/Type/_selinux_contexts index 4c2cf4288..bdad8e72b 100644 --- a/Completion/Linux/Type/_selinux_contexts +++ b/Completion/Linux/Type/_selinux_contexts @@ -1,14 +1,21 @@ #autoload -local -a parts suf +local -a parts users roles types + +zparseopts -E -D a:=types P:=users + +if ! compset -S ':*'; then + users+=( -qS : ) + roles+=( -qS : ) + [[ $(/dev/null || types+=( -qS : ) +fi parts=( users roles types ) while compset -P 1 '*:' && (( $+parts[1] )) ; do shift parts done if (( $+parts[1] )); then - compset -S ':*' || suf=( -S : ) - _selinux_$parts[1] $suf + _selinux_$parts[1] ${(P)parts[1]} else _message -e selinux-ranges 'selinux range' fi diff --git a/Completion/Linux/Type/_selinux_types b/Completion/Linux/Type/_selinux_types index ef31f45d2..69047c690 100644 --- a/Completion/Linux/Type/_selinux_types +++ b/Completion/Linux/Type/_selinux_types @@ -1,7 +1,19 @@ #autoload -local -a setypes expl +# Pass -a attribute to filter types, e.g.: +# -a domain - for process types +# -a file_type - for file types +# -a port_type - for network ports + +local -a setypes expl extra + +zparseopts -E -D -a extra a: + +if (( $#extra )); then + setypes=( ${${${(f)"$(_call_program selinux-types seinfo $extra --flat -x)"}#[[:blank:]]}:1} ) +else + setypes=( ${(f)"$(_call_program selinux-types seinfo --flat -t)"} ) +fi -setypes=( ${(f)"$(_call_program selinux-types seinfo --flat -t)"} ) _description selinux-types expl "selinux type" compadd "$@" "$expl[@]" -a setypes diff --git a/Completion/Unix/Command/_cp b/Completion/Unix/Command/_cp index da9428ce3..cb899cc28 100644 --- a/Completion/Unix/Command/_cp +++ b/Completion/Unix/Command/_cp @@ -32,7 +32,7 @@ if _pick_variant gnu=GNU unix --version; then '(-v --verbose)'{-v,--verbose}'[explain what is being done]' \ '(-x --one-file-system)'{-x,--one-file-system}'[stay on this file system]' \ '(--context)-Z[set destination SELinux security context]' \ - '(-Z)--context=-[set destination SELinux security context]:: :_selinux_contexts' \ + '(-Z)--context=-[set destination SELinux security context]:: :_selinux_contexts -a file_type' \ '(- *)--help' '(- *)--version' \ '*:file or directory:_files' else diff --git a/Completion/Unix/Command/_find b/Completion/Unix/Command/_find index 560b77f7e..4f1c338ee 100644 --- a/Completion/Unix/Command/_find +++ b/Completion/Unix/Command/_find @@ -115,14 +115,14 @@ case $variant in '*-readable' '*-writable' '*-xtype:file type:((b\:block\ special\ file c\:character\ special\ file d\:directory p\:named\ pipe f\:normal\ file l\:symbolic\ link s\:socket))' - '-files0-from[start recursing from targets in given file]:NUL-separated targets file:_files' + '(*)-files0-from[start recursing from targets in given file]:NUL-separated targets file:_files' '*-fls:output file:_files' '*-fprint:output file:_files' '*-fprint0:output file:_files' '*-fprintf:output file:_files:output format' '*-printf:output format' ) - [[ $OSTYPE = linux-gnu ]] && args+=( '*-context:SELinux context (glob pattern):_selinux_contexts' ) + [[ $OSTYPE = linux-gnu ]] && args+=( '*-context:SELinux context (glob pattern):_selinux_contexts -a file_type' ) ;; esac diff --git a/Completion/Unix/Command/_install b/Completion/Unix/Command/_install index 364119961..238b8b5bc 100644 --- a/Completion/Unix/Command/_install +++ b/Completion/Unix/Command/_install @@ -25,7 +25,7 @@ if _pick_variant gnu='Free Soft' unix --version; then args+=( $common_args '(-b --backup)--backup=[create backup; optionally specify method]:: :->controls' - "${lx}--context=-[like -Z, or specify SELinux security context to set]::SELinux security context:_selinux_contexts" + "${lx}--context=-[like -Z, or specify SELinux security context to set]::SELinux security context:_selinux_contexts -a file_type" '-D[create all leading destination path components]' '(: -)--help[display help information]' "${lx}--preserve-context[preserve SELinux security context]" diff --git a/Completion/Unix/Command/_mount b/Completion/Unix/Command/_mount index 5a379b424..bf75aa118 100644 --- a/Completion/Unix/Command/_mount +++ b/Completion/Unix/Command/_mount @@ -334,9 +334,9 @@ if (( ! $+_fs_any )); then 'keybits[set number of bits in encryption key]:key size:(64 128 160 192 256)' 'offset[specify data start for loopback mount]:offset (bytes)' '(loud)silent' '(silent)loud' - '(fscontext defcontext)context:context' - '(context)'{fscontext,defcontext}':context' - 'rootcontext:context' + '(fscontext defcontext)context:context:_selinux_contexts -a file_type' + '(context)'{fscontext,defcontext}':context:_selinux_contexts -a file_type' + 'rootcontext:context:_selinux_contexts -a file_type' ) _fs_adfs=( 'uid[set owner of root]:user ID' diff --git a/Completion/Unix/Command/_zfs b/Completion/Unix/Command/_zfs index 3265e1eb8..c09435a1f 100644 --- a/Completion/Unix/Command/_zfs +++ b/Completion/Unix/Command/_zfs @@ -295,7 +295,7 @@ case $OSTYPE in linux-gnu) rw_ds_props+=( 'relatime:value:(on off)' ) ci_ds_props+=( - {,fs,def,root}'context:SELinux context:_selinux_contexts' + {,fs,def,root}'context:SELinux context:_selinux_contexts -a file_type' ) ;; esac -- cgit v1.2.3 From 87aba4d437f5fef46917c1235c00b9162d7bcbd0 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Mon, 27 Jan 2025 23:00:17 +0100 Subject: 53325: cover newer BSD releases in completion --- ChangeLog | 15 +++++++++++++++ Completion/BSD/Command/_acpiconf | 28 ++++++++++++++++++++++++++++ Completion/BSD/Command/_bsdconfig | 1 + Completion/BSD/Command/_pkgin | 2 ++ Completion/BSD/Command/_procstat | 35 ++++++++++++++++++----------------- Completion/BSD/Command/_sockstat | 5 +++++ Completion/BSD/Command/_systat | 1 + Completion/Unix/Command/_date | 17 ++++++++++++++--- Completion/Unix/Command/_df | 19 ++++++++++++------- Completion/Unix/Command/_dhclient | 1 + Completion/Unix/Command/_dmidecode | 6 ++++-- Completion/Unix/Command/_env | 14 +++++++++++--- Completion/Unix/Command/_iostat | 3 +++ Completion/Unix/Command/_last | 14 +++++++------- Completion/Unix/Command/_ls | 6 +++++- Completion/Unix/Command/_mv | 8 ++++---- Completion/Unix/Command/_ps | 2 +- Completion/Unix/Command/_script | 13 +++++++++++-- Completion/Unix/Command/_sed | 6 ++++-- Completion/Unix/Command/_vmstat | 6 +++++- Completion/Unix/Command/_w | 7 ++++++- Completion/Unix/Command/_wc | 2 +- Completion/Unix/Command/_zfs | 31 +++++++++++++++++++++++-------- 23 files changed, 182 insertions(+), 60 deletions(-) create mode 100644 Completion/BSD/Command/_acpiconf (limited to 'Completion/Unix/Command/_zfs') diff --git a/ChangeLog b/ChangeLog index ba7054a8e..2585d50e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2025-01-27 Oliver Kiddle + + * 53325: Completion/BSD/Command/_acpiconf, + Completion/BSD/Command/_bsdconfig, Completion/BSD/Command/_pkgin, + Completion/BSD/Command/_procstat, Completion/BSD/Command/_sockstat, + Completion/BSD/Command/_systat, Completion/Unix/Command/_date, + Completion/Unix/Command/_df, Completion/Unix/Command/_dhclient, + Completion/Unix/Command/_dmidecode, Completion/Unix/Command/_env, + Completion/Unix/Command/_iostat, Completion/Unix/Command/_last, + Completion/Unix/Command/_ls, Completion/Unix/Command/_mv, + Completion/Unix/Command/_ps, Completion/Unix/Command/_script, + Completion/Unix/Command/_sed, Completion/Unix/Command/_vmstat, + Completion/Unix/Command/_w, Completion/Unix/Command/_wc, + Completion/Unix/Command/_zfs: cover newer BSD releases in completion + 2025-01-20 Bart Schaefer * Julian Prein: 53309: Completion/Unix/Command/_uniq: remove diff --git a/Completion/BSD/Command/_acpiconf b/Completion/BSD/Command/_acpiconf new file mode 100644 index 000000000..817a2f1ad --- /dev/null +++ b/Completion/BSD/Command/_acpiconf @@ -0,0 +1,28 @@ +#compdef acpiconf + +local curcontext="$curcontext" sep ret=1 +local -a state line modes desc +local -A opt_args + +_arguments -s \ + '(-)-h[display usage information]' \ + '(-)-i[get battery information]:battery' \ + '(-)-k[ack or abort a pending suspend]:ack' \ + '(-)-s[enter specified sleep mode]: :->modes' && ret=0 + +if [[ -n $state ]]; then + modes=( $(_call_program modes sysctl -n hw.acpi.supported_sleep_state) ) + zstyle -s ":completion:${curcontext}:modes" list-separator sep || sep=-- + (( $#modes )) || modes=( S3 S4 ) + desc=( + "S1 $sep stop the processor clock" + "S2 $sep low wake latency sleep state" + "S3 $sep suspend to RAM" + "S4 $sep suspend to disk" + "S5 $sep soft off state" + ) + desc=( ${(M)desc:#(${(~j.|.)modes}) *} ) + _wanted modes expl 'mode' compadd -M 'B:S=' -ld desc - ${modes#S} && ret=0 +fi + +return ret diff --git a/Completion/BSD/Command/_bsdconfig b/Completion/BSD/Command/_bsdconfig index f88255575..5de8f777d 100644 --- a/Completion/BSD/Command/_bsdconfig +++ b/Completion/BSD/Command/_bsdconfig @@ -51,6 +51,7 @@ shortcuts=( vt_saver vt_screenmap vt_ttys + wifi wireless wlan ) _arguments -s -w -A '-*' : \ diff --git a/Completion/BSD/Command/_pkgin b/Completion/BSD/Command/_pkgin index 662bed181..c4ed3aa14 100644 --- a/Completion/BSD/Command/_pkgin +++ b/Completion/BSD/Command/_pkgin @@ -5,6 +5,8 @@ local -a state state_descr line expl cmds short pkgs local -A opt_args _arguments -s -S -C \ + '(-6)-4[only use IPv4 addresses]' \ + '(-4)-6[only use IPv6 addresses]' \ '-c+[enable chrooting pkgin in the given repository]:chroot path:_directories' \ '-d[download only]' \ '-f[force database update]' \ diff --git a/Completion/BSD/Command/_procstat b/Completion/BSD/Command/_procstat index a1708f6ac..867ddc501 100644 --- a/Completion/BSD/Command/_procstat +++ b/Completion/BSD/Command/_procstat @@ -1,26 +1,27 @@ #compdef procstat _arguments -s -A "-*" -S \ - '-b[show binary information]' \ - '-c[show command line arguments]' \ - '-e[show environment variables]' \ - '-f[show file descriptor information]' \ - '-i[show signal pending and disposition]' \ - '-j[show signal pending and blocked information for process threads]' \ - '-k[show stacks of kernel threads]' \ - '-l[show resource limits]' \ - "-L[show LWP info for the process pertaining to it's signal driven exit]" \ - '-r[show resource usage]' \ - '-s[show security credential information]' \ - '-S[show cpuset information]' \ - '-t[show thread information]' \ - '-v[show virtual memory mappings]' \ - '-x[show ELF auxiliary vector]' \ + '(1)-b[show binary information]' \ + '(1)-c[show command line arguments]' \ + '(1)-e[show environment variables]' \ + '(1)-f[show file descriptor information]' \ + '(1)-i[show signal pending and disposition]' \ + '(1)-j[show signal pending and blocked information for process threads]' \ + '(1)-k[show stacks of kernel threads]' \ + '(1)-l[show resource limits]' \ + "(1)-L[show LWP info for the process pertaining to it's signal driven exit]" \ + '(1)-r[show resource usage]' \ + '(1)-s[show security credential information]' \ + '(1)-S[show cpuset information]' \ + '(1)-t[show thread information]' \ + '(1)-v[show virtual memory mappings]' \ + '(1)-x[show ELF auxiliary vector]' \ '-h[suppress table headers]' \ - '(1)-a[all processes]' \ + '(2 *)-a[all processes]' \ '-w+[repeat information after specified interval]:delay (seconds)' \ '-C[print additional capability information for file descriptors]' \ '-H[statistics per-thread rather than per-process]' \ '-n[numeric form for signals]' \ - '1::core file:_path_files -g "*core*(-.)"' \ + '1::command:(advlock argument auxv basic binary cpuset credential environment fd file kstack pargs ptlwpinfo pwdx rlimit rlimitusage rusage sigfastblock signal thread tsignal vm)' \ + '2::core file:_path_files -g "*core*(-.)"' \ '*:process id:_pids' diff --git a/Completion/BSD/Command/_sockstat b/Completion/BSD/Command/_sockstat index f372fe1b3..b99d3681a 100644 --- a/Completion/BSD/Command/_sockstat +++ b/Completion/BSD/Command/_sockstat @@ -29,6 +29,11 @@ case $OSTYPE in '-q[quiet mode, do not print the header line]' ) ;| + freebsd<14->.*) + args+=( + '-I[show local address of socket to which the current socket is spliced]' + ) + ;| freebsd*) for proto in ${${(M)${(f)"$(.*) args+=( '-d+:daylight saving time value' @@ -77,6 +83,11 @@ else freebsd<14->.*|openbsd*) args+=( '-z+[specify timezone for output]:time zone:_time_zone') ;| + freebsd*) + args+=( + '(-R)-I-[display in ISO 8601 format]::precision [date]:(date hours minutes seconds ns)' + ) + ;| netbsd*) args+=( '-d[output date specified by string]:time string:' ) ;; diff --git a/Completion/Unix/Command/_df b/Completion/Unix/Command/_df index 21abff105..315758488 100644 --- a/Completion/Unix/Command/_df +++ b/Completion/Unix/Command/_df @@ -45,21 +45,25 @@ elif [[ "$OSTYPE" == (darwin|dragonfly|freebsd|netbsd*|openbsd)* ]]; then '-a[show all mount points]' '(-b -g -H -h -k -m --si)-g[use 1024^3-byte blocks]' '(-b -g -H -h -k -m --si)-m[use 1024*1024-byte blocks]' - ) - ;| - (darwin*|dragonfly*|freebsd*) - args+=( '(-b -g -H -h -k -m --si)-b[use 512-byte blocks (default)]' '(-b -g -H -h -k -m --si)-H[human-readable output (base 10)]' ) ;| - (darwin*|freebsd*) + (darwin*|freebsd*|netbsd*) args+=( '-c[display a grand total]' ) + ;| + (darwin*|freebsd*) + args+=( + '--libxo[generate output via libxo]' + '-,[separate thousands]' + ) ;| (darwin*) args+=( + '-I[suppress inode counts]' + '-Y[include file system type]' "-T+$spec" "!-t+$spec" # obsolete ) @@ -76,14 +80,15 @@ elif [[ "$OSTYPE" == (darwin|dragonfly|freebsd|netbsd*|openbsd)* ]]; then ;| (freebsd*) args+=( - '--libxo[generate output via libxo]' '(-b -g -H -h -k -m --si)--si[human-readable output (base 10)]' - '-,[separate thousands]' ) ;; (netbsd*) args+=( + '(-P -G -N)-f[display only the available free]' '(-G -i -P)-G[display all fields in statvfs]' + '(-G -P)-N[suppress the header line normally output]' + '-W[print widge name instead of the device]' ) ;; esac diff --git a/Completion/Unix/Command/_dhclient b/Completion/Unix/Command/_dhclient index e22586b04..f38e9a9e5 100644 --- a/Completion/Unix/Command/_dhclient +++ b/Completion/Unix/Command/_dhclient @@ -12,6 +12,7 @@ case $OSTYPE in args+=( '(-d)-b[immediately move to the background]' '-l+[specify leases file]:file:_files' + "-n[don't wait for ARP resolution]" '-p+[specify PID file]:file:_files' '-u[reject leases with unknown options]' '-q[quiet]' diff --git a/Completion/Unix/Command/_dmidecode b/Completion/Unix/Command/_dmidecode index e2c511313..62a950a7a 100644 --- a/Completion/Unix/Command/_dmidecode +++ b/Completion/Unix/Command/_dmidecode @@ -5,8 +5,10 @@ _arguments -s \ '(-)'{-h,--help}'[display usage information]' \ '(-q --quiet -u --dump)'{-q,--quiet}'[be less verbose]' \ '--no-quirks[decode everything without quirks]' \ - '(-t --type -H --handle -u --dump --dump-bin -s --string)'{-s+,--string=}'[only display value of specified DMI string]:DMI string:(bios-vendor bios-version bios-release-date system-manufacturer system-product-name system-version system-serial-number system-uuid baseboard-manufacturer baseboard-product-name baseboard-version baseboard-serial-number baseboard-asset-tag chassis-manufacturer chassis-type chassis-version chassis-serial-number chassis-asset-tag processor-family processor-manufacturer processor-version processor-frequency)' \ - '(-s --string -H --handle --dump-bin)*'{-t+,--type=}'[only display entries of specified type]:entry type:(bios system baseboard chassis processor memory cache connector slot)' \ + '(-t --type -H --handle -u --dump --dump-bin -s --string)'{-s+,--string=}'[only display value of specified DMI string]:DMI string:compadd -M "r\:|-=* r\:|=*" - $(_call_program strings dmidecode --list-strings)' \ + '--list-strings[list available string keywords]' \ + '(-s --string -H --handle --dump-bin)*'{-t+,--type=}'[only display entries of specified type]:entry type:compadd - $(_call_program types dmidecode --list-types)' \ + '--list-types[list available type keywords]' \ '(-s --string -t --type -H --handle --dump-bin)'{-H,--handle=}'[only display the entry of specified handle]:handle' \ '(-q --quiet -u --dump -s --string)'{-u,--dump}"[don't decode entries]" \ '(-s --string -t --type -H --handle)--dump-bin=[dump DMI data to a binary file]:file:_files' \ diff --git a/Completion/Unix/Command/_env b/Completion/Unix/Command/_env index 8cf0ad467..89a45e4a4 100644 --- a/Completion/Unix/Command/_env +++ b/Completion/Unix/Command/_env @@ -8,6 +8,7 @@ case $variant in gnu) (( $#words > 2 )) && ign='!' args=( + '(-a --argv0)'{-a+,--argv0=}'[pass argument as the zeroth argument of command]:argument' '(-)'{-i,--ignore-environment}'[start with empty environment]' '(* -0 --null)'{-0,--null}'[end each output line with NUL, not newline]' '(--ignore-environment -i --help --version)*'{-u+,--unset=}'[remove variable from the environment]:env var to remove:_parameters -g "*export*"' @@ -28,12 +29,19 @@ case $variant in '-U[add variables from user and system login.conf(5)]: :->user-class' ) ;| - freebsd*|darwin*) - args=( '-0[use NUL, not newline after each variable in output]' ) + freebsd*|netbsd*) + args+=( '-C+[change working directory]:directory:_directories' ) ;| - freebsd*|darwin*|dragonfly*) + freebsd*|darwin*|netbsd*) + args+=( '-0[use NUL, not newline after each variable in output]' ) + ;| + freebsd*|darwin*|dragonfly*|netbsd*|openbsd*) args+=( '(-i)*-u+[remove variable from the environment]:env var to remove:_parameters -g "*export*"' + ) + ;| + freebsd*|darwin*|dragonfly*) + args+=( '-P+[specify alternate executable search PATH]:path:_dir_list' '-S+[perform word splitting]:string to split' '*-v[verbose output]' diff --git a/Completion/Unix/Command/_iostat b/Completion/Unix/Command/_iostat index d3943fcb4..36a3b7904 100644 --- a/Completion/Unix/Command/_iostat +++ b/Completion/Unix/Command/_iostat @@ -50,6 +50,9 @@ case $OSTYPE:l in args+=( '-x[show extended disk statistics]' '-y[report data on waiting and active requests]' + '-z[replace drive and CPU statistics that are zero with spaces]' + "-H+[set page height explicitly]:height [$LINES]" + "-W+[set page width explicitly]:width [$COLUMNS]" ) ;; aix*) diff --git a/Completion/Unix/Command/_last b/Completion/Unix/Command/_last index 2013cc1c2..d76260c36 100644 --- a/Completion/Unix/Command/_last +++ b/Completion/Unix/Command/_last @@ -8,17 +8,16 @@ ttys=( ${ttys#/dev/} ) for pattern arg in \ '(solaris*|linux-gnu)' '(--hostlast)-a[display hostname in last column]' \ '((free|net|open)bsd*|darwin*|dragonfly*)' '-h+[limit sessions by hostname]:host:_hosts' \ - '((free|open)bsd*)' '-s[report duration in seconds]' \ - '(freebsd*|openbsd*)' '-d+[limit sessions to those active at snapshot time]:time ([[CC]YY][MMDD]hhmm[.SS])' \ + '((free|open)bsd*|darwin*)' '-s[report duration in seconds]' \ + '((free|open)bsd*|darwin*)' '-d+[limit sessions to those active at snapshot time]:time ([[CC]YY][MMDD]hhmm[.SS])' \ '((net|free|open)bsd*|darwin*|dragonfly*)' '-t+[limit sessions by tty]:tty:_ttys -D' \ 'openbsd*' '-c[calculate total time]' \ - '^darwin*' '(--file)-f+[specify account file]:file:_files' \ - '(solaris*|linux-gnu|freebsd*|openbsd*)' '(--limit)-n+[specify number of lines to show]:number' \ + '(solaris*|darwin*|linux-gnu|freebsd*|openbsd*)' '(--limit)-n+[specify number of lines to show]:number' \ '((open|net)bsd*|dragonfly*)' '-T[show more detailed time information including year and seconds]' \ 'netbsd*' '-x[assume file is in wtmpx(5) format]' \ 'netbsd*' '-n[show IP of remote hosts]' \ - 'freebsd*' '-w[show seconds in duration field]' \ - 'freebsd*' '-y[show year in session start time]' + '(freebsd*|darwin*)' '-w[show seconds in duration field]' \ + '(freebsd*|darwin*)' '-y[show year in session start time]' do [[ $OSTYPE = $~pattern ]] && args+=( $arg ) done @@ -58,4 +57,5 @@ else args+=( '*:user:_users' ) fi -_arguments -s -S $args +_arguments -s -S $args \ + '(--file)-f+[specify account file]:file:_files' diff --git a/Completion/Unix/Command/_ls b/Completion/Unix/Command/_ls index 392b8490b..a19ad30e2 100644 --- a/Completion/Unix/Command/_ls +++ b/Completion/Unix/Command/_ls @@ -61,12 +61,16 @@ if ! _pick_variant gnu=gnu unix --help; then '(-l -1 -C -m -x)-g[long listing but without owner information]' ) fi + if [[ $OSTYPE = (netbsd*|darwin*) ]]; then + arguments+=( + "-X[don't cross mount points when recursing]" + ) + fi if [[ $OSTYPE = netbsd* ]]; then arguments+=( '-M[output file sizes in comma-separated form]' '-O[output only leaf (non-directory) files]' '-P[print full pathname for each file]' - "-X[don't cross mount points when recursing]" ) fi if [[ $OSTYPE = (dragonfly*|freebsd*|openbsd*|darwin*) ]]; then diff --git a/Completion/Unix/Command/_mv b/Completion/Unix/Command/_mv index c52e7a5e4..983c25ea8 100644 --- a/Completion/Unix/Command/_mv +++ b/Completion/Unix/Command/_mv @@ -38,11 +38,11 @@ case $variant; in '(-f -n)-i[prompt before overwriting existing file]' ) ;| + darwin*|dragonfly*|freebsd*|netbsd*) + args+=( "-h[if target is a symlink to a directory, don't follow it]" ) + ;| darwin*|dragonfly*|freebsd*) - args+=( - "(-f -i)-n[don't overwrite existing file]" - "-h[if target is a symlink to a directory, don't follow it]" - ) + args+=( "(-f -i)-n[don't overwrite existing file]" ) ;| darwin*|dragonfly*|*bsd*) args+=( diff --git a/Completion/Unix/Command/_ps b/Completion/Unix/Command/_ps index c3dfae47d..158fb6b83 100644 --- a/Completion/Unix/Command/_ps +++ b/Completion/Unix/Command/_ps @@ -106,9 +106,9 @@ case $OSTYPE in ;| linux-gnu|netbsd*) bsdarg+=( 'k[specify sort order]' ) ;| linux-gnu|openbsd*) bsd+=( 'f[show process hierarchy]' ) ;| + darwin*|freebsd*|netbsd*) bsdarg+=( '*G[select processes by real group]' ) ;| darwin*|freebsd*) bsd+=( 'X[skip processes with no controlling terminal]' ) - bsdarg+=( '*G[select processes by real group]' ) ;| freebsd*|dragonfly*) bsd+=( 'f[show command and environment for swapped out processes]' ) diff --git a/Completion/Unix/Command/_script b/Completion/Unix/Command/_script index d38d56f2e..25f8ea35f 100644 --- a/Completion/Unix/Command/_script +++ b/Completion/Unix/Command/_script @@ -50,19 +50,28 @@ case $OSTYPE in '(-d -p -T)-r[record a session with input, output and timing data]' ) ;| + darwin*|netbsd*|freebsd*) + args+=( + '-e[return exit status of the child process]' + ) + ;| netbsd*|openbsd*) args+=( '-c[run specified command instead of a shell]:command:_cmdstring' ) ;| + darwin*|freebsd*) + args+=( + '(-a -r -k -t)-T[play back a recorded session, reporting only timestamps]: :_date_formats' + ) + ;| netbsd*) args+=( '-f[flush output after each write]' ) ;| freebsd*) args+=( - '-e[return exit status of the child process]' '-f[use filemon(4)]' - '(-a -r -k -t)-T[play back a recorded session, reporting only timestamps]: :_date_formats' + '-w[forward terminal size changes on SIGWINCH]' ) ;| darwin*|dragonfly*|freebsd*) diff --git a/Completion/Unix/Command/_sed b/Completion/Unix/Command/_sed index ef3aaf2fd..ecbec61d1 100644 --- a/Completion/Unix/Command/_sed +++ b/Completion/Unix/Command/_sed @@ -104,7 +104,7 @@ else case $OSTYPE in openbsd*|freebsd*|netbsd*|darwin*|dragonfly*) args+=( - '(-r -E)'{-E,-r}$extended + '(-r -E -H)'{-E,-r}$extended '-a[delay opening files listed with w function]' ) ;| @@ -115,8 +115,10 @@ else args+=( '-I+[edit files in-place, treating all files as a single input stream]:: :_guard "^(*[@/; \\\]*|?(#c6,)|-*)" "suffix for backup"' ) - ;; + ;| openbsd*) args+=( '-u[make output line buffered]' ) ;; + darwin*) args+=( '(-r -E)-H[use enhanced regular expressions]' ) ;; + netbsd*) args+=( '(-r -E)-g[use GNU regular expressions]' '!(-r -E -g)-G' ) ;; esac fi diff --git a/Completion/Unix/Command/_vmstat b/Completion/Unix/Command/_vmstat index 6db776e62..1d0ac855d 100644 --- a/Completion/Unix/Command/_vmstat +++ b/Completion/Unix/Command/_vmstat @@ -37,10 +37,14 @@ case $OSTYPE in '-f[report on the number fork syscalls since boot and pages of virtual memory for each]' ) ;| + freebsd*|dragonfly*|netbsd*) + specs+=( + '-n+[change the maximum number of disks to display]:number of disks to display [2]' + ) + ;| freebsd*|dragonfly*) specs+=( '-m[report on the usage of kernel dynamic memory allocated using malloc(9) by type]' - '-n+[change the maximum number of disks to display]:number of disks to display [2]' '*-p+[specify which types of devices to display]: :->devices' '-s[display the contents of the SUM structure]' '-z[report on memory used by the kernel zone allocator, uma(9), by zone]' diff --git a/Completion/Unix/Command/_w b/Completion/Unix/Command/_w index e82c84f57..408cb76af 100644 --- a/Completion/Unix/Command/_w +++ b/Completion/Unix/Command/_w @@ -23,7 +23,7 @@ case $OSTYPE in openbsd*) args+=( '-a[translate network addresses into names]' ) ;| - (free|net)bsd*|dragonfly*) + (free|net)bsd*|dragonfly*|darwin*) args+=( '-n[show network addresses as numbers]' ) ;| *bsd*|dragonfly*) @@ -35,6 +35,11 @@ case $OSTYPE in freebsd*|dragonfly*) args+=( '-d[dump process list on a per controlling tty basis]' ) ;| + netbsd*) + args+=( + '-A[sort tty names alphabetically instead of utmp or utmpx order]' + ) + ;| solaris*) args+=( '!(-s -w -l)'{-l,-w} '-s[short output form]' diff --git a/Completion/Unix/Command/_wc b/Completion/Unix/Command/_wc index a1897e289..2a4f7ab05 100644 --- a/Completion/Unix/Command/_wc +++ b/Completion/Unix/Command/_wc @@ -18,7 +18,7 @@ if _pick_variant gnu=GNU unix --version; then else args=( -A "-*" "${(@)args:#(|\(*\))(|\*)--*}" ) case $OSTYPE in - freebsd*|netbsd*) args+=( '-L[print longest line lengths]' ) ;; + freebsd*|netbsd*|darwin*) args+=( '-L[print longest line lengths]' ) ;; openbsd*) args+=( '-h[human readable: use unit suffixes]' ) ;; solaris*) args+=( ${${(M)args:#*-m\[*}//-m\[/-C\[} ) ;; esac diff --git a/Completion/Unix/Command/_zfs b/Completion/Unix/Command/_zfs index c09435a1f..5a45c2920 100644 --- a/Completion/Unix/Command/_zfs +++ b/Completion/Unix/Command/_zfs @@ -79,7 +79,7 @@ rw_ds_props=( 'paths:mountpoint:_directories -W / -P /'" 'multilevel:value:(on off)' 'nbmand:value:(on off)' - 'primarycache:value:(all none metadata)' + {prefetch,primarycache}':value:(all none metadata)' 'quota: :->quotas' 'readonly:value:(on off)' 'recordsize:value:(512 1K 2K 4K 8K 16K 32K 64K 128K 256K 512K 1M)' @@ -515,9 +515,11 @@ case $service:$words[1] in ;; zfs:set) - [[ $implementation = solaris ]] && args=( - '-r[recursively apply value]' \ - ) + if [[ $implementation = solaris ]]; then + args=( '-r[recursively apply value]' ) + else + args=( "-u[update property but don't mount or share dataset]" ) + fi _arguments -C -A "-*" -S $args \ ':property:->set-properties' \ '*:filesystem/volume:_zfs_dataset -t fs -t vol' @@ -598,13 +600,14 @@ case $service:$words[1] in zfs:mount) [[ $OSTYPE != freebsd* ]] && args=( '-O[overlay mount]' ) [[ $implementation = openzfs ]] && args+=( - '-l[load keys for encrypted filesystems as they are being mounted]' + '-l[load keys for encrypted filesystems as they are being mounted]' + '(-a)-R[mount filesystems along with all their children]' ) _arguments -A "-*" -S $args \ '-o+[specify temporary file system options]: :_values -s , "option" {,no}{atime,dev,exec,relatime,suid,xattr} ro rw' \ '-v[report mount progress]' \ '-f[force mount]' \ - '(:)-a[mount all available ZFS filesystems]' \ + '(: -R)-a[mount all available ZFS filesystems]' \ '(-a):filesystem:_zfs_dataset -t fs' ;; @@ -888,6 +891,12 @@ case $service:$words[1] in ':property:($delegatable_perms $ro_ds_props ${rw_ds_props%%:*})' ;; + zpool:(clear|online)) + [[ $OSTYPE = linux* ]] && args=( + "--power[power on the device's slot in the storage enclosure]" + ) + ;| + zpool:help) _arguments -A "-*" -S \ - commands \ @@ -905,6 +914,7 @@ case $service:$words[1] in '-L[display real paths for vdevs resolving all symbolic links]' '-o+[set given pool properties]: :_values -s , "property" "${(@M)ci_po_props\:#ashift*}"' \ '-P[display real paths for vdevs instead of only the last component of the path]' + --allow-ashift-mismatch --allow-in-use --allow-replication-mismatch ) elif [[ $implementation = solaris ]]; then args=( '-l[display configuration in /dev/chassis location form]' ) @@ -1004,7 +1014,7 @@ case $service:$words[1] in zpool:get) [[ $implementation = solaris ]] && args=( - '-s+[specify sources to display]: :_values -s "source" local default none' + '-s+[specify sources to display]: :_values -s , "source" local default none' ) _arguments -A "-*" -S $args \ '-H[suppress headers and tab-delimit fields]' \ @@ -1140,6 +1150,9 @@ case $service:$words[1] in [[ $implementation = openzfs ]] && args=( '-f[force disk into faulted state]' ) + [[ $OSTYPE = linux* ]] && args=( + "--power[power off the device's slot in the storage enclosure]" + ) _arguments -C -A "-*" -S $args \ '-t[offline until next reboot]' \ ':pool:_zfs_pool' \ @@ -1147,7 +1160,7 @@ case $service:$words[1] in ;; zpool:online) - _arguments -C -A "-*" -S \ + _arguments -C -A "-*" -S $args \ '-e[expand device to use all available space]' \ ':pool:_zfs_pool' \ '*:virtual device:->pool-devices' @@ -1234,8 +1247,10 @@ case $service:$words[1] in zpool:status) if [[ $implementation = openzfs ]]; then args=( + '--power[display vdev enclosure slot power status]' '-D[display a histogram of deduplication statistics]' '-c[run scripts on each vdev]:script:_files -W "($ZPOOL_SCRIPTS_PATH /etc/zfs/zpool.d ~/.zpool.d)"' + '-e[only show unhealthy vdevs]' '-i[display vdev initialization status]' '-g[display vdev GUIDs instead of the normal device names]' '-L[display real paths for vdevs resolving all symbolic links]' -- cgit v1.2.3 From eb8e217f1ba41c2146218bc74643a48c1a82d8b9 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Fri, 28 Feb 2025 20:58:34 +0100 Subject: 53395: complete snapshot ranges for zfs destroy --- ChangeLog | 4 ++++ Completion/Unix/Command/_zfs | 2 +- Completion/Unix/Type/_zfs_dataset | 32 ++++++++++++++++++++++++++++---- 3 files changed, 33 insertions(+), 5 deletions(-) (limited to 'Completion/Unix/Command/_zfs') diff --git a/ChangeLog b/ChangeLog index a2ffa1381..8cc81f4b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2025-02-28 Oliver Kiddle + * 53395: Completion/Unix/Type/_zfs_dataset, + Completion/Unix/Command/_zfs: + complete snapshot ranges for zfs destroy + * Ronan Pigott: 53393: Completion/Unix/Command/_python, Completion/Unix/Command/_python_module-http.server, Completion/Unix/Command/_python_module-json.tool, diff --git a/Completion/Unix/Command/_zfs b/Completion/Unix/Command/_zfs index 5a45c2920..ef4b80a41 100644 --- a/Completion/Unix/Command/_zfs +++ b/Completion/Unix/Command/_zfs @@ -434,7 +434,7 @@ case $service:$words[1] in '-R[recursively destroy all dependents]' \ '(-f)-d[delete or mark deferred]' \ '(-d)-f[force unmounts]' \ - ':dataset:_zfs_dataset -t fs -t vol ${=${opt_args[(i)-f]:--t snap}:/-f/} ${=${opt_args[(i)-*]:--t bookmark}:/-?/}' + ':dataset:_zfs_dataset -t fs -t vol ${=${opt_args[(i)-f]:--t snap -t range}:/-f/} ${=${opt_args[(i)-*]:--t bookmark}:/-?/}' ;; zfs:snap(|shot)) diff --git a/Completion/Unix/Type/_zfs_dataset b/Completion/Unix/Type/_zfs_dataset index 7edcfd5d7..0b3876148 100644 --- a/Completion/Unix/Type/_zfs_dataset +++ b/Completion/Unix/Type/_zfs_dataset @@ -1,6 +1,6 @@ #autoload -local -a type expl_type_arr rsrc rdst paths_allowed +local -a type expl_type_arr rsrc rdst paths_allowed suf local -a typearg datasetlist expl mlist local expl_type @@ -9,11 +9,16 @@ local expl_type # -r1 indicates that we're completing the source of a rename # -r2 indicates that we're completing the destination of a rename # -t takes arguments (what kinds of datasets) and can appear multiple times +# in addition to the usual types +# clone - cloned file systems +# mtpt - add mountpoints +# range - allow a range of snapshots zparseopts -D -E e:=expl_type_arr p=paths_allowed r1=rsrc r2=rdst t+:=type +suf=( -r '\n\t\- @\\#' ) [[ -n $type[(r)fs] ]] && typearg=( filesystem ) [[ -n $type[(r)vol] ]] && typearg+=( volume ) -[[ -n $type[(r)snap] ]] && typearg+=( snapshot ) +[[ -n $type[(r)snap] || -prefix *@ ]] && typearg+=( snapshot ) [[ -n $type[(r)share] && $implementation = solaris ]] && typearg+=( share ) [[ -n $type[(r)bookmark] && $implementation = openzfs ]] && typearg+=( bookmark ) @@ -62,7 +67,26 @@ fi if [[ -n $type[(r)clone] ]]; then datasetlist=( ${(f)"$(zfs list -H -o name,origin -t filesystem 2>/dev/null | awk -F$'\t' "\$2 != \"-\" {print \$1}")":#no cloned filesystems available} ) else - datasetlist=( ${(f)"$(zfs list -H -o name $typearg 2>/dev/null)":#no datasets available} ) + [[ -n $type[(r)range] && $implementation = openzfs ]] && + typearg+=( -s creation ) suf=( -S% -r '\n\t\- ,' ) + datasetlist=( ${(f)"$(zfs list -H -o name $typearg 2>/dev/null)":#no datasets available} ) +fi + +if [[ -n $type[(r)range] && -prefix *[%,] && $implementation = openzfs ]]; then + if [[ -n ${datasetlist[(r)${PREFIX%@*}@*]} ]]; then + datasetlist=( ${${(M)datasetlist:#${PREFIX%@*}@*}##*@} ) + compset -P '*[@,]' + # if we can find the starting snapshot filter to later ones + [[ -prefix *% ]] && (( ${#datasetlist[(r)${PREFIX%\%*},-1]} > 2 )) && + datasetlist=( ${${datasetlist[(r)${PREFIX%\%*},-1]}[2,-1]} ) + expl_type="" + compset -P '*%' && suf=( -qS, ) expl_type="end " + _description snapshots expl "${expl_type}snapshot" + compadd $suf "$expl[@]" -a datasetlist + else + _message -e snapshots 'snapshot' + fi + return fi expl_type=${typearg[2,-1]//,/\/} @@ -77,4 +101,4 @@ if [[ -n $expl_type_arr[2] ]]; then fi _description datasets expl "$expl_type" -_multi_parts "$@" "$expl[@]" -q / datasetlist +_multi_parts $suf "$@" "$expl[@]" -q / datasetlist -- cgit v1.2.3