File Ownership Change

Hi,

I have several directories under an upload directory where differnt users upload their files (with exxactly the same file name every week) using their own user ids.

There is a requirement that once any user uploads the file I have to clean that file and remove extra whitespaces and unreadable characters.

I have a cleanup script which runs under an admin user (basically a group owner user say xyz) account which has access to all these directories.

Once I do the clean up the owner of the uploaded file gets changed to admin user and then next time when any user tries to upload their file again they get permission denied error as the file with same name exist with different owner.

Question is

  1. How to give access to the individual user to over write the file own by the admin user or
  2. How not to change the owner of the file to the admin user while cleaning up the file.

Note: All the users are part of the same group whose owner is the admin user mentioned above. i.e. in the /etc/group file all the user ids who uploads the file are listed under the group id

 
xyz:!:212:userid1,userid2,userid3

my cleanup script runs as user xyz and the ownership gets changed to xyz and then the userid1, userid2 and userid3 are not able to upload their files.

the owner of the upload directory is userid1

 
abc        100      5/21/2011       rwxrwxr_x         userid1

before upload

 
abc.csv   100      5/21/2011       rw_r__r__         userid1

after upload and clean up

 
abc.csv   100      5/21/2011       rw_r__r__         xyz

Next time when user userid1 tries to upload gets permission denied error.

Hope I am not confusing here.

With a permissions problem like this, please show the output from "ls -lad" for each relevant file and parent directory. A weird edited output is not exactly useful because we cannot determine which field is the user and which is the group. Where does "100" come from I wonder? Is "xyz" both the name of a group and the name of a user in group "100"? Hard to guess.

First impression is to record the owner and group of the file before editing each file, then issue "chmod owner:group filename" after editing and set the permissions to something like 775.

Sorry for the confusion here is the output you requested

Directory - abc

 
$ ls -lad abc
drwxrwsr-x    3 userid1  xyz             512 May 31 13:59 abc

File inside abc - before upload

 
$ cd abc
$ ls -al
total 288
-rw-r--r--    1 userid1      xyz           63184 May 31 13:59 abc.csv

after upload

 
$ ls -al
total 288
-rw-r--r--    1 xyz      xyz           63184 May 31 13:59 abc.csv

I hope this will help. Thanks in advance

Now we are clear that "xyz" is both the name of a username and the name of a group the fog is clearing.

Make USER "xyz" a member of group "xyz". i.e. Add "xyz" to group "xyz" (albeit as the usr "xyz"'s secondary group).

usermod -G xyz xyz

Then open the permissions on each relevant file to the group.

chmod 664 filename