[BACK]Return to server.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / oldrdist

Diff for /src/usr.bin/oldrdist/Attic/server.c between version 1.4 and 1.5

version 1.4, 1996/07/19 21:57:34 version 1.5, 1996/07/25 05:13:49
Line 93 
Line 93 
   
         rem = 0;          rem = 0;
         oumask = umask(0);          oumask = umask(0);
         (void) sprintf(buf, "V%d\n", VERSION);          (void) snprintf(buf, BUFSIZ, "V%d\n", VERSION);
         (void) write(rem, buf, strlen(buf));          (void) write(rem, buf, strlen(buf));
   
         if (getuid() != geteuid()) {          if (getuid() != geteuid()) {
Line 279 
Line 279 
         /*          /*
          * Pass the destination file/directory name to remote.           * Pass the destination file/directory name to remote.
          */           */
         (void) sprintf(buf, "%c%s\n", destdir ? 'T' : 't', dest);          (void) snprintf(buf, BUFSIZ, "%c%s\n", destdir ? 'T' : 't', dest);
         if (debug)          if (debug)
                 printf("buf = %s", buf);                  printf("buf = %s", buf);
         (void) write(rem, buf, strlen(buf));          (void) write(rem, buf, strlen(buf));
Line 335 
Line 335 
                         log(lfp, "%s: no password entry for uid %d \n",                          log(lfp, "%s: no password entry for uid %d \n",
                                 target, stb.st_uid);                                  target, stb.st_uid);
                         pw = NULL;                          pw = NULL;
                         (void)sprintf(user, ":%lu", stb.st_uid);                          (void) snprintf(user, sizeof(user), ":%lu", stb.st_uid);
                 }                  }
         if (gr == NULL || gr->gr_gid != stb.st_gid)          if (gr == NULL || gr->gr_gid != stb.st_gid)
                 if ((gr = getgrgid(stb.st_gid)) == NULL) {                  if ((gr = getgrgid(stb.st_gid)) == NULL) {
                         log(lfp, "%s: no name for group %d\n",                          log(lfp, "%s: no name for group %d\n",
                                 target, stb.st_gid);                                  target, stb.st_gid);
                         gr = NULL;                          gr = NULL;
                         (void)sprintf(group, ":%lu", stb.st_gid);                          (void) snprintf(group, sizeof(group), ":%lu", stb.st_gid);
                 }                  }
         if (u == 1) {          if (u == 1) {
                 if (opts & VERIFY) {                  if (opts & VERIFY) {
Line 359 
Line 359 
                         error("%s: %s\n", target, strerror(errno));                          error("%s: %s\n", target, strerror(errno));
                         return;                          return;
                 }                  }
                 (void) sprintf(buf, "D%o %04o 0 0 %s %s %s\n", opts,                  (void) snprintf(buf, BUFSIZ, "D%o %04o 0 0 %s %s %s\n", opts,
                         stb.st_mode & 07777, protoname(), protogroup(), rname);                          stb.st_mode & 07777, protoname(), protogroup(), rname);
                 if (debug)                  if (debug)
                         printf("buf = %s", buf);                          printf("buf = %s", buf);
Line 407 
Line 407 
                         if ((lp = savelink(&stb)) != NULL) {                          if ((lp = savelink(&stb)) != NULL) {
                                 /* install link */                                  /* install link */
                                 if (*lp->target == 0)                                  if (*lp->target == 0)
                                 (void) sprintf(buf, "k%o %s %s\n", opts,                                  (void) snprintf(buf, BUFSIZ, "k%o %s %s\n",
                                         lp->pathname, rname);                                          opts, lp->pathname, rname);
                                 else                                  else
                                 (void) sprintf(buf, "k%o %s/%s %s\n", opts,                                  (void) snprintf(buf, BUFSIZ, "k%o %s/%s %s\n",
                                         lp->target, lp->pathname, rname);                                          opts, lp->target, lp->pathname, rname);
                                 if (debug)                                  if (debug)
                                         printf("buf = %s", buf);                                          printf("buf = %s", buf);
                                 (void) write(rem, buf, strlen(buf));                                  (void) write(rem, buf, strlen(buf));
Line 419 
Line 419 
                                 return;                                  return;
                         }                          }
                 }                  }
                 (void) sprintf(buf, "K%o %o %qd %ld %s %s %s\n", opts,                  (void) snprintf(buf, BUFSIZ, "K%o %o %qd %ld %s %s %s\n",
                         stb.st_mode & 07777, stb.st_size, stb.st_mtime,                          opts, stb.st_mode & 07777, stb.st_size, stb.st_mtime,
                         protoname(), protogroup(), rname);                          protoname(), protogroup(), rname);
                 if (debug)                  if (debug)
                         printf("buf = %s", buf);                          printf("buf = %s", buf);
