-1
People, at a certain point in my code I am creating a folder (1) in which will be archived photos posted by users and a CSV file (2) in which will be archived the metadata of these images. I’m thinking here about permissions.
So far I’m using the 666 permissions, but I think that would represent a vulnerability, wouldn’t you? It would make life easier for some malicious user who wanted to delete both the file and the folder.
In my specific case, both photos and other data will only be stored and will not be used again (I’m just practicing here and I came up with this doubt). In that case 600 would suffice? This would ensure that the privilege of creating and deleting folders/files would be reserved to root?
And in the case of a system where these photos, once stored, were loaded according to the user, what permissions do you use? 644? That’s not the case yet, but if it were a system that was actually going to run in production, I wouldn’t know what to do in each of these scenarios. Any suggestions?
(1) os.Mkdir(foldername, 0666)
(2) metadataFile, err := os.OpenFile("metadata.csv", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)