]> gitweb.michael.orlitzky.com - apply-default-acl.git/log
apply-default-acl.git
6 years agoInline the is_hardlink_safe() and is_regular_file() functions.
Michael Orlitzky [Mon, 26 Feb 2018 01:03:44 +0000 (20:03 -0500)]
Inline the is_hardlink_safe() and is_regular_file() functions.

These two functions were only called in one place, and they were
called right after one another. Both functions merely peek the stat
structure for a file descriptor, so it's easier to stat the thing once
and then just inline the two checks rather than setup/teardown
everything twice.

6 years agoImprove the error message when apply_default_acl() is fed a NULL path.
Michael Orlitzky [Mon, 26 Feb 2018 00:59:52 +0000 (19:59 -0500)]
Improve the error message when apply_default_acl() is fed a NULL path.

6 years agoEliminate pointless newline in the signature of acl_set_entry().
Michael Orlitzky [Mon, 26 Feb 2018 00:58:18 +0000 (19:58 -0500)]
Eliminate pointless newline in the signature of acl_set_entry().

6 years agoInline the one call to the get_mode() function.
Michael Orlitzky [Mon, 26 Feb 2018 00:55:34 +0000 (19:55 -0500)]
Inline the one call to the get_mode() function.

The get_mode() function was only called in one place, and its
implementation was about three lines. The overhead of checking its
arguments and figuring out its return value was not worth the
absolutely tiny improvement in readability that the function afforded,
so the whole thing has been inlined at its one call site.

6 years agoEliminate unnecessary intermediate result variables.
Michael Orlitzky [Mon, 26 Feb 2018 00:50:42 +0000 (19:50 -0500)]
Eliminate unnecessary intermediate result variables.

Before this commit, most library calls looked something like...

  int result = foo(x,y);
  if (result == whatever) {
    ...
  }

and then the "result" variable was never used again. There's no need
to introduce the new name, and it probably only increases
confusion. So, this commit eliminates them all.

6 years agoSimplify wipe_acls() by having it unconditionally write a new, empty ACL.
Michael Orlitzky [Mon, 26 Feb 2018 00:39:16 +0000 (19:39 -0500)]
Simplify wipe_acls() by having it unconditionally write a new, empty ACL.

6 years agoReplace most path usage with file descriptors.
Michael Orlitzky [Fri, 23 Feb 2018 21:11:08 +0000 (16:11 -0500)]
Replace most path usage with file descriptors.

Before this commit, we were passing around paths everywhere to specify
the targets of operations. This is not optimal from a security
standpoint: the best we can do to avoid following hard links is to
check whether or not a given file has more than one name. There is a
race condition inherent in that approach -- between when you stat the
file and when you use it, the number of names may change -- but using
paths makes that window larger than it has to be. There's no guarantee
that a path used at the bottom of apply_default_acl() will refer to
the same file that we called stat() on at the top of the function.

To work around that, most of the path handling functions have been
replaced with versions that use file descriptors. Now we are able to
stat() our file descriptor immediately after opening it, and the
descriptor itself will always refer to the same file. There's still
the smallest of windows for an exploit, but this makes it much safer
to call apply_default_acl() when there may be hard links present.

6 years agoRename is_directory() to is_path_directory() in preparation for other stuff.
Michael Orlitzky [Fri, 23 Feb 2018 21:02:03 +0000 (16:02 -0500)]
Rename is_directory() to is_path_directory() in preparation for other stuff.

6 years agoAdd missing jump-to-cleanup in one error scenario.
Michael Orlitzky [Fri, 23 Feb 2018 21:00:03 +0000 (16:00 -0500)]
Add missing jump-to-cleanup in one error scenario.

6 years agoAdd comments explainining the acl_create_entry() gymnastics.
Michael Orlitzky [Fri, 23 Feb 2018 17:10:25 +0000 (12:10 -0500)]
Add comments explainining the acl_create_entry() gymnastics.