Line 455 
Line 455 
                 if ((lp = savelink(&stb)) != NULL) {                  if ((lp = savelink(&stb)) != NULL) {
                         /* install link */                          /* install link */
                         if (*lp->target == 0)                          if (*lp->target == 0)
                         (void) sprintf(buf, "k%o %s %s\n", opts,                          (void) snprintf(buf, BUFSIZ, "k%o %s %s\n", opts,
                                 lp->pathname, rname);                                  lp->pathname, rname);
                         else                          else
                         (void) sprintf(buf, "k%o %s/%s %s\n", opts,                          (void) snprintf(buf, BUFSIZ, "k%o %s/%s %s\n",
                                 lp->target, lp->pathname, rname);                                  opts, lp->target, lp->pathname, rname);
                         if (debug)                          if (debug)
                                 printf("buf = %s", buf);                                  printf("buf = %s", buf);
                         (void) write(rem, buf, strlen(buf));                          (void) write(rem, buf, strlen(buf));
Line 472 
Line 472 
                 error("%s: %s\n", target, strerror(errno));                  error("%s: %s\n", target, strerror(errno));
                 return;                  return;
         }          }
         (void) sprintf(buf, "R%o %o %qd %ld %s %s %s\n", opts,          (void) snprintf(buf, BUFSIZ, "R%o %o %qd %ld %s %s %s\n", opts,
                 stb.st_mode & 07777, stb.st_size, stb.st_mtime,                  stb.st_mode & 07777, stb.st_size, stb.st_mtime,
                 protoname(), protogroup(), rname);                  protoname(), protogroup(), rname);
         if (debug)          if (debug)
Line 510 
Line 510 
                 log(lfp, "special \"%s\"\n", sc->sc_name);                  log(lfp, "special \"%s\"\n", sc->sc_name);
                 if (opts & VERIFY)                  if (opts & VERIFY)
                         continue;                          continue;
                 (void) sprintf(buf, "SFILE=%s;%s\n", target, sc->sc_name);                  (void) snprintf(buf, BUFSIZ, "SFILE=%s;%s\n", target,
                           sc->sc_name);
                 if (debug)                  if (debug)
                         printf("buf = %s", buf);                          printf("buf = %s", buf);
                 (void) write(rem, buf, strlen(buf));                  (void) write(rem, buf, strlen(buf));
Line 569 
Line 570 
         /*          /*
          * Check to see if the file exists on the remote machine.           * Check to see if the file exists on the remote machine.
          */           */
         (void) sprintf(buf, "Q%s\n", rname);          (void) snprintf(buf, BUFSIZ, "Q%s\n", rname);
         if (debug)          if (debug)
                 printf("buf = %s", buf);                  printf("buf = %s", buf);
         (void) write(rem, buf, strlen(buf));          (void) write(rem, buf, strlen(buf));
Line 673 
Line 674 
   
         switch (stb.st_mode & S_IFMT) {          switch (stb.st_mode & S_IFMT) {
         case S_IFREG:          case S_IFREG:
                 (void) sprintf(buf, "Y%qd %ld\n", stb.st_size,                  (void) snprintf(buf, BUFSIZ, "Y%qd %ld\n", stb.st_size,
                     stb.st_mtime);                      stb.st_mtime);
                 (void) write(rem, buf, strlen(buf));                  (void) write(rem, buf, strlen(buf));
                 break;                  break;
Line 776 
Line 777 
                                         return;                                          return;
                                 }                                  }
                                 buf[0] = '\0';                                  buf[0] = '\0';
                                 (void) sprintf(buf + 1,                                  (void) snprintf(buf + 1, BUFSIZ - 1,
                                         "%s: Warning: remote mode %o != local mode %o\n",                                          "%s: Warning: remote mode %o != local mode %o\n",
                                         target, stb.st_mode & 07777, mode);                                          target, stb.st_mode & 07777, mode);
                                 (void) write(rem, buf, strlen(buf + 1) + 1);                                  (void) write(rem, buf, strlen(buf + 1) + 1);
