Commit Graph

239 Commits

Author SHA1 Message Date
Dag-Erling Smørgrav d619fcb520 Through oversight, the PAM_LOG_LIBDEBUG case was left out in the
version of openpam_log() that's actually used.  Internal debugging
messages therefore went to the default case and were logged as errors,
spamming /var/log/messages and the console.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@544 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-03-31 22:47:15 +00:00
Dag-Erling Smørgrav e29b3b276f Even though I now prefer the 2-clause BSD license, for practical
reasons, it is easier to use the 3-clause BSD license even for new
additions to OpenPAM.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@543 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-03-31 22:11:34 +00:00
Dag-Erling Smørgrav f163a4b9df spelling
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@539 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-03-31 20:53:22 +00:00
Dag-Erling Smørgrav 783a383e4b Save errno before calling asprintf(), since asprintf() may touch errno,
which will cause syslog() to log the wrong error message if the format
string contains %m.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@537 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-03-31 16:20:13 +00:00
Dag-Erling Smørgrav 74c787f664 Avoid underflow if *size == 0.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@536 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-03-31 15:34:19 +00:00
Dag-Erling Smørgrav 8e881dbdd7 Fix some embarassing typos introduced in the openpam_straddch() cleanup.
Move prototype from "opempam_impl.h" to <security/openpam.h>.
Generate openpam_straddch(3) man page.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@535 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-03-31 14:55:19 +00:00
Dag-Erling Smørgrav be3bfed604 Clean up and document
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@533 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-03-31 14:25:43 +00:00
Dag-Erling Smørgrav b3a9a4792f Redundant #include
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@532 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-03-31 14:24:53 +00:00
Dag-Erling Smørgrav 2e479f3c12 Redundant #include
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@531 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-03-31 14:24:37 +00:00
Dag-Erling Smørgrav 42651f8d9b Add an internal function for appending a character to a dynamically
allocated string, expanding the string if necessary.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@528 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-02-26 03:34:46 +00:00
Dag-Erling Smørgrav 7d5d2733f5 Rename sigset to the_sigset to avoid shadowing sigset(3).
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@527 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-02-26 03:23:59 +00:00
Dag-Erling Smørgrav cf0963e668 Improve error messages by logging the full path of the module we tried
to load rather than just the module name.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@525 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-01-11 00:45:09 +00:00
Dag-Erling Smørgrav c3d9f63b55 Fix a regression introduced by r487. The count was actually used to
determine whether to stop searching for a policy.  After r487,
multiple policies for the same service would be concatenated, whereas
the intention was that the one that came first in the policy path
should eclipse the others.

