aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-01-06 18:22:05 +0000
committerlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-01-06 18:22:05 +0000
commitfcb47366ebc1c8b91c7be87599839c16641f483e (patch)
treecc713e60cce97b5aa6f661acb22d57378c083a42
parent0b66a6e5cace264fb6a577f4096910aeb066c22e (diff)
downloadbusybox-w32-fcb47366ebc1c8b91c7be87599839c16641f483e.tar.gz
busybox-w32-fcb47366ebc1c8b91c7be87599839c16641f483e.tar.bz2
busybox-w32-fcb47366ebc1c8b91c7be87599839c16641f483e.zip
No, we _want_ the suid and sgid bits reverted by chown, for security reasons.
They mean something different when the user they're switching to is different, so if you still want suid you reset it afterwards. This is a safety feature. git-svn-id: svn://busybox.net/trunk/busybox@13133 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--coreutils/chown.c31
1 files changed, 7 insertions, 24 deletions
diff --git a/coreutils/chown.c b/coreutils/chown.c
index daf77e294..98f9d9788 100644
--- a/coreutils/chown.c
+++ b/coreutils/chown.c
@@ -4,20 +4,7 @@
4 * 4 *
5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> 5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */ 8 */
22 9
23/* BB_AUDIT SUSv3 defects - unsupported options -h, -H, -L, and -P. */ 10/* BB_AUDIT SUSv3 defects - unsupported options -h, -H, -L, and -P. */
@@ -30,11 +17,6 @@
30#include <string.h> 17#include <string.h>
31#include "busybox.h" 18#include "busybox.h"
32 19
33/* Don't use lchown for glibc older then 2.1.x */
34#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
35#define lchown chown
36#endif
37
38static long uid; 20static long uid;
39static long gid; 21static long gid;
40 22
@@ -42,12 +24,13 @@ static int (*chown_func)(const char *, uid_t, gid_t) = chown;
42 24
43static int fileAction(const char *fileName, struct stat *statbuf, void* junk) 25static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
44{ 26{
45 if (chown_func(fileName, uid, (gid == -1) ? statbuf->st_gid : gid) == 0) { 27 if (!chown_func(fileName,
46 chmod(fileName, statbuf->st_mode); 28 (uid == -1) ? statbuf->st_uid : uid,
47 return (TRUE); 29 (gid == -1) ? statbuf->st_gid : gid)) {
30 return TRUE;
48 } 31 }
49 bb_perror_msg("%s", fileName); /* Avoid multibyte problems. */ 32 bb_perror_msg("%s", fileName); /* A filename could have % in it... */
50 return (FALSE); 33 return FALSE;
51} 34}
52 35
53#define FLAG_R 1 36#define FLAG_R 1