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

Diff for /src/usr.bin/rdistd/server.c between version 1.46 and 1.47

version 1.46, 2019/06/28 05:35:35 version 1.47, 2019/06/28 13:35:03
Line 131 
Line 131 
                 status = fchownat(AT_FDCWD, file, uid, gid,                  status = fchownat(AT_FDCWD, file, uid, gid,
                     AT_SYMLINK_NOFOLLOW);                      AT_SYMLINK_NOFOLLOW);
   
         if (status < 0) {          if (status == -1) {
                 if (uid == (uid_t)-1)                  if (uid == (uid_t)-1)
                         message(MT_NOTICE, "%s: chgrp %d failed: %s",                          message(MT_NOTICE, "%s: chgrp %d failed: %s",
                                 target, gid, SYSERR);                                  target, gid, SYSERR);
Line 161 
Line 161 
         if (fd != -1 && !islink)          if (fd != -1 && !islink)
                 status = fchmod(fd, mode);                  status = fchmod(fd, mode);
   
         if (status < 0 && !islink)          if (status == -1 && !islink)
                 status = chmod(file, mode);                  status = chmod(file, mode);
   
         if (status < 0) {          if (status == -1) {
                 message(MT_NOTICE, "%s: chmod failed: %s", target, SYSERR);                  message(MT_NOTICE, "%s: chmod failed: %s", target, SYSERR);
                 return(-1);                  return(-1);
         }          }
Line 296 
Line 296 
         case S_IFBLK:          case S_IFBLK:
         case S_IFSOCK:          case S_IFSOCK:
         case S_IFIFO:          case S_IFIFO:
                 if (unlink(target) < 0) {                  if (unlink(target) == -1) {
                         if (errno == ETXTBSY) {                          if (errno == ETXTBSY) {
                                 if (!silent)                                  if (!silent)
                                         message(MT_REMOTE|MT_NOTICE,                                          message(MT_REMOTE|MT_NOTICE,
Line 344 
Line 344 
                 while ((*ptarget++ = *cp++) != '\0')                  while ((*ptarget++ = *cp++) != '\0')
                         continue;                          continue;
                 ptarget--;                  ptarget--;
                 if (lstat(target, &stb) < 0) {                  if (lstat(target, &stb) == -1) {
                         if (!silent)                          if (!silent)
                                 message(MT_REMOTE|MT_WARNING,                                  message(MT_REMOTE|MT_WARNING,
                                         "%s: lstat failed: %s",                                          "%s: lstat failed: %s",
Line 361 
Line 361 
         if (failures)          if (failures)
                 return(-1);                  return(-1);
   
         if (rmdir(target) < 0) {          if (rmdir(target) == -1) {
                 error("%s: rmdir failed: %s", target, SYSERR);                  error("%s: rmdir failed: %s", target, SYSERR);
                 return(-1);                  return(-1);
         }          }
Line 425 
Line 425 
                 while ((*ptarget++ = *cp++) != '\0')                  while ((*ptarget++ = *cp++) != '\0')
                         continue;                          continue;
                 ptarget--;                  ptarget--;
                 if (lstat(target, &stb) < 0) {                  if (lstat(target, &stb) == -1) {
                         message(MT_REMOTE|MT_WARNING, "%s: lstat failed: %s",                          message(MT_REMOTE|MT_WARNING, "%s: lstat failed: %s",
                                 target, SYSERR);                                  target, SYSERR);
                         continue;                          continue;
Line 603 
Line 603 
          * If stbvalid is false, "stb" is not valid because the stat()           * If stbvalid is false, "stb" is not valid because the stat()
          * by is_*_mounted() either failed or does not match "target".           * by is_*_mounted() either failed or does not match "target".
          */           */
         if (!stbvalid && lstat(target, &stb) < 0) {          if (!stbvalid && lstat(target, &stb) == -1) {
                 if (errno == ENOENT)                  if (errno == ENOENT)
                         (void) sendcmd(QC_NO, NULL);                          (void) sendcmd(QC_NO, NULL);
                 else                  else
Line 649 
Line 649 
   
         *cp = CNULL;          *cp = CNULL;
   
         if (lstat(name, &stb) < 0) {          if (lstat(name, &stb) == -1) {
                 if (errno == ENOENT && chkparent(name, opts) >= 0) {                  if (errno == ENOENT && chkparent(name, opts) >= 0) {
                         if (mkdir(name, 0777 & ~oumask) == 0) {                          if (mkdir(name, 0777 & ~oumask) == 0) {
                                 message(MT_NOTICE, "%s: mkdir", name);                                  message(MT_NOTICE, "%s: mkdir", name);
Line 886 
Line 886 
         /*          /*
          * Install new (temporary) file as the actual target           * Install new (temporary) file as the actual target
          */           */
         if (rename(new, target) < 0) {          if (rename(new, target) == -1) {
                 static const char fmt[] = "%s -> %s: rename failed: %s";                  static const char fmt[] = "%s -> %s: rename failed: %s";
                 struct stat stb;                  struct stat stb;
                 /*                  /*
Line 898 
Line 898 
                         /* Save the target */                          /* Save the target */
                         if ((savefile = savetarget(target, opts)) != NULL) {                          if ((savefile = savetarget(target, opts)) != NULL) {
                                 /* Retry installing new file as target */                                  /* Retry installing new file as target */
                                 if (rename(new, target) < 0) {                                  if (rename(new, target) == -1) {
                                         error(fmt, new, target, SYSERR);                                          error(fmt, new, target, SYSERR);
                                         /* Try to put back save file */                                          /* Try to put back save file */
                                         if (rename(savefile, target) < 0)                                          if (rename(savefile, target) == -1)
                                                 error(fmt,                                                  error(fmt,
                                                       savefile, target, SYSERR);                                                        savefile, target, SYSERR);
                                         (void) unlink(new);                                          (void) unlink(new);
Line 968 
Line 968 
                                 message(MT_NOTICE, "%s: need to remove",                                  message(MT_NOTICE, "%s: need to remove",
                                         target);                                          target);
                         else {                          else {
                                 if (unlink(target) < 0) {                                  if (unlink(target) == -1) {
                                         error("%s: remove failed: %s",                                          error("%s: remove failed: %s",
                                               target, SYSERR);                                                target, SYSERR);
                                         return;                                          return;
Line 1149 
Line 1149 
          * Make new symlink using a temporary name           * Make new symlink using a temporary name
          */           */
         if (chkparent(new, opts) < 0 || mktemp(new) == NULL ||          if (chkparent(new, opts) < 0 || mktemp(new) == NULL ||
             symlink(dbuf, new) < 0) {              symlink(dbuf, new) == -1) {
                 error("%s -> %s: symlink failed: %s", new, dbuf, SYSERR);                  error("%s -> %s: symlink failed: %s", new, dbuf, SYSERR);
                 return;                  return;
         }          }
Line 1175 
Line 1175 
         /*          /*
          * Install link as the target           * Install link as the target
          */           */
         if (rename(new, target) < 0) {          if (rename(new, target) == -1) {
                 error("%s -> %s: symlink rename failed: %s",                  error("%s -> %s: symlink rename failed: %s",
                       new, target, SYSERR);                        new, target, SYSERR);
                 (void) unlink(new);                  (void) unlink(new);
Line 1259 
Line 1259 
                 error("%s: no parent: %s ", target, SYSERR);                  error("%s: no parent: %s ", target, SYSERR);
                 return;                  return;
         }          }
         if (exists && (unlink(target) < 0)) {          if (exists && (unlink(target) == -1)) {
                 error("%s: unlink failed: %s", target, SYSERR);                  error("%s: unlink failed: %s", target, SYSERR);
                 return;                  return;
         }          }
         if (linkat(AT_FDCWD, expbuf, AT_FDCWD, target, 0) < 0) {          if (linkat(AT_FDCWD, expbuf, AT_FDCWD, target, 0) == -1) {
                 error("%s: cannot link to %s: %s", target, oldname, SYSERR);                  error("%s: cannot link to %s: %s", target, oldname, SYSERR);
                 return;                  return;
         }          }

Legend:
Removed from v.1.46  
changed lines
  Added in v.1.47