188 * on a regular or a pseudo (called from compat
189 * backend) database. Then set the necessary
190 * parameters for later data structures creation
191 * and processing.
192 */
193 static nscd_rc_t
194 getparams(
195 int search_fnum,
196 nss_db_initf_t initf,
197 nscd_nsw_params_t *params)
198 {
199
200 nscd_rc_t rc = NSCD_SUCCESS;
201 nss_db_params_t *p;
202 int j;
203 char *dbn;
204 const char *n;
205 char *me = "getparams";
206
207 p = ¶ms->p;
208 (void) memset(p, 0, sizeof (*p));
209 (*initf)(p);
210 params->dbi = -1;
211 params->cfgdbi = -1;
212 params->compati = -1;
213 params->dnsi = -1;
214
215 /* map database name to index */
216 n = p->name;
217 for (j = 0; j < NSCD_NUM_DB; j++) {
218 dbn = NSCD_NSW_DB_NAME(j);
219 if (*n != *dbn)
220 continue;
221 if (strcmp(n, dbn) == 0) {
222 params->dbi = j;
223 if (*n != 'h' && *n != 'i' && *n != 's' && *n != 'a')
224 break;
225 if (strcmp(n, NSS_DBNAM_HOSTS) == 0 &&
226 search_fnum == NSS_DBOP_HOSTS_BYNAME)
227 params->dnsi = 0;
228 else if (strcmp(n, NSS_DBNAM_IPNODES) == 0 &&
229 search_fnum == NSS_DBOP_IPNODES_BYNAME)
230 params->dnsi = 1;
231 else if (strcmp(n, NSS_DBNAM_SHADOW) == 0)
232 params->privdb = 1;
233 break;
234 }
235 }
236
237 /*
238 * use the switch policy for passwd_compat or
239 * group_compat?
240 */
241 if (p->config_name != NULL) {
242
243 n = p->config_name;
244 for (j = 0; j < NSCD_NUM_DB; j++) {
245 dbn = NSCD_NSW_DB_NAME(j);
246 if (*n == *dbn) {
247 if (strcmp(n, dbn) == 0) {
248 params->cfgdbi = j;
249 break;
250 }
251 }
252 }
253 }
254
255 /* map the database name to the pseudo database index */
256 if (params->cfgdbi != -1) {
257 if (strstr(p->config_name, "_compat") != NULL) {
258 n = p->name;
259 for (j = params->cfgdbi; j < NSCD_NUM_DB; j++) {
260 dbn = NSCD_NSW_DB_NAME(j);
261 if (*n == *dbn) {
262 if (strcmp(n, dbn) == 0) {
|
188 * on a regular or a pseudo (called from compat
189 * backend) database. Then set the necessary
190 * parameters for later data structures creation
191 * and processing.
192 */
193 static nscd_rc_t
194 getparams(
195 int search_fnum,
196 nss_db_initf_t initf,
197 nscd_nsw_params_t *params)
198 {
199
200 nscd_rc_t rc = NSCD_SUCCESS;
201 nss_db_params_t *p;
202 int j;
203 char *dbn;
204 const char *n;
205 char *me = "getparams";
206
207 p = ¶ms->p;
208 (void) memset(params, 0, sizeof (nscd_nsw_params_t));
209 (*initf)(p);
210 params->dbi = -1;
211 params->cfgdbi = -1;
212 params->compati = -1;
213 params->dnsi = -1;
214
215 /* map database name to index */
216 n = p->name;
217 for (j = 0; j < NSCD_NUM_DB; j++) {
218 dbn = NSCD_NSW_DB_NAME(j);
219 if (*n != *dbn)
220 continue;
221 if (strcmp(n, dbn) == 0) {
222 params->dbi = j;
223 if (*n != 'h' && *n != 'i' && *n != 's' && *n != 'a')
224 break;
225 if (strcmp(n, NSS_DBNAM_HOSTS) == 0 &&
226 search_fnum == NSS_DBOP_HOSTS_BYNAME)
227 params->dnsi = 0;
228 else if (strcmp(n, NSS_DBNAM_IPNODES) == 0 &&
229 search_fnum == NSS_DBOP_IPNODES_BYNAME)
230 params->dnsi = 1;
231 else if (strcmp(n, NSS_DBNAM_SHADOW) == 0)
232 params->privdb = 1;
233 break;
234 }
235 }
236
237 /*
238 * use the switch policy for passwd_compat or
239 * group_compat?
240 */
241 if (p->config_name != NULL) {
242 n = p->config_name;
243 for (j = 0; j < NSCD_NUM_DB; j++) {
244 dbn = NSCD_NSW_DB_NAME(j);
245 if (*n == *dbn) {
246 if (strcmp(n, dbn) == 0) {
247 params->cfgdbi = j;
248 break;
249 }
250 }
251 }
252 }
253
254 /* map the database name to the pseudo database index */
255 if (params->cfgdbi != -1) {
256 if (strstr(p->config_name, "_compat") != NULL) {
257 n = p->name;
258 for (j = params->cfgdbi; j < NSCD_NUM_DB; j++) {
259 dbn = NSCD_NSW_DB_NAME(j);
260 if (*n == *dbn) {
261 if (strcmp(n, dbn) == 0) {
|