6 years agoRemove pointless indirection in acl_entry_count() and acl_is_minimal().
Michael Orlitzky [Fri, 23 Feb 2018 16:39:07 +0000 (11:39 -0500)]
Remove pointless indirection in acl_entry_count() and acl_is_minimal().

The acl_t type is already a pointer to a structure, so there's no
reason to be passing around pointers to acl_t in acl_entry_count() and
acl_is_minimal(). This commit changes their signatures and call sites.

6 years agoHave acl_execute_masked() take an acl_t rather than a path as its argument.
Michael Orlitzky [Fri, 23 Feb 2018 16:32:31 +0000 (11:32 -0500)]
Have acl_execute_masked() take an acl_t rather than a path as its argument.

We only call acl_execute_masked() in one place; and in that place, the
ACL of the path in question is already available. So, there's no
reason for us to re-retrieve it. Instead, the function has been
updated to take an acl_t (and not a path), simplifing the logic a bit.

6 years agoRename inherit_default_acl() to assign_default_acl().
Michael Orlitzky [Fri, 23 Feb 2018 16:15:22 +0000 (11:15 -0500)]
Rename inherit_default_acl() to assign_default_acl().

The inherit_default_acl() function was called with two path names, and
the default ACL of the second path was retrieved and applied to the
first path. However, the only situation in which the function was used
was when the default ACL of the parent path was already available -- so
we were wasting time re-retrieving it.

This commit changes the name of the function to assign_default_acl(),
and it now takes an acl_t as its second parameter rather than a
path. The one place it is used now passes it the (already-known)
parent's default ACL rather than that parent's path.

6 years agoNaively ignore hard links to avoid security mishaps.
Michael Orlitzky [Thu, 22 Feb 2018 23:00:11 +0000 (18:00 -0500)]
Naively ignore hard links to avoid security mishaps.

If an attacker can introduce a hard link into a directory with a
default ACL, then he may be able to trick the user into applying that
default ACL to the target of the hard link which lives somewhere else
entirely. That can be exploited to gain access to the user's files,
and is hard to detect.

To avoid that problem entirely, great care must be taken. For now, a
naive check of the target path is implemented to ensure that (at the
start of the routine) it has only one name on the filesystem. This
still admits a race condition, but is an improvement.

The new behavior is now documented in the man page, and a test has
been added to ensure that pre-existing hard links are ignored.

8 years agoFix capitalization of "No such..." in the expected output of some tests. v0.0.6
Michael Orlitzky [Mon, 3 Oct 2016 14:19:45 +0000 (10:19 -0400)]
Fix capitalization of "No such..." in the expected output of some tests.

8 years agoAdd one more test for recursive symlink handling.
Michael Orlitzky [Mon, 3 Oct 2016 14:13:50 +0000 (10:13 -0400)]
Add one more test for recursive symlink handling.

8 years agoFix symlink handling and update to version 0.0.6.
Michael Orlitzky [Mon, 3 Oct 2016 14:06:11 +0000 (10:06 -0400)]
Fix symlink handling and update to version 0.0.6.

There was kind of a big bug in previous versions: symlinks were
followed and they weren't supposed to be. This came down to a few
"stat" calls that should have been "lstat" calls. Those changes have
been made, and there's now a test for the correct behavior.

Unrelated: I capitalized the 'n' in the "No such file..." error.

8 years agoAdd three tests for the new "no such file..." error output. v0.0.5
Michael Orlitzky [Tue, 27 Sep 2016 19:39:06 +0000 (15:39 -0400)]
Add three tests for the new "no such file..." error output.

8 years agoUse $() for subshells instead of backticks in run-tests.sh.
Michael Orlitzky [Tue, 27 Sep 2016 19:30:33 +0000 (15:30 -0400)]
Use $() for subshells instead of backticks in run-tests.sh.

8 years agoPrint an error if any targets do not exist.
Michael Orlitzky [Tue, 27 Sep 2016 19:23:33 +0000 (15:23 -0400)]
Print an error if any targets do not exist.

This commit fixes the last known bug, that apply-default-acl can be
called on a file that does not exist and no error is output.

