vsftpd 2.0.7 - initial checkin.
[tomato.git] / release / src / router / vsftpd / access.c
blob3b327671ab8d015616df87a0374a092a53f69a29
1 /*
2 * Part of Very Secure FTPd
3 * Licence: GPL v2
4 * Author: Chris Evans
5 * access.c
7 * Routines to do very very simple access control based on filenames.
8 */
10 #include "access.h"
11 #include "ls.h"
12 #include "tunables.h"
13 #include "str.h"
15 int
16 vsf_access_check_file(const struct mystr* p_filename_str)
18 static struct mystr s_access_str;
20 if (!tunable_deny_file)
22 return 1;
24 if (str_isempty(&s_access_str))
26 str_alloc_text(&s_access_str, tunable_deny_file);
28 if (vsf_filename_passes_filter(p_filename_str, &s_access_str))
30 return 0;
32 else
34 struct str_locate_result loc_res =
35 str_locate_str(p_filename_str, &s_access_str);
36 if (loc_res.found)
38 return 0;
41 return 1;
44 int
45 vsf_access_check_file_visible(const struct mystr* p_filename_str)
47 static struct mystr s_access_str;
49 if (!tunable_hide_file)
51 return 1;
53 if (str_isempty(&s_access_str))
55 str_alloc_text(&s_access_str, tunable_hide_file);
57 if (vsf_filename_passes_filter(p_filename_str, &s_access_str))
59 return 0;
61 else
63 struct str_locate_result loc_res =
64 str_locate_str(p_filename_str, &s_access_str);
65 if (loc_res.found)
67 return 0;
70 return 1;