🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

3 total messages Started by Russell Cattelan Tue, 04 Aug 1992 05:15
fileutils 3.3 (chown.c fix)
#197
Author: Russell Cattelan
Date: Tue, 04 Aug 1992 05:15
41 lines
1641 bytes
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.

*** chown.c	Tue Aug  4 09:44:27 1992
--- chown.c.orig	Tue Aug  4 09:56:23 1992
***************
*** 96,108 ****
       int argc;
       char **argv;
  {
- #if 0
    int user = -1;		/* New uid; -1 if not to be changed. */
    int group = -1;		/* New gid; -1 if not to be changed. */
- #endif
-   uid_t user =  -1;
-   gid_t group =  -1;
- 
    int errors = 0;
    int optc;
    char *e;
--- 96,103 ----

----------------------------------------------------------------------
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 

--
  Russell Cattelan
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Conway's Law:
        In any organization there will always be one person who knows
        what is going on.

        This person must be fired.
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Re: fileutils 3.3 (chown.c fix) patch included
#212
Author: 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;
Re: fileutils 3.3 (chown.c fix)
#230
Author: Glaze
Date: Sat, 08 Aug 1992 15:52
86 lines
2814 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.
[mini patch given]

>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 

It's the same problem. You didn't complete the patching of the variable
type defs. You need to change them all. Also, for some reason I had to
put (uid_t) and (gid_t) casting for the -1. Seems strange that the
compiler would try to compare a u_short (type of uid_t/gid_t) with a
long. Here's a full (I think) 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;
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads