Print this page
4029 remove tonic build bits

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/install.bin/install.bin.c
          +++ new/usr/src/tools/install.bin/install.bin.c
↓ open down ↓ 37 lines elided ↑ open up ↑
  38   38  #include "stdusers.h"
  39   39  
  40   40  
  41   41  #define FILE_BUFF       40960
  42   42  
  43   43  static int suppress = 0;
  44   44  
  45   45  static void usage(void);
  46   46  static void file_copy(char *src_file, char *dest_file);
  47   47  static void chown_file(const char *file, const char *group, const char *owner);
  48      -static void formclosed(char *root, char *closedroot);
  49   48  static char *find_basename(const char *str);
  50   49  static int creatdir(char *fn);
  51   50  
  52   51  
  53   52  void
  54   53  usage(void)
  55   54  {
  56   55          (void) fprintf(stderr,
  57      -            "usage: install [-sdO][-m mode][-g group][-u owner] "
       56 +            "usage: install [-sd][-m mode][-g group][-u owner] "
  58   57              "-f dir file ...\n");
  59   58  }
  60   59  
  61   60  void
  62   61  file_copy(char *src_file, char *dest_file)
  63   62  {
  64   63          int     src_fd;
  65   64          int     dest_fd;
  66   65          int     count;
  67   66          static char file_buff[FILE_BUFF];
↓ open down ↓ 50 lines elided ↑ open up ↑
 118  117          }
 119  118  
 120  119          if (chown(file, own, grp) == -1) {
 121  120                  (void) fprintf(stderr, "install:chown_file: failed "
 122  121                      "(%d): %s\n", errno, strerror(errno));
 123  122                  exit(1);
 124  123          }
 125  124  }
 126  125  
 127  126  
 128      -void
 129      -formclosed(char *root, char *closedroot)
 130      -{
 131      -        int wholelen, residlen;
 132      -        char *temp;
 133      -
 134      -        wholelen = strlen(root);
 135      -        temp = strstr(strstr(root, "proto/root_"), "/");
 136      -        temp++;
 137      -        temp = strstr(temp, "/");
 138      -        residlen = strlen(temp);
 139      -        (void) strlcpy(closedroot, root, wholelen - residlen + 1);
 140      -        (void) strlcat(closedroot, "-closed", MAXPATHLEN);
 141      -        (void) strlcat(closedroot, temp, MAXPATHLEN);
 142      -}
 143      -
 144      -
 145  127  char *
 146  128  find_basename(const char *str)
 147  129  {
 148  130          int     i;
 149  131          int     len;
 150  132  
 151  133          len = strlen(str);
 152  134  
 153  135          for (i = len-1; i >= 0; i--)
 154  136                  if (str[i] == '/')
↓ open down ↓ 21 lines elided ↑ open up ↑
 176  158  {
 177  159          int     c;
 178  160          int     errflg = 0;
 179  161          int     dirflg = 0;
 180  162          char    *group = NULL;
 181  163          char    *owner = NULL;
 182  164          char    *dirb = NULL;
 183  165          char    *ins_file = NULL;
 184  166          int     mode = -1;
 185  167          char    dest_file[MAXPATHLEN];
 186      -        char    shadow_dest[MAXPATHLEN];
 187      -        char    shadow_dirb[MAXPATHLEN];
 188      -        int     tonic = 0;
 189  168          int     rv = 0;
 190  169  
 191      -        while ((c = getopt(argc, argv, "f:sm:du:g:O")) != EOF) {
      170 +        while ((c = getopt(argc, argv, "f:sm:du:g:")) != EOF) {
 192  171                  switch (c) {
 193  172                  case 'f':
 194  173                          dirb = optarg;
 195  174                          break;
 196  175                  case 'g':
 197  176                          group = optarg;
 198  177                          break;
 199  178                  case 'u':
 200  179                          owner = optarg;
 201  180                          break;
 202  181                  case 'd':
 203  182                          dirflg = 1;
 204  183                          break;
 205  184                  case 'm':
 206  185                          mode = strtol(optarg, NULL, 8);
 207  186                          break;
 208  187                  case 's':
 209  188                          suppress = 1;
 210  189                          break;
 211      -                case 'O':
 212      -                        tonic = 1;
 213      -                        break;
 214  190                  case '?':
 215  191                          errflg++;
 216  192                          break;
 217  193                  }
 218  194          }
 219  195  
 220  196          if (errflg) {
 221  197                  usage();
 222  198                  return (1);
 223  199          }
↓ open down ↓ 6 lines elided ↑ open up ↑
 230  206          if (!dirflg && (dirb == NULL)) {
 231  207                  (void) fprintf(stderr,
 232  208                      "install: no destination directory specified.\n");
 233  209                  return (1);
 234  210          }
 235  211  
 236  212          for (c = optind; c < argc; c++) {
 237  213                  ins_file = argv[c];
 238  214  
 239  215                  if (dirflg) {
 240      -                        if (tonic) {
 241      -                                formclosed(ins_file, shadow_dest);
 242      -                                rv = creatdir(shadow_dest);
 243      -                                if (rv) {
 244      -                                        (void) fprintf(stderr,
 245      -                                            "install: tonic creatdir "
 246      -                                            "%s (%d): (%s)\n",
 247      -                                            shadow_dest, errno,
 248      -                                            strerror(errno));
 249      -                                        return (rv);
 250      -                                }
 251      -                        }
 252  216                          rv = creatdir(ins_file);
 253  217                          if (rv) {
 254  218                                  (void) fprintf(stderr,
 255  219                                      "install: creatdir %s (%d): %s\n",
 256  220                                      ins_file, errno, strerror(errno));
 257  221                                  return (rv);
 258  222                          }
 259  223                          (void) strlcpy(dest_file, ins_file, MAXPATHLEN);
 260  224  
 261  225                  } else {
 262  226                          (void) strcat(strcat(strcpy(dest_file, dirb), "/"),
 263  227                              find_basename(ins_file));
 264  228                          file_copy(ins_file, dest_file);
 265      -
 266      -                        if (tonic) {
 267      -                                formclosed(dirb, shadow_dirb);
 268      -                                /*
 269      -                                 * The standard directories in the proto
 270      -                                 * area are created as part of "make setup",
 271      -                                 * but that doesn't create them in the
 272      -                                 * closed proto area. So if the target
 273      -                                 * directory doesn't exist, we need to
 274      -                                 * create it now.
 275      -                                 */
 276      -                                rv = creatdir(shadow_dirb);
 277      -                                if (rv) {
 278      -                                        (void) fprintf(stderr,
 279      -                                            "install: tonic creatdir(f) "
 280      -                                            "%s (%d): %s\n",
 281      -                                            shadow_dirb, errno,
 282      -                                            strerror(errno));
 283      -                                        return (rv);
 284      -                                }
 285      -                                (void) strcat(strcat(strcpy(shadow_dest,
 286      -                                    shadow_dirb), "/"),
 287      -                                    find_basename(ins_file));
 288      -                                file_copy(ins_file, shadow_dest);
 289      -                        }
 290  229                  }
 291  230  
 292      -                if (group || owner) {
      231 +                if (group || owner)
 293  232                          chown_file(dest_file, group, owner);
 294      -                        if (tonic)
 295      -                                chown_file(shadow_dest, group, owner);
 296      -                }
      233 +
 297  234                  if (mode != -1) {
 298  235                          (void) umask(0);
 299  236                          if (chmod(dest_file, mode) == -1) {
 300  237                                  (void) fprintf(stderr,
 301  238                                      "install: chmod of %s to mode %o failed "
 302  239                                      "(%d): %s\n",
 303  240                                      dest_file, mode, errno, strerror(errno));
 304  241                                  return (1);
 305  242                          }
 306      -                        if (tonic) {
 307      -                                if (chmod(shadow_dest, mode) == -1) {
 308      -                                        (void) fprintf(stderr,
 309      -                                            "install: tonic chmod of %s "
 310      -                                            "to mode %o failed (%d): %s\n",
 311      -                                            shadow_dest, mode,
 312      -                                            errno, strerror(errno));
 313      -                                        return (1);
 314      -                                }
 315      -                        }
 316  243                  }
 317  244          }
 318  245          return (0);
 319  246  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX