Open SCAP Library
Loading...
Searching...
No Matches
oval_fts.h
1/*
2 * Copyright 2010 Red Hat Inc., Durham, North Carolina.
3 * All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Authors:
20 * "Daniel Kopecek" <dkopecek@redhat.com>
21 */
22#ifndef OVAL_FTS_H
23#define OVAL_FTS_H
24
25#include "oscap_platforms.h"
26
27#include <sexp.h>
28#if defined(OS_SOLARIS) || defined(OS_AIX)
29#include "fts_sun.h"
30#else
31#include <fts.h>
32#endif
33#include "fsdev.h"
34#include "common/oscap_pcre.h"
35
36#define ENT_GET_AREF(ent, dst, attr_name, mandatory) \
37 do { \
38 if (((dst) = probe_ent_getattrval(ent, attr_name)) == NULL) { \
39 if (mandatory) { \
40 _F("Attribute `%s' is missing!\n", attr_name); \
41 return (NULL); \
42 } \
43 } \
44 } while(0)
45
46#define ENT_GET_STRVAL(ent, dst, dstlen, zerolen_exp) \
47 do { \
48 SEXP_t *___r; \
49 \
50 if ((___r = probe_ent_getval(ent)) == NULL) { \
51 dW("entity has no value!"); \
52 return (NULL); \
53 } else { \
54 if (!SEXP_stringp(___r)) { \
55 _F("invalid type\n"); \
56 SEXP_free(___r); \
57 return (NULL); \
58 } \
59 if (SEXP_string_length(___r) == 0) { \
60 SEXP_free(___r); \
61 zerolen_exp; \
62 } else { \
63 SEXP_string_cstr_r(___r, dst, dstlen); \
64 SEXP_free(___r); \
65 } \
66 } \
67 } while (0)
68
69typedef struct {
70 /* oval_fts_read_match_path() state */
71 FTS *ofts_match_path_fts;
72 FTSENT *ofts_match_path_fts_ent;
73 /* oval_fts_read_recurse_path() state */
74 FTS *ofts_recurse_path_fts;
75 int ofts_recurse_path_fts_opts;
76 int ofts_recurse_path_curdepth;
77 char *ofts_recurse_path_pthcpy;
78 char *ofts_recurse_path_curpth;
79 dev_t ofts_recurse_path_devid;
80
81 oscap_pcre_t *ofts_path_regex;
82 uint32_t ofts_path_op;
83
84 SEXP_t *ofts_spath;
85 SEXP_t *ofts_sfilename;
86 SEXP_t *ofts_sfilepath;
87 SEXP_t *result;
88
89 int max_depth;
90 int direction;
91 int recurse;
92 int filesystem;
93 int following;
94
95 fsdev_t *localdevs;
96 const char *prefix;
97} OVAL_FTS;
98
99#define OVAL_RECURSE_DIRECTION_NONE 0 /* default */
100#define OVAL_RECURSE_DIRECTION_DOWN 1
101#define OVAL_RECURSE_DIRECTION_UP 2
102
103#define OVAL_RECURSE_FILES 0x01
104#define OVAL_RECURSE_DIRS 0x02
105#define OVAL_RECURSE_SYMLINKS 0x04
106
107#define OVAL_RECURSE_SYMLINKS_AND_DIRS (OVAL_RECURSE_SYMLINKS|OVAL_RECURSE_DIRS) /* default */
108#define OVAL_RECURSE_FILES_AND_DIRS (OVAL_RECURSE_FILES|OVAL_RECURSE_SYMLINKS)
109
110#define OVAL_RECURSE_FS_LOCAL 0
111#define OVAL_RECURSE_FS_DEFINED 1
112#define OVAL_RECURSE_FS_ALL 2 /* default */
113
114typedef struct {
115 char *file;
116 size_t file_len;
117 char *path;
118 size_t path_len;
119 unsigned int fts_info;
121
122/*
123 * OVAL FTS public API
124 */
125OVAL_FTS *oval_fts_open_prefixed(const char *prefix, SEXP_t *path, SEXP_t *filename, SEXP_t *filepath, SEXP_t *behaviors, SEXP_t* result);
126OVAL_FTS *oval_fts_open(SEXP_t *path, SEXP_t *filename, SEXP_t *filepath, SEXP_t *behaviors, SEXP_t* result);
127OVAL_FTSENT *oval_fts_read(OVAL_FTS *ofts);
128int oval_fts_close(OVAL_FTS *ofts);
129
130void oval_ftsent_free(OVAL_FTSENT *ofts_ent);
131
132#endif /* OVAL_FTS_H */
fsdev header file
Definition fts_sun.h:84
Definition oval_fts.h:114
Definition oval_fts.h:69
Definition sexp-types.h:82
Definition fts_sun.h:132
Filesystem device structure.
Definition fsdev.h:45
Definition oscap_pcre.c:40