A new function, path_accessible(), was added and it uses the
faccessat() POSIX call to check whether or not the current effective
user/group can access a path. We then call the new path_accessible()
on every target given on the command line. If any do not exist, an
error is printed:

  $ ./apply-default-acl derp
  ./apply-default-acl: derp: no such file or directory

Along with this change comes a version bump to v0.0.5 in configure.ac.
Some minor reorganization was done in configure.ac as well.

8 years agoFix a typo in a comment.
Michael Orlitzky [Tue, 27 Sep 2016 19:21:16 +0000 (15:21 -0400)]
Fix a typo in a comment.

8 years agoMake the usage() function argument program_name const.
Michael Orlitzky [Tue, 27 Sep 2016 19:20:27 +0000 (15:20 -0400)]
Make the usage() function argument program_name const.

11 years agoOutput an error message when a test user is missing.
Michael Orlitzky [Thu, 31 Jan 2013 13:11:31 +0000 (08:11 -0500)]
Output an error message when a test user is missing.
Add two tests for multiple command-line arguments.

11 years agoBump configure.ac to version 0.0.4. v0.0.4
Michael Orlitzky [Sat, 26 Jan 2013 01:05:12 +0000 (20:05 -0500)]
Bump configure.ac to version 0.0.4.
Add -Wall -Werror to the automake command line.
Add the test suite to Makefile.am (will generate a `make check` target).

11 years agoFix the bug from the latest test case.
Michael Orlitzky [Fri, 25 Jan 2013 23:03:09 +0000 (18:03 -0500)]
Fix the bug from the latest test case.

11 years agoAdd a test for a newly-discovered bug.
Michael Orlitzky [Fri, 25 Jan 2013 22:58:20 +0000 (17:58 -0500)]
Add a test for a newly-discovered bug.

11 years agoReplace the global no_exec_mask variable with a slightly less-awful solution.
Michael Orlitzky [Fri, 25 Jan 2013 04:17:45 +0000 (23:17 -0500)]
Replace the global no_exec_mask variable with a slightly less-awful solution.

11 years agoWhitespace fix.
Michael Orlitzky [Fri, 25 Jan 2013 04:09:58 +0000 (23:09 -0500)]
Whitespace fix.

11 years agoAdd a manpage and update Makefile.am to install it.
Michael Orlitzky [Wed, 23 Jan 2013 17:25:16 +0000 (12:25 -0500)]
Add a manpage and update Makefile.am to install it.

11 years agoFinish Doxygen documentation.
Michael Orlitzky [Wed, 23 Jan 2013 16:08:20 +0000 (11:08 -0500)]
Finish Doxygen documentation.

11 years agoDocument more functions with Doxygen.
Michael Orlitzky [Sun, 20 Jan 2013 00:33:25 +0000 (19:33 -0500)]
Document more functions with Doxygen.
Replace magic exit codes with defined constants.
Replace a few failure codes with errors.

11 years agoBegin using Doxygen-style comments.
Michael Orlitzky [Sat, 19 Jan 2013 01:44:19 +0000 (20:44 -0500)]
Begin using Doxygen-style comments.
Add a Doxyfile.

11 years agoStore the test users in a bash array.
Michael Orlitzky [Fri, 18 Jan 2013 23:40:36 +0000 (18:40 -0500)]
Store the test users in a bash array.
Use separate exit codes for test failure and missing users.

11 years agoUse (bin,daemon) users instead of (mail,news).
Michael Orlitzky [Fri, 18 Jan 2013 23:13:09 +0000 (18:13 -0500)]
Use (bin,daemon) users instead of (mail,news).

11 years agoAdd a new command-line option, --no-exec-mask, that disables the exec bit masking...
Michael Orlitzky [Wed, 9 Jan 2013 20:45:15 +0000 (15:45 -0500)]
Add a new command-line option, --no-exec-mask, that disables the exec bit masking heuristics.
Add tests for the new command-line option.

