Ejemplo n.º 1
0
int mod_load_manually(int type)
{
  int i, ok;
  char *s;
  char **items;
  module_t **mod_items;
  int added = 0;

  mod_auto_detect();

  i = mod_build_list(type, &items, &mod_items);

  if(!i || (i == 1 && !*mod_items)) {
    return 0;	/* no new modules */
  }

  if(!i || (i == 1 && !*mod_items)) return 0;

  if(i) {
    s = mod_get_title(type);
    i = dia_list(s, MENU_WIDTH, NULL, items, 1, align_left);

    if(i--) {
      if(mod_items[i]) {
        ok = 1;
        if(mod_items[i]->pre_inst) {
          ok = mod_load_modules(mod_items[i]->pre_inst, 1);
        }
        if(ok) ok = mod_load_modules(mod_items[i]->name, 2);
        if(ok && mod_items[i]->post_inst) {
          ok = mod_load_modules(mod_items[i]->post_inst, 1);
        }
      }
      else {
        added = 0;
      }
    }

    free(s);
  }

  return added;
}
Ejemplo n.º 2
0
int mod_modprobe(char *module, char *param)
{
  int err;
  module_t *ml;

  if(!module) return -1;

  ml = mod_get_entry(module);

  if(!ml) return mod_insmod(module, param);

  err = 0;
  if(ml->pre_inst) {
    err = !mod_load_modules(ml->pre_inst, 0);
  }
  if(!err) err = mod_insmod(ml->name, param);
  if(!err && ml->post_inst) {
    err = mod_load_modules(ml->post_inst, 0);
  }

  return err;
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
    opt_t opt;
    int retval = 0;
    const char *m;


    /*
     * Initialize.
     */
    err_init(xbasename(argv[0]));       /* init err package */

    /*
     *  If running setuid, fork a child to handle 
     *   all privileged operations and drop privs in this process.
     */
    privsep_init();

    /*
     * Seed options with default values:
     */
    opt_default(&opt, argv[0]);

    /*
     * Override defaults with environment
     */
    opt_env(&opt);

    /*
     * Process any options that need to be handled early:
     */
    opt_args_early(&opt, argc, argv);

    /*
     *  Load static or dynamic pdsh modules
     */
    mod_init();
    /*
     *  Allow module directory to be overridden, but not when
     *   running as root or setuid. (This is mainly for testing...)
     */
    if (!(m = getenv ("PDSH_MODULE_DIR")) ||
          getuid() == 0 ||
          getuid() != geteuid())
        m = pdsh_module_dir;
    if (mod_load_modules(m, &opt) < 0)
        errx("%p: Couldn't load any pdsh modules\n");

    /*
     * Handle options.
     */
    opt_args(&opt, argc, argv); /* override with command line           */

    if (opt_verify(&opt)) {     /* verify options, print errors         */
        /*
         * Do the work.
         */
        if (opt.info_only)      /* display info only */
            opt_list(&opt);
        else if (pdsh_personality() == PCP && opt.pcp_server) 
            retval = (_pcp_remote_server (&opt) < 0);
        else if (pdsh_personality() == PCP && opt.pcp_client)
            retval = (_pcp_remote_client (&opt) < 0);
        else if (pdsh_personality() == PCP || opt.cmd != NULL)
            retval = dsh(&opt); /* single dsh/pcp command */
        else                    /* prompt loop */
            _interactive_dsh(&opt);
    } else {
        retval = 1;
    }

    mod_exit(); 

    /*
     * Clean up.
     */
    privsep_fini();
    opt_free(&opt);             /* free heap storage in opt struct */
    err_cleanup();

    return retval;
}