/[baselayout]/trunk/src/librc-misc.c
Gentoo

Diff of /trunk/src/librc-misc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2979 Revision 2980
283 283
284 return (true); 284 return (true);
285} 285}
286librc_hidden_def(rc_rm_dir) 286librc_hidden_def(rc_rm_dir)
287 287
288char **rc_get_config (const char *file) 288char **rc_config_load (const char *file)
289{ 289{
290 char **list = NULL; 290 char **list = NULL;
291 FILE *fp; 291 FILE *fp;
292 char buffer[RC_LINEBUFFER]; 292 char buffer[RC_LINEBUFFER];
293 char *p; 293 char *p;
365 } 365 }
366 fclose (fp); 366 fclose (fp);
367 367
368 return (list); 368 return (list);
369} 369}
370librc_hidden_def(rc_get_config) 370librc_hidden_def(rc_config_load)
371 371
372char *rc_get_config_entry (char **list, const char *entry) 372char *rc_config_value (char **list, const char *entry)
373{ 373{
374 char *line; 374 char *line;
375 int i; 375 int i;
376 char *p; 376 char *p;
377 377
381 return (p += 1); 381 return (p += 1);
382 } 382 }
383 383
384 return (NULL); 384 return (NULL);
385} 385}
386librc_hidden_def(rc_get_config_entry) 386librc_hidden_def(rc_config_value)
387 387
388char **rc_get_list (const char *file) 388char **rc_config_list (const char *file)
389{ 389{
390 FILE *fp; 390 FILE *fp;
391 char buffer[RC_LINEBUFFER]; 391 char buffer[RC_LINEBUFFER];
392 char *p; 392 char *p;
393 char *token; 393 char *token;
415 } 415 }
416 fclose (fp); 416 fclose (fp);
417 417
418 return (list); 418 return (list);
419} 419}
420librc_hidden_def(rc_get_list) 420librc_hidden_def(rc_config_list)
421 421
422char **rc_filter_env (void) 422char **rc_filter_env (void)
423{ 423{
424 char **env = NULL; 424 char **env = NULL;
425 char **whitelist = NULL; 425 char **whitelist = NULL;
433 char *token; 433 char *token;
434 char *sep; 434 char *sep;
435 char *e; 435 char *e;
436 int pplen = strlen (PATH_PREFIX); 436 int pplen = strlen (PATH_PREFIX);
437 437
438 whitelist = rc_get_list (SYS_WHITELIST); 438 whitelist = rc_config_list (SYS_WHITELIST);
439 if (! whitelist) 439 if (! whitelist)
440 fprintf (stderr, "system environment whitelist (" SYS_WHITELIST ") missing\n"); 440 fprintf (stderr, "system environment whitelist (" SYS_WHITELIST ") missing\n");
441 441
442 env = rc_get_list (USR_WHITELIST); 442 env = rc_config_list (USR_WHITELIST);
443 rc_strlist_join (&whitelist, env); 443 rc_strlist_join (&whitelist, env);
444 rc_strlist_free (env); 444 rc_strlist_free (env);
445 env = NULL; 445 env = NULL;
446 446
447 if (! whitelist) 447 if (! whitelist)
448 return (NULL); 448 return (NULL);
449 449
450 if (rc_is_file (PROFILE_ENV)) 450 if (rc_is_file (PROFILE_ENV))
451 profile = rc_get_config (PROFILE_ENV); 451 profile = rc_config_load (PROFILE_ENV);
452 452
453 STRLIST_FOREACH (whitelist, env_name, count) { 453 STRLIST_FOREACH (whitelist, env_name, count) {
454 char *space = strchr (env_name, ' '); 454 char *space = strchr (env_name, ' ');
455 if (space) 455 if (space)
456 *space = 0; 456 *space = 0;
459 459
460 if (! env_var && profile) { 460 if (! env_var && profile) {
461 env_len = strlen (env_name) + strlen ("export ") + 1; 461 env_len = strlen (env_name) + strlen ("export ") + 1;
462 p = rc_xmalloc (sizeof (char *) * env_len); 462 p = rc_xmalloc (sizeof (char *) * env_len);
463 snprintf (p, env_len, "export %s", env_name); 463 snprintf (p, env_len, "export %s", env_name);
464 env_var = rc_get_config_entry (profile, p); 464 env_var = rc_config_value (profile, p);
465 free (p); 465 free (p);
466 } 466 }
467 467
468 if (! env_var) 468 if (! env_var)
469 continue; 469 continue;
571 char *runlevel = rc_runlevel_get (); 571 char *runlevel = rc_runlevel_get ();
572 572
573 /* Don't trust environ for softlevel yet */ 573 /* Don't trust environ for softlevel yet */
574 snprintf (buffer, PATH_MAX, "%s.%s", RC_CONFIG, runlevel); 574 snprintf (buffer, PATH_MAX, "%s.%s", RC_CONFIG, runlevel);
575 if (rc_exists (buffer)) 575 if (rc_exists (buffer))
576 config = rc_get_config (buffer); 576 config = rc_config_load (buffer);
577 else 577 else
578 config = rc_get_config (RC_CONFIG); 578 config = rc_config_load (RC_CONFIG);
579 579
580 STRLIST_FOREACH (config, line, i) { 580 STRLIST_FOREACH (config, line, i) {
581 p = strchr (line, '='); 581 p = strchr (line, '=');
582 if (! p) 582 if (! p)
583 continue; 583 continue;

Legend:
Removed from v.2979  
changed lines
  Added in v.2980

  ViewVC Help
Powered by ViewVC 1.1.20