]>
Commit | Line | Data |
---|---|---|
c740b7f5 AM |
1 | Index: rpm/rpmdb/db3.c |
2 | RCS File: /v/rpm/cvs/rpm/rpmdb/db3.c,v | |
3 | rcsdiff -q -kk '-r1.71' '-r1.72' -u '/v/rpm/cvs/rpm/rpmdb/db3.c,v' 2>/dev/null | |
4 | --- db3.c 2007/08/18 23:40:36 1.71 | |
5 | +++ db3.c 2007/09/24 02:38:57 1.72 | |
6 | @@ -275,12 +275,21 @@ | |
7 | fileSystem @*/ | |
8 | /*@modifies dbi, *dbenvp, fileSystem @*/ | |
9 | { | |
10 | + static int oneshot = 0; | |
11 | rpmdb rpmdb = dbi->dbi_rpmdb; | |
12 | DB_ENV *dbenv = NULL; | |
13 | int eflags; | |
14 | int rc; | |
15 | int xx; | |
16 | ||
17 | + if (!oneshot) { | |
18 | +#if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR != 0) || (DB_VERSION_MAJOR == 4) | |
19 | + xx = db_env_set_func_open(Open); | |
20 | + xx = cvtdberr(dbi, "db_env_set_func_open", xx, _debug); | |
21 | +#endif | |
22 | + oneshot++; | |
23 | + } | |
24 | + | |
25 | if (dbenvp == NULL) | |
26 | return 1; | |
27 | ||
28 | Index: rpm/rpmdb/rpmdb.c | |
29 | RCS File: /v/rpm/cvs/rpm/rpmdb/rpmdb.c,v | |
30 | rcsdiff -q -kk '-r1.158' '-r1.159' -u '/v/rpm/cvs/rpm/rpmdb/rpmdb.c,v' 2>/dev/null | |
31 | --- rpmdb.c 2007/09/09 19:06:51 1.158 | |
32 | +++ rpmdb.c 2007/09/24 02:38:57 1.159 | |
33 | @@ -3618,8 +3618,9 @@ | |
34 | if (db == NULL) return 0; | |
35 | ||
36 | mi = rpmdbInitIterator(db, RPMTAG_BASENAMES, NULL, 0); | |
37 | - if (mi == NULL) /* XXX should never happen */ | |
38 | - return 0; | |
39 | +assert(mi); /* XXX will never happen. */ | |
40 | + if (mi == NULL) | |
41 | + return 2; | |
42 | ||
43 | key = &mi->mi_key; | |
44 | data = &mi->mi_data; | |
45 | Index: rpm/rpmio/librpmio.vers | |
46 | RCS File: /v/rpm/cvs/rpm/rpmio/librpmio.vers,v | |
47 | rcsdiff -q -kk '-r2.12' '-r2.13' -u '/v/rpm/cvs/rpm/rpmio/librpmio.vers,v' 2>/dev/null | |
48 | --- librpmio.vers 2007/09/09 20:32:43 2.12 | |
49 | +++ librpmio.vers 2007/09/24 02:38:57 2.13 | |
50 | @@ -140,6 +140,8 @@ | |
51 | _Mknod; | |
52 | Mount; | |
53 | noLibio; | |
54 | + Open; | |
55 | + _Open; | |
56 | Opendir; | |
57 | _Opendir; | |
58 | pgpArmorKeyTbl; | |
59 | Index: rpm/rpmio/rpmio.h | |
60 | RCS File: /v/rpm/cvs/rpm/rpmio/rpmio.h,v | |
61 | rcsdiff -q -kk '-r1.57' '-r1.58' -u '/v/rpm/cvs/rpm/rpmio/rpmio.h,v' 2>/dev/null | |
62 | --- rpmio.h 2007/08/28 20:45:49 1.57 | |
63 | +++ rpmio.h 2007/09/24 02:38:57 1.58 | |
64 | @@ -342,11 +342,22 @@ | |
65 | /*@globals errno, h_errno, fileSystem, internalState @*/ | |
66 | /*@modifies errno, fileSystem, internalState @*/; | |
67 | ||
68 | +/*@unchecked@*/ /*@observer@*/ /*@null@*/ | |
69 | +extern const char * _chroot_prefix; | |
70 | + | |
71 | /** | |
72 | * chroot(2) clone. | |
73 | * @todo Implement remotely. | |
74 | */ | |
75 | int Chroot(const char * path) | |
76 | + /*@globals _chroot_prefix, errno, fileSystem, internalState @*/ | |
77 | + /*@modifies _chroot_prefix, errno, fileSystem, internalState @*/; | |
78 | + | |
79 | +/** | |
80 | + * open(2) clone. | |
81 | + * @todo Implement remotely. | |
82 | + */ | |
83 | +int Open(const char * path, int flags, mode_t mode) | |
84 | /*@globals errno, fileSystem, internalState @*/ | |
85 | /*@modifies errno, fileSystem, internalState @*/; | |
86 | ||
87 | Index: rpm/rpmio/rpmrpc.c | |
88 | RCS File: /v/rpm/cvs/rpm/rpmio/rpmrpc.c,v | |
89 | rcsdiff -q -kk '-r2.54' '-r2.55' -u '/v/rpm/cvs/rpm/rpmio/rpmrpc.c,v' 2>/dev/null | |
90 | --- rpmrpc.c 2007/07/10 18:00:30 2.54 | |
91 | +++ rpmrpc.c 2007/09/24 02:38:57 2.55 | |
92 | @@ -160,6 +160,9 @@ | |
93 | return rmdir(path); | |
94 | } | |
95 | ||
96 | +/*@unchecked@*/ | |
97 | +const char * _chroot_prefix = NULL; | |
98 | + | |
99 | int Chroot(const char * path) | |
100 | { | |
101 | const char * lpath; | |
102 | @@ -183,11 +186,56 @@ | |
103 | return -2; | |
104 | /*@notreached@*/ break; | |
105 | } | |
106 | + | |
107 | + _chroot_prefix = _free(_chroot_prefix); | |
108 | + if (strcmp(path, ".")) | |
109 | + _chroot_prefix = rpmGetPath(path, NULL); | |
110 | + | |
111 | /*@-superuser@*/ | |
112 | return chroot(path); | |
113 | /*@=superuser@*/ | |
114 | } | |
115 | ||
116 | +int Open(const char * path, int flags, mode_t mode) | |
117 | +{ | |
118 | + const char * lpath; | |
119 | + int ut = urlPath(path, &lpath); | |
120 | + | |
121 | +if (_rpmio_debug) | |
122 | +fprintf(stderr, "*** Open(%s, 0x%x, 0%o)\n", path, flags, mode); | |
123 | + switch (ut) { | |
124 | + case URL_IS_PATH: | |
125 | + path = lpath; | |
126 | + /*@fallthrough@*/ | |
127 | + case URL_IS_UNKNOWN: | |
128 | + break; | |
129 | + case URL_IS_DASH: | |
130 | + case URL_IS_HKP: | |
131 | + case URL_IS_FTP: /* XXX TODO: implement. */ | |
132 | + case URL_IS_HTTPS: /* XXX TODO: implement. */ | |
133 | + case URL_IS_HTTP: /* XXX TODO: implement. */ | |
134 | + default: | |
135 | + errno = EINVAL; /* XXX W2DO? */ | |
136 | + return -2; | |
137 | + /*@notreached@*/ break; | |
138 | + } | |
139 | + | |
140 | + if (_chroot_prefix && _chroot_prefix[0] == '/' && _chroot_prefix[1] != '\0') | |
141 | + { | |
142 | + size_t nb = strlen(_chroot_prefix); | |
143 | + size_t ob = strlen(path); | |
144 | + while (nb > 0 && _chroot_prefix[nb-1] == '/') | |
145 | + nb--; | |
146 | + if (ob > nb && !strncmp(path, _chroot_prefix, nb) && path[nb] == '/') | |
147 | + path += nb; | |
148 | + } | |
149 | +#ifdef NOTYET /* XXX likely sane default. */ | |
150 | + if (mode == 0) | |
151 | + mode = 0644; | |
152 | +#endif | |
153 | + return open(path, flags, mode); | |
154 | +} | |
155 | + | |
156 | /* XXX rpmdb.c: analogue to rename(2). */ | |
157 | ||
158 | int Rename (const char * oldpath, const char * newpath) |