LCOV - code coverage report
Current view: top level - lib/krb5 - error.c (source / functions) Hit Total Coverage
Test: GNU Generic Security Service Lines: 0 26 0.0 %
Date: 2010-05-20 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 17 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* krb5/error.c --- Kerberos 5 GSS-API error handling functionality.
       2                 :            :  * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010  Simon Josefsson
       3                 :            :  *
       4                 :            :  * This file is part of the Generic Security Service (GSS).
       5                 :            :  *
       6                 :            :  * GSS is free software; you can redistribute it and/or modify it
       7                 :            :  * under the terms of the GNU General Public License as published by
       8                 :            :  * the Free Software Foundation; either version 3 of the License, or
       9                 :            :  * (at your option) any later version.
      10                 :            :  *
      11                 :            :  * GSS is distributed in the hope that it will be useful, but WITHOUT
      12                 :            :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
      13                 :            :  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
      14                 :            :  * License for more details.
      15                 :            :  *
      16                 :            :  * You should have received a copy of the GNU General Public License
      17                 :            :  * along with GSS; if not, see http://www.gnu.org/licenses or write to
      18                 :            :  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth
      19                 :            :  * Floor, Boston, MA 02110-1301, USA.
      20                 :            :  *
      21                 :            :  */
      22                 :            : 
      23                 :            : /* Get specification. */
      24                 :            : #include "k5internal.h"
      25                 :            : 
      26                 :            : struct gss_status_codes
      27                 :            : {
      28                 :            :   gss_uint32 err;
      29                 :            :   const char *name;
      30                 :            :   const char *text;
      31                 :            : };
      32                 :            : 
      33                 :            : static struct gss_status_codes gss_krb5_errors[] = {
      34                 :            :   /* 4.1.1. Non-Kerberos-specific codes */
      35                 :            :   {GSS_KRB5_S_G_BAD_SERVICE_NAME, "GSS_KRB5_S_G_BAD_SERVICE_NAME",
      36                 :            :    N_("No @ in SERVICE-NAME name string")},
      37                 :            :   {GSS_KRB5_S_G_BAD_STRING_UID, "GSS_KRB5_S_G_BAD_STRING_UID",
      38                 :            :    N_("STRING-UID-NAME contains nondigits")},
      39                 :            :   {GSS_KRB5_S_G_NOUSER, "GSS_KRB5_S_G_NOUSER",
      40                 :            :    N_("UID does not resolve to username")},
      41                 :            :   {GSS_KRB5_S_G_VALIDATE_FAILED, "GSS_KRB5_S_G_VALIDATE_FAILED",
      42                 :            :    N_("Validation error")},
      43                 :            :   {GSS_KRB5_S_G_BUFFER_ALLOC, "GSS_KRB5_S_G_BUFFER_ALLOC",
      44                 :            :    N_("Couldn't allocate gss_buffer_t data")},
      45                 :            :   {GSS_KRB5_S_G_BAD_MSG_CTX, "GSS_KRB5_S_G_BAD_MSG_CTX",
      46                 :            :    N_("Message context invalid")},
      47                 :            :   {GSS_KRB5_S_G_WRONG_SIZE, "GSS_KRB5_S_G_WRONG_SIZE",
      48                 :            :    N_("Buffer is the wrong size")},
      49                 :            :   {GSS_KRB5_S_G_BAD_USAGE, "GSS_KRB5_S_G_BAD_USAGE",
      50                 :            :    N_("Credential usage type is unknown")},
      51                 :            :   {GSS_KRB5_S_G_UNKNOWN_QOP, "GSS_KRB5_S_G_UNKNOWN_QOP",
      52                 :            :    N_("Unknown quality of protection specified")},
      53                 :            :   /* 4.1.2. Kerberos-specific-codes */
      54                 :            :   {GSS_KRB5_S_KG_CCACHE_NOMATCH, "GSS_KRB5_S_KG_CCACHE_NOMATCH",
      55                 :            :    N_("Principal in credential cache does not match desired name")},
      56                 :            :   {GSS_KRB5_S_KG_KEYTAB_NOMATCH, "GSS_KRB5_S_KG_KEYTAB_NOMATCH",
      57                 :            :    N_("No principal in keytab matches desired name")},
      58                 :            :   {GSS_KRB5_S_KG_TGT_MISSING, "GSS_KRB5_S_KG_TGT_MISSING",
      59                 :            :    N_("Credential cache has no TGT")},
      60                 :            :   {GSS_KRB5_S_KG_NO_SUBKEY, "GSS_KRB5_S_KG_NO_SUBKEY",
      61                 :            :    N_("Authenticator has no subkey")},
      62                 :            :   {GSS_KRB5_S_KG_CONTEXT_ESTABLISHED, "GSS_KRB5_S_KG_CONTEXT_ESTABLISHED",
      63                 :            :    N_("Context is already fully established")},
      64                 :            :   {GSS_KRB5_S_KG_BAD_SIGN_TYPE, "GSS_KRB5_S_KG_BAD_SIGN_TYPE",
      65                 :            :    N_("Unknown signature type in token")},
      66                 :            :   {GSS_KRB5_S_KG_BAD_LENGTH, "GSS_KRB5_S_KG_BAD_LENGTH",
      67                 :            :    N_("Invalid field length in token")},
      68                 :            :   {GSS_KRB5_S_KG_CTX_INCOMPLETE, "GSS_KRB5_S_KG_CTX_INCOMPLETE",
      69                 :            :    N_("Attempt to use incomplete security context")}
      70                 :            : };
      71                 :            : 
      72                 :            : OM_uint32
      73                 :          0 : gss_krb5_display_status (OM_uint32 * minor_status,
      74                 :            :                          OM_uint32 status_value,
      75                 :            :                          int status_type,
      76                 :            :                          const gss_OID mech_type,
      77                 :            :                          OM_uint32 * message_context,
      78                 :            :                          gss_buffer_t status_string)
      79                 :            : {
      80         [ #  # ]:          0 :   if (minor_status)
      81                 :          0 :     *minor_status = 0;
      82                 :            : 
      83      [ #  #  # ]:          0 :   switch (status_value)
      84                 :            :     {
      85                 :            :     case 0:
      86                 :          0 :       status_string->value = strdup (_("No krb5 error"));
      87         [ #  # ]:          0 :       if (!status_string->value)
      88                 :            :         {
      89         [ #  # ]:          0 :           if (minor_status)
      90                 :          0 :             *minor_status = ENOMEM;
      91                 :          0 :           return GSS_S_FAILURE;
      92                 :            :         }
      93                 :          0 :       status_string->length = strlen (status_string->value);
      94                 :          0 :       break;
      95                 :            : 
      96                 :            :       /* 4.1.1. Non-Kerberos-specific codes */
      97                 :            :     case GSS_KRB5_S_G_BAD_SERVICE_NAME:
      98                 :            :     case GSS_KRB5_S_G_BAD_STRING_UID:
      99                 :            :     case GSS_KRB5_S_G_NOUSER:
     100                 :            :     case GSS_KRB5_S_G_VALIDATE_FAILED:
     101                 :            :     case GSS_KRB5_S_G_BUFFER_ALLOC:
     102                 :            :     case GSS_KRB5_S_G_BAD_MSG_CTX:
     103                 :            :     case GSS_KRB5_S_G_WRONG_SIZE:
     104                 :            :     case GSS_KRB5_S_G_BAD_USAGE:
     105                 :            :     case GSS_KRB5_S_G_UNKNOWN_QOP:
     106                 :            :       /* 4.1.2. Kerberos-specific-codes */
     107                 :            :     case GSS_KRB5_S_KG_CCACHE_NOMATCH:
     108                 :            :     case GSS_KRB5_S_KG_KEYTAB_NOMATCH:
     109                 :            :     case GSS_KRB5_S_KG_TGT_MISSING:
     110                 :            :     case GSS_KRB5_S_KG_NO_SUBKEY:
     111                 :            :     case GSS_KRB5_S_KG_CONTEXT_ESTABLISHED:
     112                 :            :     case GSS_KRB5_S_KG_BAD_SIGN_TYPE:
     113                 :            :     case GSS_KRB5_S_KG_BAD_LENGTH:
     114                 :            :     case GSS_KRB5_S_KG_CTX_INCOMPLETE:
     115                 :          0 :       status_string->value =
     116                 :          0 :         strdup (_(gss_krb5_errors[status_value - 1].text));
     117         [ #  # ]:          0 :       if (!status_string->value)
     118                 :            :         {
     119         [ #  # ]:          0 :           if (minor_status)
     120                 :          0 :             *minor_status = ENOMEM;
     121                 :          0 :           return GSS_S_FAILURE;
     122                 :            :         }
     123                 :          0 :       status_string->length = strlen (status_string->value);
     124                 :          0 :       break;
     125                 :            : 
     126                 :            :     default:
     127                 :          0 :       status_string->value = strdup (_("Unknown krb5 error"));
     128         [ #  # ]:          0 :       if (!status_string->value)
     129                 :            :         {
     130         [ #  # ]:          0 :           if (minor_status)
     131                 :          0 :             *minor_status = ENOMEM;
     132                 :          0 :           return GSS_S_FAILURE;
     133                 :            :         }
     134                 :          0 :       status_string->length = strlen (status_string->value);
     135                 :            :       break;
     136                 :            :     }
     137                 :            : 
     138                 :          0 :   return GSS_S_COMPLETE;
     139                 :            : }

Generated by: LCOV version 1.8