From 4fced3ef5a42348db02083651e5f654c7ac232c7 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Tue, 25 Jan 2022 18:05:05 +0100 Subject: [PATCH] Remove sticky filter This isn't super useful, and having a caveat in the docs that it might cause the entire filter to fail is awkward. So just remove it. --- doc_src/cmds/path.rst | 4 +--- src/builtins/path.cpp | 9 ++------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/doc_src/cmds/path.rst b/doc_src/cmds/path.rst index a3c583113..e6f2d62a0 100644 --- a/doc_src/cmds/path.rst +++ b/doc_src/cmds/path.rst @@ -161,15 +161,13 @@ The available filters are: - ``-t`` or ``--type`` with the options: "dir", "file", "link", "block", "char", "fifo" and "socket", in which case the path needs to be a directory, file, link, block device, character device, named pipe or socket, respectively. - ``-d``, ``-f`` and ``-l`` are short for ``--type=dir``, ``--type=file`` and ``--type=link``, respectively. There are no shortcuts for the other types. -- ``-p`` or ``--perm`` with the options: "read", "write", and "exec", as well as "suid", "sgid", "sticky", "user" (referring to the path owner) and "group" (referring to the path's group), in which case the path needs to have all of the given permissions for the current user. +- ``-p`` or ``--perm`` with the options: "read", "write", and "exec", as well as "suid", "sgid", "user" (referring to the path owner) and "group" (referring to the path's group), in which case the path needs to have all of the given permissions for the current user. - ``-r``, ``-w`` and ``-x`` are short for ``--perm=read``, ``--perm=write`` and ``--perm=exec``, respectively. There are no shortcuts for the other permissions. Note that the path needs to be *any* of the given types, but have *all* of the given permissions. This is because having a path that is both writable and executable makes sense, but having a path that is both a directory and a file doesn't. Links will count as the type of the linked-to file, so links to files count as files, links to directories count as directories. The filter options can either be given as multiple options, or comma-separated - ``path filter -t dir,file`` or ``path filter --type dir --type file`` are equivalent. -If your operating system doesn't support a "sticky" bit, that check will always be false, so no path will pass. - With ``--invert``, the meaning of the filtering is inverted - any path that wouldn't pass (including by not existing) passes, and any path that would pass fails. It returns 0 if at least one path passed the filter. diff --git a/src/builtins/path.cpp b/src/builtins/path.cpp index 574f3fe54..33ccc4ee3 100644 --- a/src/builtins/path.cpp +++ b/src/builtins/path.cpp @@ -144,9 +144,8 @@ enum { PERM_EXEC = 1 << 2, PERM_SUID = 1 << 3, PERM_SGID = 1 << 4, - PERM_STICKY = 1 << 5, - PERM_USER = 1 << 6, - PERM_GROUP = 1 << 7, + PERM_USER = 1 << 5, + PERM_GROUP = 1 << 6, }; typedef uint32_t path_perm_flags_t; @@ -268,9 +267,6 @@ static int handle_flag_p(const wchar_t **argv, parser_t &parser, io_streams_t &s } else if (p == L"sgid") { opts->perm |= PERM_SGID; opts->have_special_perm = true; - } else if (p == L"sticky") { - opts->perm |= PERM_STICKY; - opts->have_special_perm = true; } else if (p == L"user") { opts->perm |= PERM_USER; opts->have_special_perm = true; @@ -533,7 +529,6 @@ static bool filter_path(options_t opts, const wcstring &path) { if (opts.perm & PERM_SGID && !(S_ISGID & buf.st_mode)) return false; if (opts.perm & PERM_USER && !(geteuid() == buf.st_uid)) return false; if (opts.perm & PERM_GROUP && !(getegid() == buf.st_gid)) return false; - if (opts.perm & PERM_STICKY && !(S_ISVTX & buf.st_mode)) return false; } }