NetFileCache and LocalRepo

- LocalRepo - use a local folder as a CKAN repo
- Replaced Cache with NetFileCache, now everything is cached by url according to #111 
- No tests yet :(
- Doesn't get filename from HTTP headers yet
I heartily endorse either system provided or otherwise generated randomized
temp files/folders.

On Sat, Nov 8, 2014 at 2:48 PM, Paul Fenwick <notifications@github.com>
wrote:

> In CKAN/CKAN/NetFileCache.cs:
>
> > +using System.Text;
> > +
> > +namespace CKAN
> > +{
> > +
> > +    public class NetFileCache
> > +    {
> > +
> > +        private string tempPath = "";
> > +        private string cachePath = "";
> > +
> > +        public NetFileCache(string _cachePath, string _tempPath = null)
> > +        {
> > +            if (_tempPath == null)
> > +            {
> > +                tempPath = Path.Combine(Path.GetTempPath(), "ckan_temp");
>
> Uh oh! That's going to give us lots of pain on multi-user systems! If
> /tmp/ckan_temp has been created by one user, then it can't be used by
> another.
>
> What's more, it may even expose us to symlink attacks. If an attacker
> places a symlink in /tmp/ckan_temp to point to somewhere else on the
> system, we'll go start writing files there.
>
> While neither of these are going to keep me awake at night, they're both
> easily fixed. While we don't have mkdtemp available to us in C#, we can
> use GetTempFileName to create a temp file that we know did not exist
> previously, and then delete that and create a directory in its steed.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/KSP-CKAN/CKAN/pull/282/files#r20049525>.
>