Line 801 
Line 802 
         if (cp == NULL)          if (cp == NULL)
                 strcpy(new, tempname);                  strcpy(new, tempname);
         else if (cp == target)          else if (cp == target)
                 (void) sprintf(new, "/%s", tempname);                  (void) snprintf(new, sizeof(new), "/%s", tempname);
         else {          else {
                 *cp = '\0';                  *cp = '\0';
                 (void) sprintf(new, "%s/%s", target, tempname);                  (void) snprintf(new, sizeof(new), "%s/%s", target, tempname);
                 *cp = '/';                  *cp = '/';
         }          }
   
Line 904 
Line 905 
                 (void) fclose(f2);                  (void) fclose(f2);
                 if (opts & VERIFY) {                  if (opts & VERIFY) {
 differ:                 buf[0] = '\0';  differ:                 buf[0] = '\0';
                         (void) sprintf(buf + 1, "need to update: %s\n",target);                          (void) snprintf(buf + 1, BUFSIZ - 1,
                                   "need to update: %s\n",target);
                         (void) write(rem, buf, strlen(buf + 1) + 1);                          (void) write(rem, buf, strlen(buf + 1) + 1);
                         goto badnew2;                          goto badnew2;
                 }                  }
Line 937 
Line 939 
   
         if (opts & COMPARE) {          if (opts & COMPARE) {
                 buf[0] = '\0';                  buf[0] = '\0';
                 (void) sprintf(buf + 1, "updated %s\n", target);                  (void) snprintf(buf + 1, BUFSIZ - 1,
                           "updated %s\n", target);
                 (void) write(rem, buf, strlen(buf + 1) + 1);                  (void) write(rem, buf, strlen(buf + 1) + 1);
         } else          } else
                 ack();                  ack();
Line 1107 
Line 1110 
         /*          /*
          * Tell the remote to clean the files from the last directory sent.           * Tell the remote to clean the files from the last directory sent.
          */           */
         (void) sprintf(buf, "C%o\n", opts & VERIFY);          (void) snprintf(buf, BUFSIZ, "C%o\n", opts & VERIFY);
         if (debug)          if (debug)
                 printf("buf = %s", buf);                  printf("buf = %s", buf);
         (void) write(rem, buf, strlen(buf));          (void) write(rem, buf, strlen(buf));
Line 1219 
Line 1222 
                         error("%s:%s: %s\n", host, target, strerror(errno));                          error("%s:%s: %s\n", host, target, strerror(errno));
                         continue;                          continue;
                 }                  }
                 (void) sprintf(buf, "Q%s\n", dp->d_name);                  (void) snprintf(buf, BUFSIZ, "Q%s\n", dp->d_name);
                 (void) write(rem, buf, strlen(buf));                  (void) write(rem, buf, strlen(buf));
                 cp = buf;                  cp = buf;
                 do {                  do {
Line 1233 
Line 1236 
                 if (opts & VERIFY) {                  if (opts & VERIFY) {
                         cp = buf;                          cp = buf;
                         *cp++ = '\0';                          *cp++ = '\0';
                         (void) sprintf(cp, "need to remove: %s\n", target);                          (void) snprintf(cp, BUFSIZ - 1,
                                   "need to remove: %s\n", target);
                         (void) write(rem, buf, strlen(cp) + 1);                          (void) write(rem, buf, strlen(cp) + 1);
                 } else                  } else
                         removeit(&stb);                          removeit(&stb);
Line 1311 
Line 1315 
 removed:  removed:
         cp = buf;          cp = buf;
         *cp++ = '\0';          *cp++ = '\0';
         (void) sprintf(cp, "removed %s\n", target);          (void) snprintf(cp, BUFSIZ - 1, "removed %s\n", target);
         (void) write(rem, buf, strlen(cp) + 1);          (void) write(rem, buf, strlen(cp) + 1);
 }  }
   
