Article View: gnu.utils.bug
Article #36Bug in chown [fileutils 3.3], +fix
From: Mike Rendell
Date: Sat, 31 Oct 1992 12:19
Date: Sat, 31 Oct 1992 12:19
98 lines
3119 bytes
3119 bytes
Environment: Mips M/120 running Riscos/5.00 using Mips 3.0 compilers
and Sun SparcStation 2 running SunOS 4.1.x using gcc 2.2.2
Chown does not work on (at least some) machines that have non-`int'
uid_t and gid_t types (e.g., ones where uid_t is an unsigned short).
This is because parse_user_spec() expects pointers to [ud]id_t's but is
passed pointers to int's. The following diff fixes chown.c to use the
correct types when dealing with uids and gids.
[BTW: The diff I recently sent for dd.c is backwards (i.e., generated
by diff -c newfile oldfile).]
*** chown.c.orig Sat Oct 31 15:49:53 1992
--- chown.c Sat Oct 31 15:49:42 1992
***************
*** 96,103 ****
int argc;
char **argv;
{
! int user = -1; /* New uid; -1 if not to be changed. */
! int group = -1; /* New gid; -1 if not to be changed. */
int errors = 0;
int optc;
char *e;
--- 96,103 ----
int argc;
char **argv;
{
! uid_t user = (uid_t) -1; /* New uid; -1 if not to be changed. */
! gid_t group = (gid_t) -1; /* New gid; -1 if not to be changed. */
int errors = 0;
int optc;
char *e;
***************
*** 150,159 ****
int
change_file_owner (file, user, group)
char *file;
! int user, group;
{
struct stat file_stats;
! int newuser, newgroup;
int errors = 0;
if (lstat (file, &file_stats))
--- 150,161 ----
int
change_file_owner (file, user, group)
char *file;
! uid_t user;
! gid_t group;
{
struct stat file_stats;
! uid_t newuser;
! gid_t newgroup;
int errors = 0;
if (lstat (file, &file_stats))
***************
*** 163,170 ****
return 1;
}
! newuser = user == -1 ? file_stats.st_uid : user;
! newgroup = group == -1 ? file_stats.st_gid : group;
if (newuser != file_stats.st_uid || newgroup != file_stats.st_gid)
{
if (verbose)
--- 165,172 ----
return 1;
}
! newuser = user == (uid_t) -1 ? file_stats.st_uid : user;
! newgroup = group == (gid_t) -1 ? file_stats.st_gid : group;
if (newuser != file_stats.st_uid || newgroup != file_stats.st_gid)
{
if (verbose)
***************
*** 192,198 ****
int
change_dir_owner (dir, user, group, statp)
char *dir;
! int user, group;
struct stat *statp;
{
char *name_space, *namep;
--- 194,201 ----
int
change_dir_owner (dir, user, group, statp)
char *dir;
! uid_t user;
! gid_t group;
struct stat *statp;
{
char *name_space, *namep;
--
Michael Rendell - Dept. of Comp. Sci., Memorial University of Newfoundland
Technical Details
Message-ID:
<9210311937.AA19675@mercury.cs.mun.ca>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!mercury.cs.mun.ca!michaelShow Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!mercury.cs.mun.ca!michael From: michael@mercury.cs.mun.ca (Mike Rendell) Subject: Bug in chown [fileutils 3.3], +fix Message-ID: <9210311937.AA19675@mercury.cs.mun.ca> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Sat, 31 Oct 1992 12:19:49 GMT Approved: bug-gnu-utils@prep.ai.mit.edu Lines: 99