void hub_plugins_load(struct hub_info* hub) { if (!hub->config->file_plugins || !*hub->config->file_plugins) return; hub->plugins = hub_malloc_zero(sizeof(struct uhub_plugins)); if (!hub->plugins) return; if (plugin_initialize(hub->config, hub->plugins) < 0) { hub_free(hub->plugins); hub->plugins = 0; return; } }
int main() { int argc, i, j, k; lcmaps_argument_t *args = NULL; char *init_argv[] = {"posix_enf", "-maxuid", "1", "-maxpgid", "1", "-maxsgid", "32"}; if (lcmaps_log_open(NULL,stdout,DO_USRLOG)) return 1; lcmaps_log_debug(0,"\n"); lcmaps_log(LOG_NOTICE,"Initialization POSIX Enforcement\n"); if (plugin_initialize(7, init_argv) == LCMAPS_MOD_FAIL) { lcmaps_log(2, "Error on execution: plugin_initialize\n"); return LCMAPS_MOD_FAIL; } lcmaps_log(LOG_NOTICE, "IntroSpect POSIX Enfocement\n"); if (plugin_introspect(&argc, &args) == LCMAPS_MOD_FAIL) { lcmaps_log(2, "Error on execution: plugin_introspect\n"); return LCMAPS_MOD_FAIL; } /* * Adding Test Credential Data */ i = 505; addCredentialData(UID, &i); j = 500; addCredentialData(PRI_GID, &j); k = 30; addCredentialData(SEC_GID, &k); k = 40; addCredentialData(SEC_GID, &k); k = 50; lcmaps_log(LOG_NOTICE, "Run POSIX Enforcement\n"); if (plugin_run(argc,args) == LCMAPS_MOD_FAIL) { lcmaps_log(2, "Error on execution: plugin_run\n"); return LCMAPS_MOD_FAIL; } if (cleanCredentialData()!=0) { lcmaps_log(0,"lcmaps.mod-stopPluginManager() error: could not clean credential data list\n"); return LCMAPS_MOD_FAIL; } lcmaps_log(LOG_NOTICE, "Terminate POSIX Enforcement\n"); if (plugin_terminate() == LCMAPS_MOD_FAIL) { lcmaps_log(2, "Error on execution: plugin_terminate\n"); return LCMAPS_MOD_FAIL; } return 0; }
/* * Sync Flow */ static osync_bool run_command(Command *cmd, void **plugin_data, OSyncError **error) { assert(cmd); if (cmd->cmd != CMD_INITIALIZE && *plugin_data == NULL) { fprintf(stderr, "WARNING: Got Plugin initialized? plugin_data is NULL.\n"); goto error; } switch (cmd->cmd) { case CMD_EMPTY: if (!empty(cmd, error)) goto error; break; case CMD_INITIALIZE: if (!(*plugin_data = plugin_initialize(error))) goto error; break; case CMD_FINALIZE: finalize_plugin(plugin_data); break; case CMD_CONNECT: if (!connect_plugin(cmd, error)) goto error; break; case CMD_DISCONNECT: if (!disconnect(cmd, error)) goto error; break; case CMD_SLOWSYNC: if (!get_changes(cmd, SYNCTYPE_FORCE_SLOWSYNC, error)) goto error; break; case CMD_FASTSYNC: if (!get_changes(cmd, SYNCTYPE_FORCE_FASTSYNC, error)) goto error; break; case CMD_SYNC: if (!get_changes(cmd, SYNCTYPE_NORMAL, error)) goto error; break; case CMD_COMMIT: fprintf(stderr, "COMMIT not yet implemented\n"); break; case CMD_COMMITTEDALL: if (!committedall(cmd, error)) goto error; break; case CMD_READ: fprintf(stderr, "READ not yet implemented\n"); break; case CMD_WRITE: fprintf(stderr, "WRITE not yet implemented\n"); break; case CMD_SYNCDONE: if (!syncdone(cmd, error)) goto error; break; case CMD_DISCOVER: fprintf(stderr, "DISCOVER not yet implemented\n"); break; } printf("%s: %u - sink: %p\n", __func__, cmd->cmd, cmd->sink); switch (cmd->cmd) { case CMD_INITIALIZE: case CMD_FINALIZE: case CMD_DISCOVER: break; case CMD_EMPTY: case CMD_CONNECT: case CMD_DISCONNECT: case CMD_SLOWSYNC: case CMD_FASTSYNC: case CMD_SYNC: case CMD_COMMIT: case CMD_COMMITTEDALL: case CMD_READ: case CMD_WRITE: case CMD_SYNCDONE: printf("waiting .....\n"); if (!cmd->done) g_cond_wait(cmd->cond, cmd->mutex); printf("DONE\n"); break; } return TRUE; error: return FALSE; }