🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #212

Re: fileutils 3.3 (chown.c fix) patch included

#212
From: Glaze
Date: Thu, 06 Aug 1992 23:31
94 lines
3187 bytes
cattelan@everest.ee.umn.edu (Russell Cattelan) writes:

>I found that with fileutils 3.3 chown stoped working, well with a
>little hacking I found that the types for user and group were declared
>as "int" rather than uid_t and gid_t,  thus the values set by
>parse_user_spec()  were misaligned.

>Sooooo here is the simple fix.
[changes types of vars. `user' and `group']

>Also chown on the SGI's is giving me this error message.
>chown: ./cp.h: Invalid argument
>I haven't figured this one out yet 

Comes under the same thing.  It's failing in the lines
user = newuser == -1 ? file_stats.st_uid : ...... 
group = newgroup == -1 ? ...............

To fix on the SGIs, change the variable declarations of newuser/newgroup
to uid_t/gid_t. You'll also need to modify the above lines (167 and 168
I think) to something like
user = newuser == (uid_t) -1 ? .....
group = newgroup == (gid_t) -1 ? .....

I didn't quite understand why this was necessary.
type(uid_t) is type(gid_t) is u_short. The compiler then tried to compare
a short against a long -1 . Seems pretty stupid to me.

Anyway, if you can't be bothered doing it manually, here's a patch

*** chown.c	Fri Aug  7 09:41:10 1992
--- chown.new	Fri Aug  7 09:43:10 1992
***************
*** 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;
Technical Details
Message-ID: <glaze.876@glaze>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.mu.oz.AU!glaze
References: <199208041515.AA22489@everest.ee.umn.edu>

Show Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.mu.oz.AU!glaze
From: glaze@cs.mu.oz.AU (Glaze)
Subject: Re: fileutils 3.3 (chown.c fix) patch included
Message-ID: <glaze.876@glaze>
Sender: gnulists@ai.mit.edu
Organization: Computer Science, University of Melbourne, Australia
References: <199208041515.AA22489@everest.ee.umn.edu>
Distribution: gnu
Date: Thu, 6 Aug 1992 23:31:16 GMT
Approved: bug-gnu-utils@prep.ai.mit.edu
Lines: 95