Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Changing Owner of a File.

Guest
Jun 02, 2011 Jun 02, 2011

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!

TOPICS
Advanced techniques
905
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 03, 2011 Jun 03, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 03, 2011 Jun 03, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 03, 2011 Jun 03, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 03, 2011 Jun 03, 2011
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources