I've steered away from trying to use the function ...
# cfml-general
h
I've steered away from trying to use the function directoryCreate. I always end up with a directory that I can't use because permissions aren't right. I need to figure it out though. Eventually I'd like to get to a point where I have an external drive that I'm creating directories on and then moving files in or out of it depending on the need. For experimentation I'm merely creating "Test Directory" in the root of my staging area. iI've a file called test.cfm and it has the following code to create a directory:
Copy code
path = expandPath("./Test Directory")
directoryCreate( path )
echo("Done")
It works of course, but again I can't use the directory. I opened up terminal (macOS) and ran the ls -l command to see what permissions where assigned.
Copy code
drwxr-x---   2 root        staff     64 Oct 25 13:55 Test Directory
Interestingly I've other folders that i created using the Finder.app's create folder option and they all have the following :
Copy code
drwxr-xr-x   9 hughrainey  staff    288 Oct 17 10:11 a
drwxr-xr-x   5 hughrainey  staff    160 Sep 30 16:11 assets
drwxr-xr-x  38 hughrainey  staff   1216 Oct  9 15:17 bean
and so on, and so on. . . . .e From the looks of it my tomcat <--- I'm assuming || must be running as a root user and not as me the owner "hughrainey". In doing some research on the googles I came across the suggestion to use cfexecute. In the instance I found they where using cfexecute to change permissions. Could the same be done to change the owner using chown? I looked up cfexecute on cfdocs.org. But I don't know if it's just me but it didn't give me a clear idea on how to run a terminal command from cfexecute. Two questions here: 1) Is trying to use cfexecute the way to go here. Or is that adding a level of complexity that is unneccesary? 2) If cfexecute isn't relevant, then how do I create a directory that I can write to?
1
q
ACF and Lucee will both create the directory with ownership to match the running process. So, if you are running ACF as root, it will have root permissions. The right way to go about it is to run ACF as you (hughrainey), or as a dedicated service account, add them to the "staff" group, and then you should be good.
b
Copy code
I've steered away from trying to use the function directoryCreate. I always end up with a directory that I can't use because permissions aren't right....
To add to what @quetwo says, hoping it will help. The directory so created is ColdFusion's, not yours. Therefore, ColdFusion should "always ends up with a directory it can use because the permissions are right".
Copy code
I've steered away from trying to use the function directoryCreate. I always end up with a directory that I can't use because permissions aren't right....
To add to what @quetwo says, hoping it will help. The directory so created is ColdFusion's, not yours. Therefore, ColdFusion should "always end up with a directory it can use because the permissions are right".
👍 2
d
We use dedicated service accounts for all CF servers, specific to that server (different apps and dev vs prod). You do need to set up and maintain those accounts, but you don't want CF running as a human user, especially and admin like you probably are.