-----BEGIN PGP SIGNED MESSAGE-----
Please find enclosed patches for mv. This fixes two PRs that I don't
recall the numbers of. These fixes are from OpenBSD. I want to
commit them as soon as possible because it leaves around setuid files
that owners may not have indended to be setuid.
Warner
Index: mv.c
RCS file: /home/imp/FreeBSD/CVS/src/bin/mv/mv.c,v
retrieving revision 1.10
diff -u -r1.10 mv.c
- --- mv.c 1997/01/14 05:31:31 1.10
+++ mv.c 1997/02/18 01:09:40
@@ -207,17 +207,24 @@
static u_int blen;
static char *bp;
register int nread, from_fd, to_fd;
+ int badchown = 0, serrno;
if ((from_fd = open(from, O_RDONLY, 0)) < 0) {
warn("%s", from);
return (1);
}
- - if ((to_fd =
- - open(to, O_CREAT | O_TRUNC | O_WRONLY, sbp->st_mode)) < 0) {
+ if ((to_fd = open(to, O_CREAT | O_TRUNC | O_WRONLY, 0600)) < 0) {
warn("%s", to);
(void)close(from_fd);
return (1);
}
+
+ if (fchown(to_fd, sbp->st_uid, sbp->st_gid)) {
+ serrno = errno;
+ badchown = 1;
+ }
+ (void) fchmod(to_fd, sbp->st_mode & ~(S_ISUID|S_ISGID));
+
if (!blen && !(bp = malloc(blen = sbp->st_blksize))) {
warn(NULL);
return (1);
@@ -237,8 +244,15 @@
}
(void)close(from_fd);
- - if (fchown(to_fd, sbp->st_uid, sbp->st_gid))
- - warn("%s: set owner/group", to);
+ if (badchown) {
+ errno = serrno;
+ if ((sbp->st_mode & (S_ISUID|S_ISGID))) {
+ warn("%s: set owner/group; not setting setuid/setgid",
+ to);
+ sbp->st_mode &= ~(S_ISUID|S_ISGID);
+ } else if (!fflg)
+ warn("%s: set owner/group", to);
+ }
if (fchmod(to_fd, sbp->st_mode))
warn("%s: set mode", to);
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface
iQCVAwUBMxJGDdxynu/2qPVhAQErtgP/Y8xivLxmYOCvDBEtbALukWt5YS+wyUwm
fuzR97sb2r724Zm9Jos4bM+Ywwp8cwK/Q52cz8ghP5FOKeqIp89Dd8Dh36PxwNQd
AmTNz8llsr/Z1qqYu4XRQniFAJ2t+GYcCw3rdpXr7OuSrGHpt4lVjX8MsyvBvQo9
xl49jX5Xhjc=
=MsaI
-----END PGP SIGNATURE-----
Received on Mon Feb 24 17:53:38 1997
This archive was generated by hypermail 2.1.8
: Wed Aug 23 2006 - 12:41:03 EDT
|