Print this page
10703 smatch unreachable code checking needs reworking
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2015 RackTop Systems.

  25  */
  26 
  27 /*
  28  * This is the client layer for svc.configd.  All direct protocol interactions
  29  * are handled here.
  30  *
  31  * Essentially, the job of this layer is to turn the idempotent protocol
  32  * into a series of non-idempotent calls into the object layer, while
  33  * also handling the necessary locking.
  34  */
  35 
  36 #include <alloca.h>
  37 #include <assert.h>
  38 #include <bsm/adt_event.h>
  39 #include <door.h>
  40 #include <errno.h>
  41 #include <libintl.h>
  42 #include <limits.h>
  43 #include <pthread.h>
  44 #include <stdio.h>


1971         if (!adt_audit_state(AUC_AUDITING))
1972                 return;
1973 
1974         if (door_ucred(&cred) != 0) {
1975                 switch (errno) {
1976                 case EAGAIN:
1977                 case ENOMEM:
1978                         syslog(LOG_ERR, gettext("start_audit_session(): cannot "
1979                             "get ucred.  %m\n"));
1980                         return;
1981                 case EINVAL:
1982                         /*
1983                          * Door client went away.  This is a normal,
1984                          * although infrequent event, so there is no need
1985                          * to create a syslog message.
1986                          */
1987                         return;
1988                 case EFAULT:
1989                 default:
1990                         bad_error("door_ucred", errno);
1991                         return;
1992                 }
1993         }
1994         if (adt_start_session(&session, NULL, 0) != 0) {
1995                 syslog(LOG_ERR, gettext("start_audit_session(): could not "
1996                     "start audit session.\n"));
1997                 ucred_free(cred);
1998                 return;
1999         }
2000         if (adt_set_from_ucred(session, cred, ADT_NEW) != 0) {
2001                 syslog(LOG_ERR, gettext("start_audit_session(): cannot set "
2002                     "audit session data from ucred\n"));
2003                 /* Something went wrong.  End the session. */
2004                 (void) adt_end_session(session);
2005                 ucred_free(cred);
2006                 return;
2007         }
2008 
2009         /* All went well.  Save the session data and session ID */
2010         cp->rc_adt_session = session;
2011         adt_get_asid(session, &cp->rc_adt_sessionid);




   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2015 RackTop Systems.
  25  * Copyright 2019 Joyent, Inc.
  26  */
  27 
  28 /*
  29  * This is the client layer for svc.configd.  All direct protocol interactions
  30  * are handled here.
  31  *
  32  * Essentially, the job of this layer is to turn the idempotent protocol
  33  * into a series of non-idempotent calls into the object layer, while
  34  * also handling the necessary locking.
  35  */
  36 
  37 #include <alloca.h>
  38 #include <assert.h>
  39 #include <bsm/adt_event.h>
  40 #include <door.h>
  41 #include <errno.h>
  42 #include <libintl.h>
  43 #include <limits.h>
  44 #include <pthread.h>
  45 #include <stdio.h>


1972         if (!adt_audit_state(AUC_AUDITING))
1973                 return;
1974 
1975         if (door_ucred(&cred) != 0) {
1976                 switch (errno) {
1977                 case EAGAIN:
1978                 case ENOMEM:
1979                         syslog(LOG_ERR, gettext("start_audit_session(): cannot "
1980                             "get ucred.  %m\n"));
1981                         return;
1982                 case EINVAL:
1983                         /*
1984                          * Door client went away.  This is a normal,
1985                          * although infrequent event, so there is no need
1986                          * to create a syslog message.
1987                          */
1988                         return;
1989                 case EFAULT:
1990                 default:
1991                         bad_error("door_ucred", errno);

1992                 }
1993         }
1994         if (adt_start_session(&session, NULL, 0) != 0) {
1995                 syslog(LOG_ERR, gettext("start_audit_session(): could not "
1996                     "start audit session.\n"));
1997                 ucred_free(cred);
1998                 return;
1999         }
2000         if (adt_set_from_ucred(session, cred, ADT_NEW) != 0) {
2001                 syslog(LOG_ERR, gettext("start_audit_session(): cannot set "
2002                     "audit session data from ucred\n"));
2003                 /* Something went wrong.  End the session. */
2004                 (void) adt_end_session(session);
2005                 ucred_free(cred);
2006                 return;
2007         }
2008 
2009         /* All went well.  Save the session data and session ID */
2010         cp->rc_adt_session = session;
2011         adt_get_asid(session, &cp->rc_adt_sessionid);