Commit Graph

30414 Commits

Author SHA1 Message Date
Nicolas Williams
88e31d2da8 sl: Add missing sel-gram.h target 2022-01-21 23:15:21 -06:00
Nicolas Williams
cb9b1842ea sl: Fix bison/byacc invocation 2022-01-21 23:01:44 -06:00
Nicolas Williams
20497ed2d4 com_err: Fix bison/byacc invocation 2022-01-21 23:01:44 -06:00
Nicolas Williams
664b749399 hx509: Fix sel-gram.y shift/reduce conflicts
AND and OR are now binary operators, left-associative, with AND having
higher precedence than OR.

The not operator is now higher-precedence than the AND and OR operators.
2022-01-21 22:58:22 -06:00
Nicolas Williams
e1fa08a4d6 asn1: Fix 5 shift/reduce conflicts
There remains one tough shift/reduce conflict, the warning for which is
quieted with an `%expect 1` directive.

The remaining conflict has to do with whether a constraint attaches to
the inner type that some other outer type is a SET OF or SEQUENCE OF or
tagged-type of, or whether it attaches to the outer type.  The two are
really the same thing.  The latter is the reduce side, so it's not used,
but if it were we could grab the constraint in the action and attach it
to the inner type anyways.
2022-01-21 22:37:05 -06:00
Nicolas Williams
f0f6bb03f4 hdb: Lower-case HDB_DB_FORMAT to make it valid ASN.1
In order to resolve some shift/reduce conflicts in the ASn.1 compiler's
grammar we need to be strict about value names starting with lower case
and type names starting with upper-case.
2022-01-21 22:37:05 -06:00
Nicolas Williams
37f10aaf85 cf: Restore AC_KRB_PROG_YACC to life
Using `AC_PROG_YACC` means accepting that `bison` gets invoked in yacc
compatibility mode (i.e., with the `-y` command-line option).  In recent
versions Bison has started to warn about use of Bison extensions when in
yacc compatibility mode -- even for things yacc itself accepts but which
it doesn't document.

I've confirmed that `bison -d` and `byacc -d` both work for the ASN.1
compiler.
2022-01-21 22:37:04 -06:00
Luke Howard
366878c230 kdc: kdc_request_add_pac_buffer() make pactype unsigned
The pactype argument to kdc_request_add_pac_buffer() should be unsigned,
matching krb5_pac_add_buffer(). Reindent.
2022-01-22 11:43:38 +11:00
Jeffrey Altman
dafbfa666f kadmin: add_one_principal avoid shadow warning
8dcc5e617b
("kadmin: add_one_principal refactor") made 'princ_name' a
top-level variable.  This precludes the need to declare
subsequent block-level variables with the same name.

Change-Id: I4bf9e54b49a0e366ed4cd39920d3fe58439beb33
2022-01-21 10:39:57 -05:00
Jeffrey Altman
04527412e3 Follow the Linux kernel's lead on "fallthrough"
The pseudo keyword 'fallthrough' is defined such that case statement
blocks must end with any of these keywords:
 * break;
 * fallthrough;
 * continue;
 * goto <label>;
 * return [expression];
 *
 *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes

The macro is defined either as

  __attribute__((__fallthrough__))

or as

  do {} while (0)  /* fallthrough */

not including the semicolon.

This change implements the Linux kernel style and updates several locations
where "/*fallthrough*/ and /* FALLTHROUGH */ were not previously replaced.

Externally imported code such as libedit, libtommath and sqlite are
restored to their unaltered state.

