Print this page
10133 smatch fixes for usr/src/cmd/fs.d


   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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*




  27  * Reparsed daemon
  28  */
  29 
  30 #include <stdio.h>
  31 #include <stdio_ext.h>
  32 #include <stdlib.h>
  33 #include <unistd.h>
  34 #include <signal.h>
  35 #include <sys/types.h>
  36 #include <sys/stat.h>
  37 #include <fcntl.h>
  38 #include <memory.h>
  39 #include <alloca.h>
  40 #include <ucontext.h>
  41 #include <errno.h>
  42 #include <syslog.h>
  43 #include <string.h>
  44 #include <strings.h>
  45 #include <door.h>
  46 #include <wait.h>


 174                 exit(3);
 175         }
 176 
 177         /*
 178          * Clear basic privileges not required by reparsed.
 179          */
 180         __fini_daemon_priv(PRIV_PROC_FORK, PRIV_PROC_EXEC, PRIV_PROC_SESSION,
 181             PRIV_FILE_LINK_ANY, PRIV_PROC_INFO, (char *)NULL);
 182 
 183         return (start_reparsed_svcs());
 184 }
 185 
 186 static void
 187 reparsed_door_call_error(int error, int buflen)
 188 {
 189         reparsed_door_res_t rpd_res;
 190 
 191         memset(&rpd_res, 0, sizeof (reparsed_door_res_t));
 192         rpd_res.res_status = error;
 193         rpd_res.res_len = buflen;
 194         door_return((char *)&rpd_res, sizeof (reparsed_door_res_t), NULL, 0);

 195 
 196         (void) door_return(NULL, 0, NULL, 0);
 197         /* NOTREACHED */
 198 }
 199 
 200 /*
 201  *  reparsed_doorfunc
 202  *
 203  *  argp:  "service_type:service_data" string
 204  *  dp & n_desc: not used.
 205  */
 206 static void
 207 reparsed_doorfunc(void *cookie, char *argp, size_t arg_size,
 208     door_desc_t *dp, uint_t n_desc)
 209 {
 210         int err;
 211         size_t bufsz;
 212         char *svc_type, *svc_data;
 213         char *cp, *buf, *sbuf, res_buf[DOOR_RESULT_BUFSZ];
 214         reparsed_door_res_t *resp;
 215 
 216         if ((argp == NULL) || (arg_size == 0)) {
 217                 reparsed_door_call_error(EINVAL, 0);




   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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  * Copyright (c) 2018, Joyent, Inc.
  28  */
  29 
  30 /*
  31  * Reparsed daemon
  32  */
  33 
  34 #include <stdio.h>
  35 #include <stdio_ext.h>
  36 #include <stdlib.h>
  37 #include <unistd.h>
  38 #include <signal.h>
  39 #include <sys/types.h>
  40 #include <sys/stat.h>
  41 #include <fcntl.h>
  42 #include <memory.h>
  43 #include <alloca.h>
  44 #include <ucontext.h>
  45 #include <errno.h>
  46 #include <syslog.h>
  47 #include <string.h>
  48 #include <strings.h>
  49 #include <door.h>
  50 #include <wait.h>


 178                 exit(3);
 179         }
 180 
 181         /*
 182          * Clear basic privileges not required by reparsed.
 183          */
 184         __fini_daemon_priv(PRIV_PROC_FORK, PRIV_PROC_EXEC, PRIV_PROC_SESSION,
 185             PRIV_FILE_LINK_ANY, PRIV_PROC_INFO, (char *)NULL);
 186 
 187         return (start_reparsed_svcs());
 188 }
 189 
 190 static void
 191 reparsed_door_call_error(int error, int buflen)
 192 {
 193         reparsed_door_res_t rpd_res;
 194 
 195         memset(&rpd_res, 0, sizeof (reparsed_door_res_t));
 196         rpd_res.res_status = error;
 197         rpd_res.res_len = buflen;
 198         (void) door_return((char *)&rpd_res,
 199             sizeof (reparsed_door_res_t), NULL, 0);
 200 
 201         (void) door_return(NULL, 0, NULL, 0);
 202         abort();
 203 }
 204 
 205 /*
 206  *  reparsed_doorfunc
 207  *
 208  *  argp:  "service_type:service_data" string
 209  *  dp & n_desc: not used.
 210  */
 211 static void
 212 reparsed_doorfunc(void *cookie, char *argp, size_t arg_size,
 213     door_desc_t *dp, uint_t n_desc)
 214 {
 215         int err;
 216         size_t bufsz;
 217         char *svc_type, *svc_data;
 218         char *cp, *buf, *sbuf, res_buf[DOOR_RESULT_BUFSZ];
 219         reparsed_door_res_t *resp;
 220 
 221         if ((argp == NULL) || (arg_size == 0)) {
 222                 reparsed_door_call_error(EINVAL, 0);