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.
This commit is contained in:
Fabian Homborg 2022-01-25 18:05:05 +01:00
parent 972ed61266
commit 4fced3ef5a
2 changed files with 3 additions and 10 deletions

View file

@ -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.

View file

@ -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;
}
}