11 years agoAdd the acl_execute_masked() function.
Michael Orlitzky [Wed, 9 Jan 2013 20:08:23 +0000 (15:08 -0500)]
Add the acl_execute_masked() function.
Rename any_can_execute to any_can_execute_or_dir().
Don't mask the execute bit if the target is a directory (more-closely follows setfacl's "X" behavior).

11 years agoAdd more tests in preparation for the -x fix.
Michael Orlitzky [Wed, 9 Jan 2013 20:07:52 +0000 (15:07 -0500)]
Add more tests in preparation for the -x fix.

11 years agoSet permissions on $TESTDIR in acl_reset.
Michael Orlitzky [Wed, 9 Jan 2013 19:36:13 +0000 (14:36 -0500)]
Set permissions on $TESTDIR in acl_reset.
Use equal signs to delimit expected/actual output.

11 years agoAdd two new tests for repeated application on a directory.
Michael Orlitzky [Tue, 8 Jan 2013 19:57:45 +0000 (14:57 -0500)]
Add two new tests for repeated application on a directory.

11 years agoRename the project to apply-default-acl. v0.0.3
Michael Orlitzky [Tue, 25 Dec 2012 20:55:11 +0000 (15:55 -0500)]
Rename the project to apply-default-acl.

11 years agoAdd a short -r flag example in the README. v0.0.2
Michael Orlitzky [Tue, 18 Dec 2012 21:35:51 +0000 (16:35 -0500)]
Add a short -r flag example in the README.

11 years agoAdd missing '$' in README.
Michael Orlitzky [Tue, 18 Dec 2012 21:25:51 +0000 (16:25 -0500)]
Add missing '$' in README.

11 years agoUpdate the install docs and usage info in the README.
Michael Orlitzky [Tue, 18 Dec 2012 06:11:07 +0000 (01:11 -0500)]
Update the install docs and usage info in the README.
Add the docs and test script to EXTRA_DIST.
Fix the binary path in the test script.

11 years agoAdd an autogen.sh.
Michael Orlitzky [Tue, 18 Dec 2012 06:10:53 +0000 (01:10 -0500)]
Add an autogen.sh.

11 years agoAdd a configure.ac, and replace the old makefile with two Makefile.am files.
Michael Orlitzky [Tue, 18 Dec 2012 05:56:36 +0000 (00:56 -0500)]
Add a configure.ac, and replace the old makefile with two Makefile.am files.

11 years agoUse getopt for option parsing.
Michael Orlitzky [Tue, 18 Dec 2012 05:01:42 +0000 (00:01 -0500)]
Use getopt for option parsing.

11 years agoAdd tests for --recursive mode.
Michael Orlitzky [Tue, 18 Dec 2012 04:26:03 +0000 (23:26 -0500)]
Add tests for --recursive mode.

11 years agoAdd a --recursive option.
Michael Orlitzky [Tue, 18 Dec 2012 04:07:09 +0000 (23:07 -0500)]
Add a --recursive option.
Update the usage() and option parsing for the new flag.

12 years agoFix a function name in some error messages.
Michael Orlitzky [Thu, 18 Oct 2012 12:18:15 +0000 (08:18 -0400)]
Fix a function name in some error messages.

12 years agoAdd a 'dist' makefile target. v0.0.1
Michael Orlitzky [Sun, 19 Aug 2012 15:49:06 +0000 (11:49 -0400)]
Add a 'dist' makefile target.

12 years agoAdd LICENSE and README files.
Michael Orlitzky [Sun, 19 Aug 2012 05:27:57 +0000 (01:27 -0400)]
Add LICENSE and README files.
Rename 'aclq' to 'reapply_default_acl' everywhere.

12 years agoFix command-line error handling.
Michael Orlitzky [Sat, 18 Aug 2012 02:01:02 +0000 (22:01 -0400)]
Fix command-line error handling.
Add a few comments.

12 years agoAdd one more test for the default mask execute bit.
Michael Orlitzky [Sat, 18 Aug 2012 01:38:06 +0000 (21:38 -0400)]
Add one more test for the default mask execute bit.

12 years agoFix an error string.
Michael Orlitzky [Wed, 15 Aug 2012 17:02:58 +0000 (13:02 -0400)]
Fix an error string.

