~ubuntu-branches/ubuntu/trusty/vsftpd/trusty-proposed

1.1.1 by LaMont Jones
Import upstream version 2.0.1
1
/*
2
 * Part of Very Secure FTPd
3
 * Licence: GPL v2
4
 * Author: Chris Evans
5
 * access.c
6
 *
7
 * Routines to do very very simple access control based on filenames.
8
 */
9
10
#include "access.h"
11
#include "ls.h"
12
#include "tunables.h"
13
#include "str.h"
14
15
int
16
vsf_access_check_file(const struct mystr* p_filename_str)
17
{
18
  static struct mystr s_access_str;
1.5.12 by Daniel Baumann
Import upstream version 2.3.4
19
  unsigned int iters = 0;
1.1.1 by LaMont Jones
Import upstream version 2.0.1
20
21
  if (!tunable_deny_file)
22
  {
23
    return 1;
24
  }
25
  if (str_isempty(&s_access_str))
26
  {
27
    str_alloc_text(&s_access_str, tunable_deny_file);
28
  }
1.5.12 by Daniel Baumann
Import upstream version 2.3.4
29
  if (vsf_filename_passes_filter(p_filename_str, &s_access_str, &iters))
1.1.1 by LaMont Jones
Import upstream version 2.0.1
30
  {
31
    return 0;
32
  }
33
  else
34
  {
35
    struct str_locate_result loc_res =
36
      str_locate_str(p_filename_str, &s_access_str);
37
    if (loc_res.found)
38
    {
39
      return 0;
40
    }
41
  }
42
  return 1;
43
}
44
45
int
46
vsf_access_check_file_visible(const struct mystr* p_filename_str)
47
{
48
  static struct mystr s_access_str;
1.5.12 by Daniel Baumann
Import upstream version 2.3.4
49
  unsigned int iters = 0;
1.1.1 by LaMont Jones
Import upstream version 2.0.1
50
51
  if (!tunable_hide_file)
52
  {
53
    return 1;
54
  }
55
  if (str_isempty(&s_access_str))
56
  {
57
    str_alloc_text(&s_access_str, tunable_hide_file);
58
  }
1.5.12 by Daniel Baumann
Import upstream version 2.3.4
59
  if (vsf_filename_passes_filter(p_filename_str, &s_access_str, &iters))
1.1.1 by LaMont Jones
Import upstream version 2.0.1
60
  {
61
    return 0;
62
  }
63
  else
64
  {
65
    struct str_locate_result loc_res =
66
      str_locate_str(p_filename_str, &s_access_str);
67
    if (loc_res.found)
68
    {
69
      return 0;
70
    }
71
  }
72
  return 1;
73
}
74