Skip to content

Commit

Permalink
kdc: Don't reference ENODATA in platform-independent code
Browse files Browse the repository at this point in the history
FreeBSD has ENOATTR but not ENODATA, Linux has ENODATA but not ENOATTR for
returning "attr does not exist". With 2eb899d we settled on ENOATTR to
handle this case.

Alternatively we could

 #define ENODATA ENOATTR

on FreeBSD...

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: douglas.bagnall@catalyst.net.nz

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Jan 19 09:24:15 UTC 2023 on atb-devel-224
  • Loading branch information
vlendec committed Jan 19, 2023
1 parent 84f56f2 commit 872ea49
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions source4/kdc/mit_samba.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "param/param.h"
#include "dsdb/samdb/samdb.h"
#include "system/kerberos.h"
#include "lib/replace/system/filesys.h"
#include <com_err.h>
#include <kdb.h>
#include <kadm5/kadm_err.h>
Expand Down Expand Up @@ -640,7 +641,7 @@ krb5_error_code mit_samba_reget_pac(struct mit_samba_context *ctx,
new_pac);
if (code != 0) {
krb5_pac_free(context, new_pac);
if (code == ENODATA) {
if (code == ENOATTR) {
krb5_pac_free(context, *pac);
*pac = NULL;
code = 0;
Expand Down Expand Up @@ -740,7 +741,7 @@ krb5_error_code mit_samba_update_pac(struct mit_samba_context *ctx,
old_pac,
new_pac);
if (code != 0) {
if (code == ENODATA) {
if (code == ENOATTR) {
/*
* We can't tell the KDC to not issue a PAC. It will
* just return the newly allocated empty PAC.
Expand Down
7 changes: 4 additions & 3 deletions source4/kdc/pac-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "lib/replace/replace.h"
#include "lib/replace/system/kerberos.h"
#include "lib/replace/system/filesys.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
#include "lib/util/talloc_stack.h"
Expand Down Expand Up @@ -1401,7 +1402,7 @@ WERROR samba_rodc_confirm_user_is_allowed(uint32_t num_object_sids,
* @param new_pac The new already allocated PAC
* @return A Kerberos error code. If no PAC should be returned, the code will be
* ENODATA!
* ENOATTR!
*/
krb5_error_code samba_kdc_update_pac(TALLOC_CTX *mem_ctx,
krb5_context context,
Expand Down Expand Up @@ -1756,7 +1757,7 @@ krb5_error_code samba_kdc_update_pac(TALLOC_CTX *mem_ctx,
* need to re-generate anything anyway.
*/
if (!samba_princ_needs_pac(server)) {
code = ENODATA;
code = ENOATTR;
goto done;
}

Expand All @@ -1779,7 +1780,7 @@ krb5_error_code samba_kdc_update_pac(TALLOC_CTX *mem_ctx,
&requested_pac);
if (code != 0 || !requested_pac) {
if (!requested_pac) {
code = ENODATA;
code = ENOATTR;
}
goto done;
}
Expand Down
3 changes: 2 additions & 1 deletion source4/kdc/wdc-samba4.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "sdb_hdb.h"
#include "librpc/gen_ndr/auth.h"
#include <krb5_locl.h>
#include "lib/replace/system/filesys.h"

#undef DBGC_CLASS
#define DBGC_CLASS DBGC_KERBEROS
Expand Down Expand Up @@ -361,7 +362,7 @@ static krb5_error_code samba_wdc_reget_pac2(astgs_request_t r,
new_pac);
if (ret != 0) {
krb5_pac_free(context, new_pac);
if (ret == ENODATA) {
if (ret == ENOATTR) {
krb5_pac_free(context, *pac);
*pac = NULL;
ret = 0;
Expand Down

0 comments on commit 872ea49

Please sign in to comment.