"Fossies" - the Fresh Open Source Software Archive

Member "sssd-2.2.3/src/providers/ad/ad_pac_common.c" (30 Nov 2019, 2453 Bytes) of package /linux/misc/sssd-2.2.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ad_pac_common.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2     SSSD
    3 
    4     Authors:
    5         Sumit Bose <sbose@redhat.com>
    6 
    7     Copyright (C) 2016 Red Hat
    8 
    9     This program is free software; you can redistribute it and/or modify
   10     it under the terms of the GNU General Public License as published by
   11     the Free Software Foundation; either version 3 of the License, or
   12     (at your option) any later version.
   13 
   14     This program is distributed in the hope that it will be useful,
   15     but WITHOUT ANY WARRANTY; without even the implied warranty of
   16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17     GNU General Public License for more details.
   18 
   19     You should have received a copy of the GNU General Public License
   20     along with this program.  If not, see <http://www.gnu.org/licenses/>.
   21 */
   22 
   23 
   24 #include "providers/ad/ad_pac.h"
   25 #include "util/util.h"
   26 
   27 errno_t ad_get_data_from_pac(TALLOC_CTX *mem_ctx,
   28                              uint8_t *pac_blob, size_t pac_len,
   29                              struct PAC_LOGON_INFO **_logon_info)
   30 {
   31     DATA_BLOB blob;
   32     struct ndr_pull *ndr_pull;
   33     struct PAC_DATA *pac_data;
   34     enum ndr_err_code ndr_err;
   35     size_t c;
   36     int ret;
   37     TALLOC_CTX *tmp_ctx;
   38 
   39     tmp_ctx = talloc_new(NULL);
   40     if (tmp_ctx == NULL) {
   41         DEBUG(SSSDBG_OP_FAILURE, "talloc_new failed.\n");
   42         return ENOMEM;
   43     }
   44 
   45     blob.data = pac_blob;
   46     blob.length = pac_len;
   47 
   48     ndr_pull = ndr_pull_init_blob(&blob, tmp_ctx);
   49     if (ndr_pull == NULL) {
   50         DEBUG(SSSDBG_OP_FAILURE, "ndr_pull_init_blob failed.\n");
   51         ret = ENOMEM;
   52         goto done;
   53     }
   54     ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC; /* FIXME: is this really needed ? */
   55 
   56     pac_data = talloc_zero(tmp_ctx, struct PAC_DATA);
   57     if (pac_data == NULL) {
   58         DEBUG(SSSDBG_OP_FAILURE, "talloc_zero failed.\n");
   59         ret = ENOMEM;
   60         goto done;
   61     }
   62 
   63     ndr_err = ndr_pull_PAC_DATA(ndr_pull, NDR_SCALARS|NDR_BUFFERS, pac_data);
   64     if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
   65         DEBUG(SSSDBG_OP_FAILURE, "ndr_pull_PAC_DATA failed [%d]\n", ndr_err);
   66         ret =  EBADMSG;
   67         goto done;
   68     }
   69 
   70     for(c = 0; c < pac_data->num_buffers; c++) {
   71         if (pac_data->buffers[c].type == PAC_TYPE_LOGON_INFO) {
   72             *_logon_info = talloc_steal(mem_ctx,
   73                                     pac_data->buffers[c].info->logon_info.info);
   74 
   75             ret = EOK;
   76             goto done;
   77         }
   78     }
   79 
   80     ret = EINVAL;
   81 
   82 done:
   83     talloc_free(tmp_ctx);
   84 
   85     return ret;
   86 }