I managed to get my hands on a nifty ftp object. It is very low level and easy to adapt. I'm using it to transfer files from one Mac to another via FTP.
Now, the issue I'm having is that when the file, that is transfered, reaches its destination, the other Mac, the access permissions is set , at random intervals, to "Everyone" : "No Access". So sometimes, whatever I do with the files fails randomly because my application can't access the files.
Is there a way I can change the file's access permissions in Objective-C?
Regards,
EZFrag
For permissons of local files, you'd want [NSFileManager setAttributes:ofItemAtPath:error:]
And the attribute dictionary you'd want to use would include NSFilePosixPermissions.
Related
I'm trying to discover a way to save an NSDictionary, (which will probably hold high scores and users on a particular system.) onto a new file. I would like to know how to create the file, and put it in the location that it should be, preferably where it can't be touched by the user. Is there any place that these kinds of files are meant to be?
There are many ways to do it.
Either make Plist of your NSDictionary and write to Documents Directory
OR
Make JSON string >> Convert it to NSData using NSJSONSerialization >> Write it to Documents Directory
You can write files in documents directory using NSFileManager
Have a look at this question:
How to save data into the User's Application Support?
The best place to save such files is the "Application Support" folder in the users "Library" folder. The user could go there, but most users won't.
The first answer also has a link on how to save an NSDictionary to a file.
Edit
My answer applies for osx applications only. If you making an app for ios, you should save your file to your app's "Documents" directory.
Is it possible to retrieve the name (or IP address, whichever) of a computer that is accessing a file on my shared folders via workgroup? If so, what would I need to retrieve it? Filename? File directory?
I am using vb.net 2005.
The short answer is NO.
But, if you are on the computer that has the share, you can go into Administrative Tools>>Computer Management>>System Tools>>Shared Folders>>Open Files and and you might get some information about what files and who. But this is not reliable because only certain files apply locking and they will only show up here if locked from another computer. Too often windows will tell you the file is locked but you will not see the information in here.
I'm building an app that has projects. A project can have many files in it which are pointed to from a project file. Theses files are copied to the projects folder so I know where they will be but as far as I know in WinJS you can only get access to files the user directly give access to. The user will select the project file, I'll be able to read it but I'll have no way to access the projects files. I do know I can do something like package the project up as a single file and then extract the individual files in my apps local file system but doing so is sub-optimal to me and I'd prefer to do the folder based structure if I can.
I'm not entirely sure I get it, but I'll give it a shot. In a Windows Store app, you do have access to more than just what the user directly gives access to. If you want to pick a file from anywhere on the computer (our from other apps through the FilePicker contract) then, yes, the user has to pick them, but you app has full access to the isolated storage and if it declares access to the user's documents library and the user allows it, then you have access (to your declared file types) in there as well.
I think the choice of going to isolated storage versus the user's document library comes down to whether or not the user would expect to have the project files outside of your app. Might they email a project to a friend? Might they manipulate the project with another app? Might they want to back the project up? If so, then use their documents library. If not, then the data is more application data than user data and could be stored in the local app storage.
Hope that answers the question. If not, then please clarify.
I'm new at writing code for websites. The website allows users to upload files, such as profile pictures or other pictures. The files are saved in the unix file system and the URLs to find those images are stored in a MySQL database.
It seems like the only way I can let the user upload files is to give write access to anybody using chmod. Otherwise it complains that it doesn't have write permissions. But they shouldn't be able to write whatever they want or overwrite other users stuff. Similarly, to allow users to see images that they have rightful access to, they need read permissions on the file system. But now that means that anybody with the url to that picture can see the image too, correct? That's not what I want.
Is there a solution to this contradiction? Or am I thinking about the problem incorrectly? Thanks for any help.
You need to manage the permissions in your application and not expose arbitrary parts of your local filesystem directly to the clients. Your application should decide what files someone can see or where to write data. You should not trust data (filenames, etc) from your clients...ideally, store files on disk using systematically generated names and store human-readable names in the database.
SunStar9,
Since you are already using a MySQL database to store the URL of the image on the file system, why not just store the image itself as a BLOB (binary large object)?
This is generally a well-accepted design practice for allowing users to upload binary data to a website.
Are you using PHP, Java, Ruby/Rails, or something other to develop your website? Depending on what you are using, there could be file upload/management plugins or modules that will help you develop what you are trying to do if you are certain you want to use the files ystem for storing the image data.
I am writing a program in vb.net that requires a user to log in before he can use the application. The main user is created when the program is installed, similar to how windows works when it is installed.
The main user can add additional users to the program. I already know that I should store the passwords encrypted. My question is, where should I store the usernames and passwords? The registry, Isolated storage or .config file. I don't want any user to be able to modify/delete that file as the other user would obviously not be able to log in. Also, this file should be accessible for any user that logs into the computer.
The computer is not guaranteed to be connected to the internet, so it must be stored locally.
Thanks
To tell you the truth if someone has the will power to look for the file they will find it, so storage can help up security but I would focus on the contents of the file itself.
You could try to store the data of the application as a encrypted file which could stop the amateur attempts but as you are using the .net framework your program could could be decompiled and any symmetric encryption algorithms could be rendered useless.
I think your best bet would be to either generate a seed according to the computer the program is on, and if decryption fails call home or go into Lock Down.
Another option would be to store the encrypted (encrypted with your symmetric key) file and a hash file (in different locations probably). If the hash of the loaded file then does not match the hash file your program could then call home (If you have a home to call).
This is just a idea, haven't actually tried anything like this.
If you are not able to use windows users/credentials in any way on the machine, then there really is no absolute way to prevent the file from being removed/changed, Since anyone on the computer has the same access as the main user, who needs rights to modify the file in order for him to add users through the program.
The only way to do it for sure is to have the main user logon with a different user name, and set the file permissions on that file/folder to make sure that only the main user has modify permission to the file (and the other user account does not have the right to modify permissions). I know you said it wouldn't work in your environment(which is?) but you might be able to create users and run stuff under different credentials through your code without having the users log on any different.
The only crazy way I can think of is to create a service on the computer that once it starts running, it opens and holds a handle to that file with sharing set such that no other process can open the file for writing. You'd of course have to workout some way for the main user to be able to add users.