0

I am writing software that has an option to delete all files is a user-specified directory. This is the usual case for software. For example, cpp compiler has an option to delete all previously generated binaries.

My program accepts any path from the user for removal, which could lead to them accidentally removing their home directory together with all its content, the content of /etc/bin, or any other directory that is not protected by the file system for the current user.

I can check the home directory myself, but I can't know all possible weak parts, especially since my software is cross-platform.

So the question is:

Is there a list of paths that are not recommended to be deleted by the user so that I can simply match user input by the pattern and at least warn them?

2

Any path could easily be something the user doesn't want to delete. The user should not run your tool on a folder if that folder should not be deleted. Probably it is enough to always warn "THIS WILL DELETE ALL FILES IN /path/given/by/user, ARE YOU SURE?" and then rely on the OS (either through file permissions or access controls like SELinux) to protect them from anything stupendously dumb.

This does of course assume your app doesn't require superuser access to run, so that it will normally only be running as a normal user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.