Change-Id: I69db8167b0d5884f55d96d72de3059a0235a1ba3
2022-01-21 10:39:47 -05:00
Jeffrey Altman
02bd267fbd kadmin: kadmind_dispatch fix broken commit
124b8d0f78 ("kadmin: kadmind_dispatch
do not write NULL 'rsp' to 'out'") was committed with an
unintentional source code removal.

Change-Id: I3de21e3624d713a9b5a1e89d147a5db5f1f55ab1
2022-01-21 09:24:34 -05:00
Jeffrey Altman
124b8d0f78 kadmin: kadmind_dispatch do not write NULL 'rsp' to 'out'
1b213c1082 ("kadmind: Add missing
error checks") altered the behavior of kadmin_dispatch() such that
it unconditionally called

      krb5_storage_to_data(rsp, out);

This change was unsafe because krb5_unparse_name_fixed() failure
would skip the allocation of the 'rsp' and 'sp' krb5_storage
objects.

This change allocates the krb5_storage objects prior to performing
any work.  If either of them fail, kadmin_dispatch() immediately
returns ENOMEM.

Change-Id: I14fd96afe029a4e74bb769605286ca0e17d25043
2022-01-21 09:16:35 -05:00
Jeffrey Altman
251cbf05c2 Revert "kadmin: kadmind_dispatch do not write to 'out' on error"
This reverts commit fb52fd1c53.

The change caused tests/kdc/check-kadmin to fail.
2022-01-21 09:04:31 -05:00
Jeffrey Altman
cd91a3a03e appl/afsutil: expand_cell_name return NULL if not found
In function ‘afslog_cell.isra’:
  afslog.c:144:13: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  144 |            warnx("No cell matching \"%s\" found.", cell);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

caused by expand_cell_name() returning the input pointer.
Alter the behavior of expand_cell_name() to match its usage.

Change-Id: I3b15c4b3e59b597af5351e5e62f5d7751be50feb
2022-01-21 08:51:28 -05:00
Jeffrey Altman
8dcc5e617b kadmin: add_one_principal refactor
If rand_password is true, allocate princ_name early to prevent
memory allocation errors after the principal was added.

Use memset_s to clear the 'password' so that it will not be
optimized away.

Change-Id: I80d11546166d2350e6a79c5a376cb9e8cb191fa3
2022-01-21 00:44:10 -05:00
Jeffrey Altman
912b20c4d7 kadmin: refactor set_random_password
Obtain the unparsed principal name early so that there is no
risk of memory allocation failure after kadm5_chpass_principal_3()
succeeds.

Change-Id: I389281004826da5752081c2f26127d55e3dc3989
2022-01-21 00:31:56 -05:00
Jeffrey Altman
fb52fd1c53 kadmin: kadmind_dispatch do not write to 'out' on error
1b213c1082 ("kadmind: Add missing
error checks") altered the behavior of kadmin_dispatch() such that
it unconditionally called

  krb5_storage_to_data(rsp, out);

Previously kadmin_dispatch() only wrote to 'out' on success.
Doing so is important because 'rsp' might be NULL on error.

Change-Id: I2688a5c47db0f94d955971e785037c578d3f3fa4
2022-01-21 00:25:15 -05:00
Jeffrey Altman
4ffd190b08 kadmin: kadmind_dispatch fix handling of HEIM_ERR_EOF error
1b213c1082 ("kadmind: Add missing
error checks") altered the scope of the

   if (ret == HEIM_ERR_EOF)
      ret = 0;

treatment of HEIM_ERR_EOF as a success code.  Prior to that
commit HEIM_ERR_EOF meant success only when reading the 'keepold'
value.  It indicated a premature failure if returned when reading
'princ' or 'n_key_data'.

This change corrects the scope of HEIM_ERR_EOF indicating success.

Change-Id: If5463b47dc3eabee6fa2f8e717147f02adc1586c
2022-01-20 23:43:06 -05:00
Jeffrey Altman
81f3a0b804 lib/hdb: ndbm correct asprintf error handling
asprintf() return code must be checked because in case of failure
the value of the output buffer variable is undefined.

Change-Id: I75e06fffe2330ec10dbe4f678479ded479ab5931
2022-01-20 23:33:11 -05:00
Jeffrey Altman
2e54dc7aae lib/hcrypto: DES_cfb64_encrypt init buffer in decrypt path 2022-01-20 21:29:11 -05:00
Luke Howard
8946f0de9d gss_preauth: remove dead code
The intent was to map KRB5KRB_AP_ERR_BAD_INTEGRITY and HNTLM_ERR_AUTH to
KRB5KRB_AP_ERR_BAD_INTEGRITY, but this code was never reached.
2022-01-21 10:09:44 +11:00
Luke Howard
fce4d19953 kdc: declare calling/linkage conventions for accessors
Decorate generated accessors with KDC_LIB_FUNCTION/KDC_LIB_CALL for correct
linkage on Windows.
2022-01-21 08:22:07 +11:00
Nicolas Williams
fea2ce1831 GitHub: OSX: what's running on port 49188 anyways? 2022-01-20 15:10:54 -06:00
Nicolas Williams
06ba7b1597 test: When kdc fails to start, show the log
This is an attempt to find out why the GitHub Actions OS X build is
failing.
2022-01-20 14:32:17 -06:00
Nicolas Williams
7e67437594 GitHub: Add optional coverity build 2022-01-20 13:54:51 -06:00
Nicolas Williams
588e49a1bc kdc: Fix copy_Principal_ptr() bug (plugin acc.) 2022-01-20 13:32:31 -06:00
Nicolas Williams
681708f416 gsskrb5: Fix coverity issue 2022-01-20 13:28:57 -06:00
Nicolas Williams
62176f07d9 kuser: Fix coverity issues 2022-01-20 13:28:39 -06:00
Nicolas Williams
be6305b601 kadm5: Fix ENOMEM path leak 2022-01-20 12:41:39 -06:00
Nicolas Williams
b0fa256521 krb5: Fix coverity warning in krcache.c 2022-01-20 12:41:39 -06:00
Nicolas Williams
b991c4b2b3 hdb: Fix coverity warnings
This is a fix for a false positive that we can avoid by changing the
internal API in question.  Might as well.
2022-01-20 12:41:39 -06:00
Nicolas Williams
d1564ce6e9 kcm: Fix coverity issues 2022-01-20 12:41:39 -06:00
Jeffrey Altman
7ab7fdd269 update .gitignore 2022-01-20 12:49:19 -05:00
Jeffrey Altman
34e918f210 lib/krb5: unparse_name_fixed ERANGE if zero buffer len
The tests depend upon an ERANGE error for buffer length zero.
They broken due to 8324a2af1d
("lib/krb5: unparse_name_fixed error if invalid name buffer or length")
which returned EINVAL.

Change-Id: I81693f9d3f5fdc1838c11ffbfe0dafc742d9b207
2022-01-20 11:09:04 -05:00
Jeffrey Altman
d55abd8f50 lib/krb5: make_local_fast_ap_fxarmor requires a ccache
If make_local_fast_ap_fxarmor() is called without a ccache
it will segmentation fault.  Set a krb5 error message in the
context and fail with EINVAL.

Change-Id: I8a72a026dbae931e41498f55cd634ad2fee26772
2022-01-20 10:22:51 -05:00
Jeffrey Altman
966e98d50b lib/krb5: fcc_remove_cred return krb5_cc_end_seq_get failure
krb5_cc_end_seq_get() is not expected to fail because it is a
cleanup routine.  If it fails it indicates something wrong with
the cache or the system.  Return the failure if there is one.

Otherwise, the failure from krb5_cc_next_cred() should be
returned UNLESS it is KRB5_CC_END in which case return success.

Change-Id: I80e07103e2fb38aa40418a436fa5351fb89549d3
2022-01-20 10:06:11 -05:00
Jeffrey Altman
29940dd22c lib/krb5: krb5_init_creds_set_service fail if set_realm fails
Calls to krb5_principal_set_realm() can fail due to memory
allocation failures.  If the client realm cannot be set in
the generated principal the wrong realm will be used.
Check for the result of krb5_principal_set_realm() and if
there is a failure, clean up and return the error code to
the caller.

Change-Id: Icadd04c858e88c1ba1d4344c60a784885a6a1344
2022-01-20 09:44:43 -05:00
Jeffrey Altman
8324a2af1d lib/krb5: unparse_name_fixed error if invalid name buffer or length
If the output 'name' buffer is NULL or length is zero, there is
no place to unparse the principal name to.  Fail with EINVAL and
if possible set an error message on the krb5_context.

This avoids potential NULL pointer dereferences.

Change-Id: Ie38d284f1867be883a2f2e31103ea50cd130a0fe
2022-01-20 09:27:59 -05:00
Jeffrey Altman
8836e6a39d lib/krb5: krb5_vset_error_message is no-op if no krb5_context
Refactor krb5_vset_error_message() to remove the many conditional
tests on the existence of krb5_context.  If there is no krb5_context
then _krb5_debug() is a no-op.  Therefore, there is no point in
performing any of the other work.

Change-Id: Ib88b592a542a195f27e352a80ced0a98a6f85300
2022-01-20 09:09:27 -05:00
Luke Howard
e32f7a4387 kdc: add _nocopy setter for use by mssfu
Add an internal-use setter accessor for use by mssfu.c when principal names are
replaced. This also fixes a leak where r->client_princ was not freed before
being replaced with the impersonated client name.
2022-01-20 17:23:24 +11:00
Luke Howard
ec24edf700 kdc: add accessor functions for KDC request structure
Add accessor functions for use by Samba and other plugin developers.
Documentation is in kdc/kdc-accessors.h.
2022-01-20 17:23:24 +11:00
Luke Howard
ed4fe65794 base: change ret fieldname to error_code in request struct 2022-01-20 17:23:24 +11:00
Luke Howard
f4e936c893 include: fix token_validator_plugin.h typo
token_validator_plugin.h was also missing in Makefile.am:CLEANFILES.
2022-01-20 17:23:11 +11:00
Nicolas Williams
302250026c kdc: Do not announce via Bonjour when testing
Let's see if this fixes the GitHub Actions OS X CI.
2022-01-20 00:20:30 -06:00
Luke Howard
0c26edd468 include: add more generated files to CLEANFILES
take #2, fix build breakage.

Recently added features for Heimdal 8 did not update
include/Makefile.am:CLEANFILES appropriately.
2022-01-20 17:17:58 +11:00
Luke Howard
d74b411f12 Revert "include: add more generated files to CLEANFILES"
This reverts commit 622527d9ca.
2022-01-20 17:17:09 +11:00
Luke Howard
622527d9ca include: add more generated files to CLEANFILES
Recently added features for Heimdal 8 did not update
include/Makefile.am:CLEANFILES appropriately.
2022-01-20 17:15:51 +11:00
Nicolas Williams
9d0149d2f2 krb5: Context has to be opt. in for path tok. exp. 2022-01-19 23:49:06 -06:00
Nicolas Williams
1eda4920c8 krb5: Fix coverity warnings 2022-01-19 23:38:27 -06:00
Nicolas Williams
9203c4a3f4 ipropd: Ignore setsockopt() result 2022-01-19 23:37:32 -06:00