Print this page
10075 make usr/src/tools smatch clean


   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  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  23  */
  24 



  25 
  26 #include <stdio.h>
  27 #include <stdlib.h>
  28 #include <strings.h>
  29 #include <sys/param.h>
  30 #include <fcntl.h>
  31 #include <sys/errno.h>
  32 #include <sys/types.h>
  33 #include <sys/uio.h>
  34 #include <unistd.h>
  35 #include <sys/stat.h>
  36 #include <errno.h>
  37 #include <libgen.h>
  38 #include "stdusers.h"
  39 
  40 
  41 #define FILE_BUFF       40960
  42 
  43 static int suppress = 0;
  44 


  86                     "(%d): %s\n", errno, strerror(errno));
  87                 exit(1);
  88         }
  89 
  90         if (!suppress)
  91                 (void) printf("%s installed as %s\n", src_file, dest_file);
  92 
  93         (void) close(src_fd);
  94         (void) close(dest_fd);
  95 }
  96 
  97 
  98 void
  99 chown_file(const char *file, const char *group, const char *owner)
 100 {
 101         gid_t   grp = (gid_t)-1;
 102         uid_t   own = (uid_t)-1;
 103 
 104         if (group) {
 105                 grp = stdfind(group, groupnames);
 106                 if (grp < 0)
 107                         (void) fprintf(stderr, "unknown group(%s)\n", group);
 108         }
 109 
 110         if (owner) {
 111                 own = stdfind(owner, usernames);
 112                 if (own < 0) {
 113                         (void) fprintf(stderr, "unknown owner(%s)\n", owner);
 114                         exit(1);
 115                 }
 116 
 117         }
 118 
 119         if (chown(file, own, grp) == -1) {
 120                 (void) fprintf(stderr, "install:chown_file: failed "
 121                     "(%d): %s\n", errno, strerror(errno));
 122                 exit(1);
 123         }
 124 }
 125 
 126 
 127 char *
 128 find_basename(const char *str)
 129 {
 130         int     i;
 131         int     len;
 132 




   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  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  23  */
  24 
  25 /*
  26  * Copyright (c) 2018, Joyent, Inc.
  27  */
  28 
  29 #include <stdio.h>
  30 #include <stdlib.h>
  31 #include <strings.h>
  32 #include <sys/param.h>
  33 #include <fcntl.h>
  34 #include <sys/errno.h>
  35 #include <sys/types.h>
  36 #include <sys/uio.h>
  37 #include <unistd.h>
  38 #include <sys/stat.h>
  39 #include <errno.h>
  40 #include <libgen.h>
  41 #include "stdusers.h"
  42 
  43 
  44 #define FILE_BUFF       40960
  45 
  46 static int suppress = 0;
  47 


  89                     "(%d): %s\n", errno, strerror(errno));
  90                 exit(1);
  91         }
  92 
  93         if (!suppress)
  94                 (void) printf("%s installed as %s\n", src_file, dest_file);
  95 
  96         (void) close(src_fd);
  97         (void) close(dest_fd);
  98 }
  99 
 100 
 101 void
 102 chown_file(const char *file, const char *group, const char *owner)
 103 {
 104         gid_t   grp = (gid_t)-1;
 105         uid_t   own = (uid_t)-1;
 106 
 107         if (group) {
 108                 grp = stdfind(group, groupnames);
 109                 if (grp == (gid_t)-1)
 110                         (void) fprintf(stderr, "unknown group(%s)\n", group);
 111         }
 112 
 113         if (owner) {
 114                 own = stdfind(owner, usernames);
 115                 if (own == (uid_t)-1) {
 116                         (void) fprintf(stderr, "unknown owner(%s)\n", owner);
 117                         exit(1);
 118                 }
 119 
 120         }
 121 
 122         if (chown(file, own, grp) == -1) {
 123                 (void) fprintf(stderr, "install:chown_file: failed "
 124                     "(%d): %s\n", errno, strerror(errno));
 125                 exit(1);
 126         }
 127 }
 128 
 129 
 130 char *
 131 find_basename(const char *str)
 132 {
 133         int     i;
 134         int     len;
 135