Skip to main content
June 2, 2011
Question

Changing Owner of a File.

  • June 2, 2011
  • 2 replies
  • 964 views

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!

This topic has been closed for replies.

2 replies

June 3, 2011

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.

Owainnorth
Inspiring
June 3, 2011

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.

Inspiring
June 3, 2011

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?

--

Adam

Owainnorth
Inspiring
June 3, 2011

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.