12 years agoWhitespace cleanup.
Michael Orlitzky [Wed, 15 Aug 2012 16:59:17 +0000 (12:59 -0400)]
Whitespace cleanup.

12 years agoFix memory leaks.
Michael Orlitzky [Wed, 15 Aug 2012 16:14:15 +0000 (12:14 -0400)]
Fix memory leaks.

12 years agoRemove the TODO (it's done).
Michael Orlitzky [Wed, 15 Aug 2012 15:38:32 +0000 (11:38 -0400)]
Remove the TODO (it's done).

12 years agoAdd another test.
Michael Orlitzky [Wed, 15 Aug 2012 06:51:08 +0000 (02:51 -0400)]
Add another test.
Settle on the new reapplication algorithm.
Remove a ton of dead code.

12 years agoAdd a TODO.
Michael Orlitzky [Wed, 15 Aug 2012 04:24:50 +0000 (00:24 -0400)]
Add a TODO.

12 years agoUnfix one of those.
Michael Orlitzky [Wed, 15 Aug 2012 04:19:18 +0000 (00:19 -0400)]
Unfix one of those.

12 years agoFix two deps in the makefile.
Michael Orlitzky [Wed, 15 Aug 2012 04:18:41 +0000 (00:18 -0400)]
Fix two deps in the makefile.

12 years agoComplicate the shit out of everything to pass the new tests.
Michael Orlitzky [Wed, 15 Aug 2012 03:59:27 +0000 (23:59 -0400)]
Complicate the shit out of everything to pass the new tests.

12 years agoAdd a few more tricky tests.
Michael Orlitzky [Wed, 15 Aug 2012 03:59:19 +0000 (23:59 -0400)]
Add a few more tricky tests.

12 years agoAdd a 'test' makefile target.
Michael Orlitzky [Wed, 15 Aug 2012 00:21:30 +0000 (20:21 -0400)]
Add a 'test' makefile target.
Fix the group execute removal so that the last test passes.
Add a new test.

12 years agoGeneralize a few functions to non-default ACLs.
Michael Orlitzky [Tue, 14 Aug 2012 22:40:41 +0000 (18:40 -0400)]
Generalize a few functions to non-default ACLs.

12 years agoAdd another test and fool around with the logic trying to get it to pass.
Michael Orlitzky [Tue, 14 Aug 2012 21:12:28 +0000 (17:12 -0400)]
Add another test and fool around with the logic trying to get it to pass.

12 years agoAdd a test suite.
Michael Orlitzky [Tue, 14 Aug 2012 20:34:37 +0000 (16:34 -0400)]
Add a test suite.

12 years agoFix the logic so that it removes user/other read/write perms not specified in the...
Michael Orlitzky [Tue, 14 Aug 2012 20:34:10 +0000 (16:34 -0400)]
Fix the logic so that it removes user/other read/write perms not specified in the default ACL.
Don't print "Success."

12 years agoChange all return types to int.
Michael Orlitzky [Tue, 14 Aug 2012 19:16:44 +0000 (15:16 -0400)]
Change all return types to int.
Add the has_minimal_default_acl() function.
Make group bits correct in the presence of minimal ACLs.
Begin fixing group execute with extended ACLs.

12 years agoAdd -Wall and fix warnings.
Michael Orlitzky [Sun, 12 Aug 2012 23:44:37 +0000 (19:44 -0400)]
Add -Wall and fix warnings.

12 years agoImplement the reapply_default_acl function.
Michael Orlitzky [Sun, 12 Aug 2012 16:35:56 +0000 (12:35 -0400)]
Implement the reapply_default_acl function.

12 years agoAdd some non-working junk.
Michael Orlitzky [Wed, 8 Aug 2012 23:47:32 +0000 (19:47 -0400)]
Add some non-working junk.

12 years agoInitial commit, just exploring at the moment.
Michael Orlitzky [Wed, 8 Aug 2012 22:08:29 +0000 (18:08 -0400)]
Initial commit, just exploring at the moment.