utils.c (40fc4ee2) utils.c (426e9c1d)
1/*-
2 * Copyright (c) 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35#if 0
36static char sccsid[] = "@(#)utils.c 8.3 (Berkeley) 4/1/94";
37#endif
38static const char rcsid[] =
1/*-
2 * Copyright (c) 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35#if 0
36static char sccsid[] = "@(#)utils.c 8.3 (Berkeley) 4/1/94";
37#endif
38static const char rcsid[] =
39 "$Id: utils.c,v 1.20 1998/06/10 06:29:23 peter Exp $";
39 "$Id: utils.c,v 1.21 1998/11/18 11:47:45 bde Exp $";
40#endif /* not lint */
41
42#include <sys/param.h>
43#include <sys/stat.h>
44#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
45#include <sys/mman.h>
46#endif
47

--- 130 unchanged lines hidden (view full) ---

178 if (pflag && setfile(fs, to_fd))
179 rval = 1;
180 /*
181 * If the source was setuid or setgid, lose the bits unless the
182 * copy is owned by the same user and group.
183 */
184#define RETAINBITS \
185 (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
40#endif /* not lint */
41
42#include <sys/param.h>
43#include <sys/stat.h>
44#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
45#include <sys/mman.h>
46#endif
47

--- 130 unchanged lines hidden (view full) ---

178 if (pflag && setfile(fs, to_fd))
179 rval = 1;
180 /*
181 * If the source was setuid or setgid, lose the bits unless the
182 * copy is owned by the same user and group.
183 */
184#define RETAINBITS \
185 (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
186 else if (fs->st_mode & (S_ISUID | S_ISGID) && fs->st_uid == myuid)
186 else if (fs->st_mode & (S_ISUID | S_ISGID) && fs->st_uid == myuid) {
187 if (fstat(to_fd, &to_stat)) {
188 warn("%s", to.p_path);
189 rval = 1;
190 } else if (fs->st_gid == to_stat.st_gid &&
191 fchmod(to_fd, fs->st_mode & RETAINBITS & ~myumask)) {
192 warn("%s", to.p_path);
193 rval = 1;
194 }
187 if (fstat(to_fd, &to_stat)) {
188 warn("%s", to.p_path);
189 rval = 1;
190 } else if (fs->st_gid == to_stat.st_gid &&
191 fchmod(to_fd, fs->st_mode & RETAINBITS & ~myumask)) {
192 warn("%s", to.p_path);
193 rval = 1;
194 }
195 }
195 (void)close(from_fd);
196 if (close(to_fd)) {
197 warn("%s", to.p_path);
198 rval = 1;
199 }
200 return (rval);
201}
202

--- 124 unchanged lines hidden ---
196 (void)close(from_fd);
197 if (close(to_fd)) {
198 warn("%s", to.p_path);
199 rval = 1;
200 }
201 return (rval);
202}
203

--- 124 unchanged lines hidden ---