LCOV - code coverage report
Current view: top level - util - domain_info_utils.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 31 47 66.0 %
Date: 2012-11-29 Functions: 1 2 50.0 %
Branches: 8 100 8.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :     Authors:
       3                 :            :         Sumit Bose <sbose@redhat.com>
       4                 :            : 
       5                 :            :     Copyright (C) 2012 Red Hat
       6                 :            : 
       7                 :            :     This program is free software; you can redistribute it and/or modify
       8                 :            :     it under the terms of the GNU General Public License as published by
       9                 :            :     the Free Software Foundation; either version 3 of the License, or
      10                 :            :     (at your option) any later version.
      11                 :            : 
      12                 :            :     This program is distributed in the hope that it will be useful,
      13                 :            :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :            :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15                 :            :     GNU General Public License for more details.
      16                 :            : 
      17                 :            :     You should have received a copy of the GNU General Public License
      18                 :            :     along with this program.  If not, see <http://www.gnu.org/licenses/>.
      19                 :            : */
      20                 :            : 
      21                 :            : #include "confdb/confdb.h"
      22                 :            : #include "db/sysdb.h"
      23                 :            : #include "util/util.h"
      24                 :            : 
      25                 :          3 : struct sss_domain_info *new_subdomain(TALLOC_CTX *mem_ctx,
      26                 :            :                                       struct sss_domain_info *parent,
      27                 :            :                                       const char *name,
      28                 :            :                                       const char *flat_name,
      29                 :            :                                       const char *id)
      30                 :            : {
      31                 :            :     int ret;
      32                 :          3 :     struct sss_domain_info *dom = NULL;
      33                 :            : 
      34                 :          3 :     dom = talloc_zero(mem_ctx, struct sss_domain_info);
      35         [ -  + ]:          3 :     if (dom == NULL) {
      36 [ #  # ][ #  # ]:          0 :         DEBUG(SSSDBG_OP_FAILURE, ("talloc_zero failed.\n"));
         [ #  # ][ #  # ]
                 [ #  # ]
      37                 :            :         return NULL;
      38                 :            :     }
      39                 :            : 
      40                 :          3 :     dom->parent = parent;
      41                 :          3 :     dom->name = talloc_strdup(dom, name);
      42         [ -  + ]:          3 :     if (dom->name == NULL) {
      43 [ #  # ][ #  # ]:          0 :         DEBUG(SSSDBG_OP_FAILURE, ("Failed to copy domain name.\n"));
         [ #  # ][ #  # ]
                 [ #  # ]
      44                 :            :         goto fail;
      45                 :            :     }
      46                 :            : 
      47                 :          3 :     dom->provider = talloc_strdup(dom, parent->provider);
      48         [ -  + ]:          3 :     if (dom->provider == NULL) {
      49 [ #  # ][ #  # ]:          0 :         DEBUG(SSSDBG_OP_FAILURE, ("Failed to copy provider name.\n"));
         [ #  # ][ #  # ]
                 [ #  # ]
      50                 :            :         goto fail;
      51                 :            :     }
      52                 :            : 
      53                 :          3 :     dom->conn_name = talloc_strdup(dom, parent->conn_name);
      54         [ -  + ]:          3 :     if (dom->conn_name == NULL) {
      55 [ #  # ][ #  # ]:          0 :         DEBUG(SSSDBG_OP_FAILURE, ("Failed to copy connection name.\n"));
         [ #  # ][ #  # ]
                 [ #  # ]
      56                 :            :         goto fail;
      57                 :            :     }
      58                 :            : 
      59         [ -  + ]:          3 :     if (flat_name != NULL) {
      60                 :          0 :         dom->flat_name = talloc_strdup(dom, flat_name);
      61         [ #  # ]:          0 :         if (dom->flat_name == NULL) {
      62 [ #  # ][ #  # ]:          0 :             DEBUG(SSSDBG_OP_FAILURE, ("Failed to copy flat name.\n"));
         [ #  # ][ #  # ]
                 [ #  # ]
      63                 :            :             goto fail;
      64                 :            :         }
      65                 :            :     }
      66                 :            : 
      67         [ -  + ]:          3 :     if (id != NULL) {
      68                 :          0 :         dom->domain_id = talloc_strdup(dom, id);
      69         [ #  # ]:          0 :         if (dom->domain_id == NULL) {
      70 [ #  # ][ #  # ]:          0 :             DEBUG(SSSDBG_OP_FAILURE, ("Failed to copy id.\n"));
         [ #  # ][ #  # ]
                 [ #  # ]
      71                 :            :             goto fail;
      72                 :            :         }
      73                 :            :     }
      74                 :            : 
      75                 :          3 :     dom->enumerate = false;
      76                 :          3 :     dom->fqnames = false;
      77                 :            :     /* FIXME: get ranges from the server */
      78                 :          3 :     dom->id_min = 0;
      79                 :          3 :     dom->id_max = 0xffffffff;
      80                 :          3 :     dom->pwd_expiration_warning = parent->pwd_expiration_warning;
      81                 :          3 :     dom->cache_credentials = parent->cache_credentials;
      82                 :          3 :     dom->case_sensitive = false;
      83                 :          3 :     dom->user_timeout = parent->user_timeout;
      84                 :          3 :     dom->group_timeout = parent->group_timeout;
      85                 :          3 :     dom->netgroup_timeout = parent->netgroup_timeout;
      86                 :          3 :     dom->service_timeout = parent->service_timeout;
      87                 :          3 :     dom->override_homedir = parent->override_homedir;
      88                 :          3 :     dom->names = parent->names;
      89                 :            : 
      90                 :          3 :     dom->subdomain_homedir = parent->subdomain_homedir;
      91                 :            : 
      92         [ -  + ]:          3 :     if (parent->sysdb == NULL) {
      93 [ #  # ][ #  # ]:          0 :         DEBUG(SSSDBG_OP_FAILURE, ("Missing sysdb context in parent domain.\n"));
         [ #  # ][ #  # ]
                 [ #  # ]
      94                 :            :         goto fail;
      95                 :            :     }
      96                 :          3 :     ret = sysdb_get_subdomain_context(dom, parent->sysdb, dom, &dom->sysdb);
      97         [ -  + ]:          3 :     if (ret != EOK) {
      98 [ #  # ][ #  # ]:          0 :         DEBUG(SSSDBG_OP_FAILURE, ("sysdb_get_subdomain_context failed.\n"));
         [ #  # ][ #  # ]
                 [ #  # ]
      99                 :            :         goto fail;
     100                 :            :     }
     101                 :            : 
     102                 :            :     return dom;
     103                 :            : 
     104                 :            : fail:
     105                 :          0 :     talloc_free(dom);
     106                 :          3 :     return NULL;
     107                 :            : }
     108                 :            : 
     109                 :          0 : struct sss_domain_info *copy_subdomain(TALLOC_CTX *mem_ctx,
     110                 :            :                                        struct sss_domain_info *subdomain)
     111                 :            : {
     112                 :          0 :     return new_subdomain(mem_ctx, subdomain->parent, subdomain->name,
     113                 :          0 :                          subdomain->flat_name, subdomain->domain_id);
     114                 :            : }

Generated by: LCOV version 1.9