zsh-workers
 help / color / mirror / code / Atom feed
From: Arseny Maslennikov <ar@cs.msu.ru>
To: zsh-workers@zsh.org
Cc: Arseny Maslennikov <ar@cs.msu.ru>
Subject: [PATCH v2 1/3] Introduce new completion for Linux task capabilities
Date: Sun, 21 Mar 2021 16:01:29 +0300	[thread overview]
Message-ID: <20210321130131.1667276-1-ar@cs.msu.ru> (raw)

This is intended for use on Linux-based systems only.

The next patch introduces a completion for setpriv(1), which actively
uses this function. I believe some utilities that handle caps
may want to use it as well, albeit indirectly (neither setpriv(1) nor
setcap/getcap(8), for instance, want to offer the cap names themselves
as completion results; instead they want to prefix each name or a
comma-separated sequence of names).
---
Changes since v1:
* _capability_names is no longer shipped; users are encouraged to use
  _capabilities with compadd options as a match provider.

 Completion/Linux/Type/_capabilities | 65 +++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Completion/Linux/Type/_capabilities

diff --git a/Completion/Linux/Type/_capabilities b/Completion/Linux/Type/_capabilities
new file mode 100644
index 000000000..8cb31878f
--- /dev/null
+++ b/Completion/Linux/Type/_capabilities
@@ -0,0 +1,65 @@
+#autoload
+
+# This function completes POSIX capabilities for Linux.
+# Many command line utilities expect different syntax to encode various kinds
+# of capability names or sets, so this function tries to be as generic as
+# possible. It accepts compadd options to allow variations on the exact
+# generated completion matches.
+#
+# Usage examples:
+#
+# Complete full capability names:
+#   _capabilities -p cap_
+# Sort the completion list by capability number:
+#   _capabilities -o nosort
+
+# The list of Linux capabilities is taken from include/uapi/linux/capability.h
+# and subject to the following pipe filter:
+# grep 'define CAP' | sed -r 's/^[[:space:]]*#define[[:space:]]+CAP_//; s/[[:space:]]+[0-9]+$//' | tr '[[:upper:]]' '[[:lower:]]'
+local -a caplist=(
+  chown
+  dac_override
+  dac_read_search
+  fowner
+  fsetid
+  kill
+  setgid
+  setuid
+  setpcap
+  linux_immutable
+  net_bind_service
+  net_broadcast
+  net_admin
+  net_raw
+  ipc_lock
+  ipc_owner
+  sys_module
+  sys_rawio
+  sys_chroot
+  sys_ptrace
+  sys_pacct
+  sys_admin
+  sys_boot
+  sys_nice
+  sys_resource
+  sys_time
+  sys_tty_config
+  mknod
+  lease
+  audit_write
+  audit_control
+  setfcap
+  mac_override
+  mac_admin
+  syslog
+  wake_alarm
+  block_suspend
+  audit_read
+  perfmon
+  bpf
+  checkpoint_restore
+)
+local -a expl
+
+_description capabilities expl "Linux capability"
+compadd "${(@)expl}" "$@" -a - caplist
-- 
2.31.0



             reply	other threads:[~2021-03-21 13:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-21 13:01 Arseny Maslennikov [this message]
2021-03-21 13:01 ` [PATCH v2 2/3] Introduce new completion for setpriv(1) on Linux Arseny Maslennikov
2021-03-22 10:18   ` Mikael Magnusson
2021-03-21 13:01 ` [RFC PATCH v2 3/3] _setpriv: complete multiple --dump with argument states Arseny Maslennikov
2021-03-27 16:28   ` Lawrence Velázquez
2021-03-27 16:28 ` [PATCH v2 1/3] Introduce new completion for Linux task capabilities Lawrence Velázquez
2021-03-28 10:57   ` Oliver Kiddle
2021-03-29  6:38     ` Duplicated X-Seq? (was: Re: Re: [PATCH v2 1/3] Introduce new completion for Linux task capabilities) Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210321130131.1667276-1-ar@cs.msu.ru \
    --to=ar@cs.msu.ru \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).