1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
#ifndef _RPMCHK_H
#define _RPMCHK_H
#include <inttypes.h>
#include <sys/types.h>
#include <netinet/in.h>
struct tetj_handle;
/*
* RPM file Lead
*/
typedef struct rpmlead {
unsigned char magic[4];
unsigned char major, minor;
uint16_t type;
uint16_t archnum;
char name[66];
uint16_t osnum;
uint16_t signature_type;
char reserved[16];
} RpmLead;
#define RPMMAG "\355\253\356\333"
#define SRPMMAG 4
#define RPMFILEVERMAJ 0x03
#define RPMFILEVERMIN 0x00
#define RPMBINPKG 0x0000
#define RPMSRCPKG 0x0001
#if defined(__i386__)
#define RPMARCH 0x0001
#endif
#if defined(__ia64__)
#define RPMARCH 0x0009
#endif
#define RPMOS 0x0001 /* Linux */
#define RPMSIGTYPE 0x0005
typedef struct rpmheader {
unsigned char magic[3];
unsigned char version;
char reserved[4];
uint32_t nindex;
uint32_t hsize;
} RpmHeader;
#define RPMHDRMAG "\216\255\350"
#define SRPMHDRMAG 3
#define RPMHDRVER 1
/*
* Each Index has a type associated with it. These are the types which
* may be used.
*/
typedef enum {
NULL_TYPE=0,
CHAR=1,
INT8=2,
INT16=3,
INT32=4,
INT64=5,
STRING=6,
BIN=7,
STRING_ARRAY=8,
I18NSTRING=9
} RpmIndexType;
#include "rpmtag.h"
typedef struct rpmhdrindex {
uint32_t tag;
uint32_t type;
uint32_t offset;
uint32_t count;
} RpmHdrIndex;
/*
* Require Flags.
*/
typedef enum {
RPMSENSE_LESS = (1 << 1),
RPMSENSE_GREATER= (1 << 2),
RPMSENSE_EQUAL = (1 << 3),
RPMSENSE_PREREQ = (1 << 6),
RPMSENSE_INTERP = (1 << 8),
RPMSENSE_SCRIPT_PRE = (1 << 9),
RPMSENSE_SCRIPT_POST = (1 << 10),
RPMSENSE_SCRIPT_PREUN = (1 << 11),
RPMSENSE_SCRIPT_POSTUN = (1 << 12),
RPMSENSE_RPMLIB = (1 << 24), /* rpmlib(feature) dependency. */
} rpmRequireFlags;
/*
* An in memory representation of the RPM file.
*/
typedef struct {
int fd;
caddr_t addr; /* Start address of the file */
int size;
RpmLead *laddr;
RpmHeader *signature;
RpmHeader *header;
RpmHeader *nexthdr;
caddr_t storeaddr; /* Start store for the current header */
caddr_t archive;
} RpmFile;
/* RPM Index things */
typedef void (*IdxTagFunc)(RpmFile *, RpmHdrIndex *, struct tetj_handle *);
typedef enum { Required, Optional } RpmIdxReqd ;
typedef enum { NotSeen, Seen } RpmIdxStatus ;
typedef struct {
RpmIndexTag tag;
char *name;
RpmIndexType type;
int count;
IdxTagFunc func;
RpmIdxReqd reqd;
RpmIdxStatus status;
} RpmIdxTagFuncRec;
extern RpmIdxTagFuncRec SigTags[];
extern int numSigIdxTags;
extern RpmIdxTagFuncRec HdrTags[];
extern int numHdrIdxTags;
/*
* Archive format -
* really cpio, but it doesn't actually match the cpio definition ?!?!?!
*/
typedef struct {
char c_magic[6];
char c_ino[8];
char c_mode[8];
char c_uid[8];
char c_gid[8];
char c_nlink[8];
char c_mtime[8];
char c_filesize[8];
char c_devmajor[8];
char c_devminor[8];
char c_rdevmajor[8];
char c_rdevminor[8];
char c_namesize[8];
char c_checksum[8];
} RpmArchiveHeader;
/*
* Debugging interface: Set the environment variable RPMCHK_DEBUG to a value
* that corresponds to the bits defined below.
*/
#define DEBUG_ENV_OVERRIDES 0x0001
#define DEBUG_TRACE_TAGS 0x0002
#define DEBUG_TRACE_CONTENTS 0x0004
extern int rpmchkdebug;
/* vals.c */
extern char *architecture;
extern char *validos;
extern char *validdepver;
extern char *pkgname;
extern unsigned char *sigdata;
extern int lsbdepidx;
extern uint32_t sigsize;
extern uint32_t archivesize;
extern uint32_t rpmtagsize;
extern uint32_t *filesizes;
extern uint16_t *filemodes;
extern uint32_t *filedevs;
extern uint16_t *filerdevs;
extern uint32_t *fileinodes;
extern uint32_t *filetimes;
extern char *filemd5s;
extern char *filelinktos;
extern char *fileusernames;
extern char *filegroupnames;
extern char *filelangs;
extern uint32_t *dirindicies;
extern char **basenames;
extern char **dirnames;
extern int numdirnames;
extern int hasPayloadFilesHavePrefix;
/* util.c */
extern RpmFile *OpenRpmFile(char *name);
extern void checkRpm(RpmFile *file1, struct tetj_handle *journal);
extern void checkRpmLead(RpmFile *file1, struct tetj_handle *journal);
extern void checkRpmHeader(RpmFile *file1, struct tetj_handle *journal);
/* fhs.c */
extern void checkRpmArchiveFilename(char *filename, struct tetj_handle *journal);
/* archive.c */
void checkRpmArchive(RpmFile *file1, struct tetj_handle *journal);
/* hdr.c */
void checkRpmHdr(RpmFile *file1, struct tetj_handle *journal);
void checkRpmSignature(RpmFile *file1, struct tetj_handle *journal);
void checkRpmHeader(RpmFile *file1, struct tetj_handle *journal);
#endif /* _RPMCHK_H */
|