Line 1353 
Line 1357 
         (void) close(fd[1]);          (void) close(fd[1]);
         s = sbuf;          s = sbuf;
         *s++ = '\0';          *s++ = '\0';
         while ((i = read(fd[0], buf, sizeof(buf))) > 0) {          while ((i = read(fd[0], buf, BUFSIZ)) > 0) {
                 cp = buf;                  cp = buf;
                 do {                  do {
                         *s++ = *cp++;                          *s++ = *cp++;
Line 1412 
Line 1416 
 #endif  #endif
         /* Print changes locally if not quiet mode */          /* Print changes locally if not quiet mode */
         if (!qflag)          if (!qflag)
                 (void)vprintf(fmt, ap);                  (void) vprintf(fmt, ap);
   
         /* Save changes (for mailing) if really updating files */          /* Save changes (for mailing) if really updating files */
         if (!(options & VERIFY) && fp != NULL)          if (!(options & VERIFY) && fp != NULL)
                 (void)vfprintf(fp, fmt, ap);                  (void) vfprintf(fp, fmt, ap);
         va_end(ap);          va_end(ap);
 }  }
   
Line 1441 
Line 1445 
         if (iamremote) {          if (iamremote) {
                 if (!fp && (rem < 0 || !(fp = fdopen(rem, "w"))))                  if (!fp && (rem < 0 || !(fp = fdopen(rem, "w"))))
                         return;                          return;
                 (void)fprintf(fp, "%crdist: ", 0x01);                  (void) fprintf(fp, "%crdist: ", 0x01);
                 (void)vfprintf(fp, fmt, ap);                  (void) vfprintf(fp, fmt, ap);
                 fflush(fp);                  fflush(fp);
         }          }
         else {          else {
                 fflush(stdout);                  fflush(stdout);
                 (void)fprintf(stderr, "rdist: ");                  (void) fprintf(stderr, "rdist: ");
                 (void)vfprintf(stderr, fmt, ap);                  (void) vfprintf(stderr, fmt, ap);
                 fflush(stderr);                  fflush(stderr);
         }          }
         if (lfp != NULL) {          if (lfp != NULL) {
                 (void)fprintf(lfp, "rdist: ");                  (void) fprintf(lfp, "rdist: ");
                 (void)vfprintf(lfp, fmt, ap);                  (void) vfprintf(lfp, fmt, ap);
                 fflush(lfp);                  fflush(lfp);
         }          }
         va_end(ap);          va_end(ap);
Line 1480 
Line 1484 
         if (!fp && !(fp = fdopen(rem, "w")))          if (!fp && !(fp = fdopen(rem, "w")))
                 return;                  return;
         if (iamremote) {          if (iamremote) {
                 (void)fprintf(fp, "%crdist: ", 0x02);                  (void) fprintf(fp, "%crdist: ", 0x02);
                 (void)vfprintf(fp, fmt, ap);                  (void) vfprintf(fp, fmt, ap);
                 fflush(fp);                  fflush(fp);
         }          }
         else {          else {
                 fflush(stdout);                  fflush(stdout);
                 (void)fprintf(stderr, "rdist: ");                  (void) fprintf(stderr, "rdist: ");
                 (void)vfprintf(stderr, fmt, ap);                  (void) vfprintf(stderr, fmt, ap);
                 fflush(stderr);                  fflush(stderr);
         }          }
         if (lfp != NULL) {          if (lfp != NULL) {
                 (void)fprintf(lfp, "rdist: ");                  (void) fprintf(lfp, "rdist: ");
                 (void)vfprintf(lfp, fmt, ap);                  (void) vfprintf(lfp, fmt, ap);
                 fflush(lfp);                  fflush(lfp);
         }          }
         cleanup(0);          cleanup(0);
Line 1573 
Line 1577 
 #else  #else
         va_start(ap);          va_start(ap);
 #endif  #endif
         (void)vsnprintf(buf, sizeof(buf), fmt, ap);          (void) vsnprintf(buf, BUFSIZ, fmt, ap);
         va_end(ap);          va_end(ap);
         comment(buf);          comment(buf);
 }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5