=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/rdistd/server.c,v retrieving revision 1.46 retrieving revision 1.47 diff -c -r1.46 -r1.47 *** src/usr.bin/rdistd/server.c 2019/06/28 05:35:35 1.46 --- src/usr.bin/rdistd/server.c 2019/06/28 13:35:03 1.47 *************** *** 1,4 **** ! /* $OpenBSD: server.c,v 1.46 2019/06/28 05:35:35 deraadt Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. --- 1,4 ---- ! /* $OpenBSD: server.c,v 1.47 2019/06/28 13:35:03 deraadt Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. *************** *** 131,137 **** status = fchownat(AT_FDCWD, file, uid, gid, AT_SYMLINK_NOFOLLOW); ! if (status < 0) { if (uid == (uid_t)-1) message(MT_NOTICE, "%s: chgrp %d failed: %s", target, gid, SYSERR); --- 131,137 ---- status = fchownat(AT_FDCWD, file, uid, gid, AT_SYMLINK_NOFOLLOW); ! if (status == -1) { if (uid == (uid_t)-1) message(MT_NOTICE, "%s: chgrp %d failed: %s", target, gid, SYSERR); *************** *** 161,170 **** if (fd != -1 && !islink) status = fchmod(fd, mode); ! if (status < 0 && !islink) status = chmod(file, mode); ! if (status < 0) { message(MT_NOTICE, "%s: chmod failed: %s", target, SYSERR); return(-1); } --- 161,170 ---- if (fd != -1 && !islink) status = fchmod(fd, mode); ! if (status == -1 && !islink) status = chmod(file, mode); ! if (status == -1) { message(MT_NOTICE, "%s: chmod failed: %s", target, SYSERR); return(-1); } *************** *** 296,302 **** case S_IFBLK: case S_IFSOCK: case S_IFIFO: ! if (unlink(target) < 0) { if (errno == ETXTBSY) { if (!silent) message(MT_REMOTE|MT_NOTICE, --- 296,302 ---- case S_IFBLK: case S_IFSOCK: case S_IFIFO: ! if (unlink(target) == -1) { if (errno == ETXTBSY) { if (!silent) message(MT_REMOTE|MT_NOTICE, *************** *** 344,350 **** while ((*ptarget++ = *cp++) != '\0') continue; ptarget--; ! if (lstat(target, &stb) < 0) { if (!silent) message(MT_REMOTE|MT_WARNING, "%s: lstat failed: %s", --- 344,350 ---- while ((*ptarget++ = *cp++) != '\0') continue; ptarget--; ! if (lstat(target, &stb) == -1) { if (!silent) message(MT_REMOTE|MT_WARNING, "%s: lstat failed: %s", *************** *** 361,367 **** if (failures) return(-1); ! if (rmdir(target) < 0) { error("%s: rmdir failed: %s", target, SYSERR); return(-1); } --- 361,367 ---- if (failures) return(-1); ! if (rmdir(target) == -1) { error("%s: rmdir failed: %s", target, SYSERR); return(-1); } *************** *** 425,431 **** while ((*ptarget++ = *cp++) != '\0') continue; ptarget--; ! if (lstat(target, &stb) < 0) { message(MT_REMOTE|MT_WARNING, "%s: lstat failed: %s", target, SYSERR); continue; --- 425,431 ---- while ((*ptarget++ = *cp++) != '\0') continue; ptarget--; ! if (lstat(target, &stb) == -1) { message(MT_REMOTE|MT_WARNING, "%s: lstat failed: %s", target, SYSERR); continue; *************** *** 603,609 **** * If stbvalid is false, "stb" is not valid because the stat() * by is_*_mounted() either failed or does not match "target". */ ! if (!stbvalid && lstat(target, &stb) < 0) { if (errno == ENOENT) (void) sendcmd(QC_NO, NULL); else --- 603,609 ---- * If stbvalid is false, "stb" is not valid because the stat() * by is_*_mounted() either failed or does not match "target". */ ! if (!stbvalid && lstat(target, &stb) == -1) { if (errno == ENOENT) (void) sendcmd(QC_NO, NULL); else *************** *** 649,655 **** *cp = CNULL; ! if (lstat(name, &stb) < 0) { if (errno == ENOENT && chkparent(name, opts) >= 0) { if (mkdir(name, 0777 & ~oumask) == 0) { message(MT_NOTICE, "%s: mkdir", name); --- 649,655 ---- *cp = CNULL; ! if (lstat(name, &stb) == -1) { if (errno == ENOENT && chkparent(name, opts) >= 0) { if (mkdir(name, 0777 & ~oumask) == 0) { message(MT_NOTICE, "%s: mkdir", name); *************** *** 886,892 **** /* * Install new (temporary) file as the actual target */ ! if (rename(new, target) < 0) { static const char fmt[] = "%s -> %s: rename failed: %s"; struct stat stb; /* --- 886,892 ---- /* * Install new (temporary) file as the actual target */ ! if (rename(new, target) == -1) { static const char fmt[] = "%s -> %s: rename failed: %s"; struct stat stb; /* *************** *** 898,907 **** /* Save the target */ if ((savefile = savetarget(target, opts)) != NULL) { /* Retry installing new file as target */ ! if (rename(new, target) < 0) { error(fmt, new, target, SYSERR); /* Try to put back save file */ ! if (rename(savefile, target) < 0) error(fmt, savefile, target, SYSERR); (void) unlink(new); --- 898,907 ---- /* Save the target */ if ((savefile = savetarget(target, opts)) != NULL) { /* Retry installing new file as target */ ! if (rename(new, target) == -1) { error(fmt, new, target, SYSERR); /* Try to put back save file */ ! if (rename(savefile, target) == -1) error(fmt, savefile, target, SYSERR); (void) unlink(new); *************** *** 968,974 **** message(MT_NOTICE, "%s: need to remove", target); else { ! if (unlink(target) < 0) { error("%s: remove failed: %s", target, SYSERR); return; --- 968,974 ---- message(MT_NOTICE, "%s: need to remove", target); else { ! if (unlink(target) == -1) { error("%s: remove failed: %s", target, SYSERR); return; *************** *** 1149,1155 **** * Make new symlink using a temporary name */ if (chkparent(new, opts) < 0 || mktemp(new) == NULL || ! symlink(dbuf, new) < 0) { error("%s -> %s: symlink failed: %s", new, dbuf, SYSERR); return; } --- 1149,1155 ---- * Make new symlink using a temporary name */ if (chkparent(new, opts) < 0 || mktemp(new) == NULL || ! symlink(dbuf, new) == -1) { error("%s -> %s: symlink failed: %s", new, dbuf, SYSERR); return; } *************** *** 1175,1181 **** /* * Install link as the target */ ! if (rename(new, target) < 0) { error("%s -> %s: symlink rename failed: %s", new, target, SYSERR); (void) unlink(new); --- 1175,1181 ---- /* * Install link as the target */ ! if (rename(new, target) == -1) { error("%s -> %s: symlink rename failed: %s", new, target, SYSERR); (void) unlink(new); *************** *** 1259,1269 **** error("%s: no parent: %s ", target, SYSERR); return; } ! if (exists && (unlink(target) < 0)) { error("%s: unlink failed: %s", target, SYSERR); return; } ! if (linkat(AT_FDCWD, expbuf, AT_FDCWD, target, 0) < 0) { error("%s: cannot link to %s: %s", target, oldname, SYSERR); return; } --- 1259,1269 ---- error("%s: no parent: %s ", target, SYSERR); return; } ! if (exists && (unlink(target) == -1)) { error("%s: unlink failed: %s", target, SYSERR); return; } ! if (linkat(AT_FDCWD, expbuf, AT_FDCWD, target, 0) == -1) { error("%s: cannot link to %s: %s", target, oldname, SYSERR); return; }