4 Replies Latest reply on Jun 3, 2011 6:30 AM by Owain North

    Changing Owner of a File.


      Hello Community,


      I have a very straight forward question:


      Is it possible to change the owner of a file in coldfusion?


      I know that within the cffile tag, I can use mode to set permissions. Isn't something similar for the owner(s)?


      Thank you!

        • 1. Re: Changing Owner of a File.
          Adam Cameron. Level 5

          No there isn't.  There doesn't even seem to be a way to do it in Java, either (that I can find... and I only spent about 5min looking, to be honest).  I guess this is because stuff like file ownership is file-system-specific, and Java positions itself as being as platform neutral as possible.  Or something.


          Anyway, you might want to have a look at CFEXECUTE, and call chown that way.  bear in mind, though, that the user that CF runs as usually has very limited permissions to the file system, so probably won't be able to do things like this.


          Why do you need to change file ownership, out of interest?




          • 2. Re: Changing Owner of a File.
            Owain North Level 4

            You'll also be able to do it through .NET, using createObject(). As pointed out, however, CF shouldn't really have permissions to do this if it's been set up properly.

            • 3. Re: Changing Owner of a File.
              ysaismartinez Level 1

              Thank you guys.


              No, I am not doing it for fun. I grabbing a file from a Windows box, processing it, and saving it as a CSV. Then that CSV is uploaded to a Unix server and I set the permissions to 666 and they want the owner to be let's say "theowner." They told me that one of the files has the proper owner, but the other one does not. I was a little perplexed since I thought that once I had the username, host, and password, to ftp a file, the remote server will use the credentials I used to determine its owner, thus no manual setting was needed. I checked the underlying Java methods to see if I could do it but I did not find anything helpful.

              • 4. Re: Changing Owner of a File.
                Owain North Level 4

                That's odd, as you say the owner should be whoever uploaded the file. Is the sticky bit set on the folder itself so it automatically mirrors permissions across? I'm not sure you can even change the owner of a file unless you're root.