-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add built-in support for automatically deleting files after a certain amount of time #11
Comments
Actually [code snippet removed by @horazont for security reasons; see discussion below; this snippet was pretty much the same as below, but without that's pretty much just as good. |
I’d also recommend the cronjob at this stage. However, the command line is a bit unsafe since the filename is determined by the client. If the client can pick a filename with e.g. a newline in it, it could make the cronjob delete arbitrary files. To avoid that, use:
The |
Ouch, good catch! I'm usually pretty good about catching shell injections but I didn't try. |
```
find /home/prosody-filer/upload/ -mindepth 1 -type d -mtime +28 -print0 | xargs -0 -- rm -rf
```
Good catch. We should add this to the README. I was using the unsafe
command in my cronjob for over 3 years.
|
By using `-print0`, filenames to purge are delimited by nuls instead of newlines, which can't be found in filenames on unix. Previously, someone who uploaded a file could inject an *extra set* of files to try to erase. For example, by uploading a file to: "/path/to/dir/file1.png%09/var/log/messages%09/etc/passwd%09/home/user/something.png" I can't take credit for this. This is from @horazont in horazont/xmpp-http-upload#11 (comment)
What a good open source day 👯 |
@kousu I took the liberty to edit your comment above so that someone just copying the first snippet they find isn’t getting into trouble :) |
mod_http_upload supports
http_upload_expire_after
. I would like to see this in here, too.(not demanding; just making a note; maybe i'll get around to writing this myself, once I get this installed)
The text was updated successfully, but these errors were encountered: