summaryrefslogtreecommitdiffstats
path: root/bin/cp
diff options
context:
space:
mode:
Diffstat (limited to 'bin/cp')
-rw-r--r--bin/cp/cp.c8
-rw-r--r--bin/cp/extern.h3
-rw-r--r--bin/cp/utils.c20
3 files changed, 4 insertions, 27 deletions
diff --git a/bin/cp/cp.c b/bin/cp/cp.c
index 0592444..3478c73 100644
--- a/bin/cp/cp.c
+++ b/bin/cp/cp.c
@@ -83,9 +83,7 @@ static const char rcsid[] =
PATH_T to = { to.p_path, "", "" };
-uid_t myuid;
int Rflag, iflag, pflag, rflag, fflag, vflag;
-int myumask;
enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
@@ -170,12 +168,6 @@ main(argc, argv)
fts_options |= FTS_LOGICAL;
}
- myuid = getuid();
-
- /* Copy the umask for explicit mode setting. */
- myumask = umask(0);
- (void)umask(myumask);
-
/* Save the target base in "to". */
target = argv[--argc];
if (strlcpy(to.p_path, target, sizeof(to.p_path)) >= sizeof(to.p_path))
diff --git a/bin/cp/extern.h b/bin/cp/extern.h
index 3b0ecef..4e5f07c 100644
--- a/bin/cp/extern.h
+++ b/bin/cp/extern.h
@@ -41,8 +41,7 @@ typedef struct {
} PATH_T;
extern PATH_T to;
-extern uid_t myuid;
-extern int iflag, pflag, fflag, vflag, myumask;
+extern int iflag, pflag, fflag, vflag;
#include <sys/cdefs.h>
diff --git a/bin/cp/utils.c b/bin/cp/utils.c
index 110cc79..479550e 100644
--- a/bin/cp/utils.c
+++ b/bin/cp/utils.c
@@ -63,7 +63,7 @@ copy_file(entp, dne)
int dne;
{
static char buf[MAXBSIZE];
- struct stat to_stat, *fs;
+ struct stat *fs;
int ch, checkch, from_fd, rcount, rval, to_fd, wcount, wresid;
char *bufp;
#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
@@ -180,22 +180,6 @@ copy_file(entp, dne)
if (pflag && setfile(fs, to_fd))
rval = 1;
- /*
- * If the source was setuid or setgid, lose the bits unless the
- * copy is owned by the same user and group.
- */
-#define RETAINBITS \
- (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
- else if (fs->st_mode & (S_ISUID | S_ISGID) && fs->st_uid == myuid) {
- if (fstat(to_fd, &to_stat)) {
- warn("%s", to.p_path);
- rval = 1;
- } else if (fs->st_gid == to_stat.st_gid &&
- fchmod(to_fd, fs->st_mode & RETAINBITS & ~myumask)) {
- warn("%s", to.p_path);
- rval = 1;
- }
- }
(void)close(from_fd);
if (close(to_fd)) {
warn("%s", to.p_path);
@@ -260,6 +244,8 @@ copy_special(from_stat, exists)
return (pflag ? setfile(from_stat, 0) : 0);
}
+#define RETAINBITS \
+ (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
int
setfile(fs, fd)
OpenPOWER on IntegriCloud