While there, take the time to reorganize the front end of the policy
loading code, both to clarify the logic and to produce better log
messages in case of errors.  The most important change is that
openpam_load_chain() now opens and vets the policy file before calling
openpam_parse_chain(), so it is better able to distinguish between
errors relating to the file itself and errors relating to its
contents.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@524 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-01-11 00:29:48 +00:00
Dag-Erling Smørgrav 88a6cda1a1 Reluctantly document PAM_LOG_LIBDEBUG.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@523 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-01-11 00:15:24 +00:00
Dag-Erling Smørgrav b616ada557 Add another log level, PAM_LOG_LIBDEBUG, with a negative priority. It
is currently equivalent to PAM_LOG_DEBUG, and is used only by the
library call tracing macros (ENTER*() and RETURN*()).  It should
eventually replace PAM_LOG_DEBUG throughout the library, except
perhaps for a few particularly interesting messages; PAM_LOG_DEBUG
will be reserved for modules.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@522 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-01-11 00:13:25 +00:00
Dag-Erling Smørgrav df3d585d08 Reduce log spam.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@521 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-01-11 00:03:18 +00:00
Dag-Erling Smørgrav 34c9fb6fd3 Only call dlerror() after dlsym() failed.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@520 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-01-10 23:57:31 +00:00
Dag-Erling Smørgrav 31e9142afc Verify that the target is a regular file.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@519 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-01-10 23:50:03 +00:00
Dag-Erling Smørgrav 8c2f4c74b7 Use fdlopen(3) if it is available.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@516 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-01-10 21:26:34 +00:00
Dag-Erling Smørgrav 41bb288744 The only place RETURNP() is used returns a non-const pointer.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@511 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2012-01-09 13:25:09 +00:00
Dag-Erling Smørgrav 596b3af085 Use a different default prompt if PAM_RHOST != PAM_HOST.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@510 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-12-31 13:14:23 +00:00
Dag-Erling Smørgrav 8ec4a16273 Don't log an error message if the file does not exist.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@509 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-12-22 17:18:53 +00:00
Dag-Erling Smørgrav 95ed7f5d0c Style / consistency
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@503 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-12-18 14:00:33 +00:00
Dag-Erling Smørgrav dd498bc7ad Use openpam_check_path_owner_perms()
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@502 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-12-18 13:59:22 +00:00
Dag-Erling Smørgrav 996a845863 Report an error if one of the modules in the chain does not implement
the requested primitive.  This is a significant change, but it should
only affect poorly-written PAM modules, and the alternative is a
potential fail-open situation.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@501 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-12-07 01:28:05 +00:00
Dag-Erling Smørgrav 229c006c86 Forgotten in previous commit: check the ownership and permissions of the
policy file.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@500 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-22 12:07:03 +00:00
Dag-Erling Smørgrav 1a4edb80d7 Factor out and improve the module ownership / permission check, and add
a similar (but race-proof) check for the policy file.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@499 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-22 11:51:50 +00:00
Dag-Erling Smørgrav b9f0b632da Validate the service name, closing an attack vector for programs like
kcheckpass that let the user specify which policy to apply.  See
<URL:http://c-skills.blogspot.com/2011/11/openpam-trickery.html>.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@497 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-21 16:25:49 +00:00
Dag-Erling Smørgrav 026c898ec5 Disallow changing the service name.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@496 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-21 16:20:45 +00:00
Dag-Erling Smørgrav d9f7580763 nit
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@494 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-20 02:58:34 +00:00
Dag-Erling Smørgrav d98f755c25 Refuse to load a module if it is owned by anyone else than root or the
arbitrator or it is writable by group or other.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@493 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-20 02:28:15 +00:00
Dag-Erling Smørgrav b011e58526 dst can't be const, you idiot.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@492 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-20 02:04:17 +00:00
Dag-Erling Smørgrav 6a92548403 Reorganize the headers and centralize the string tables.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@491 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-12 00:12:32 +00:00
Dag-Erling Smørgrav ff73a20a84 Add a strlcpy(3) implementation.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@490 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-11 03:04:46 +00:00
Dag-Erling Smørgrav e8522c7fcc Always create optv, even if there are no options.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@488 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-05 20:50:15 +00:00
Dag-Erling Smørgrav c86a681052 The count was never used, so ditch it and return plain PAM error codes
instead.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@487 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-05 20:00:46 +00:00
Dag-Erling Smørgrav ba7de9c9c6 Remove debugging code.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@484 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-03 16:47:26 +00:00
Dag-Erling Smørgrav 493804d19b Fix a couple of bugs in the option string reassembly code.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@483 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-03 16:46:20 +00:00
Dag-Erling Smørgrav 6835696a2a Revert large parts of r478. I had forgotten that the module arguments
are actually passed to each service function in the classic (argc,
argv) form.  The only place where the compiler could have caught this
used a type cast, and it did not show up in testing either because all
of the modules I tested use openpam_get_option(3) instead of
manipulating argv directly.

The cleaned-up policy parsing code remains in place, but options are
once more stored as strings, pretty much the way they appear in the
policy file, except that quotes are stripped.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@482 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-03 16:33:02 +00:00
Dag-Erling Smørgrav c16faba34e The include directive expects a service name, not a filename.
While there, remember to check for trailing garbage.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@481 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-03 16:09:22 +00:00
Dag-Erling Smørgrav b373991f87 namespace violation mumble mumble
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@479 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-03 15:40:15 +00:00
Dag-Erling Smørgrav 55f6a50684 Major overhaul of the policy parser to support quoted option values. As a
bonus, it should now be much easier to read and understand.

This also changes the way options are stored: they are now stored as a list
of { key, value } pairs rather than "key=value" strings.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@478 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-03 15:39:18 +00:00
Dag-Erling Smørgrav 11b10d0991 Minor simplification.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@477 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-03 15:30:34 +00:00
Dag-Erling Smørgrav 9b234e1f88 Provide strlcmp(3) internally on systems that don't already have it.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@475 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-03 15:29:24 +00:00
Dag-Erling Smørgrav f229d69d05 Fix the case where match_word() matches the last word on the line. It
would previously return 0 because it expected the next character after
the matched word to be a space.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@474 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-03 10:56:10 +00:00
Dag-Erling Smørgrav ebccc4d687 - Deduplicate the trailing-whitespace code.
- Don't treat "\\\n" as whitespace.  It's not what most people would
  expect, and the documentation doesn't mention it.
- Improve the documentation a bit now that gendoc.pl supports bullet
  lists.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@473 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-03 10:48:25 +00:00
Dag-Erling Smørgrav dd2c21f7b6 Mention that the service function is called twice.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@466 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-02 23:33:43 +00:00
Dag-Erling Smørgrav 956ef0df60 If a module directory was specified on the configure command line, the
OPENPAM_MODULES_DIR macro was defined in config.h in addition to
CFLAGS.  Place OPENPAM_MODULES_DIR unconditionally in config.h and
remove it from CFLAGS.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@462 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-02 15:04:31 +00:00
Dag-Erling Smørgrav a1be39bf2d Fix namespace violations in local variables used to prevent double
evaluation in macros.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@461 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-02 14:00:38 +00:00
Dag-Erling Smørgrav 0eae3f21c1 Fix namespace violations in some symbols which have external linkage but
are not part of the API.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@460 185d5e19-27fe-0310-9dcf-9bff6b9f3609
2011-11-02 13:56:03 +00:00