Exemplo n.º 1
0
static __attribute__ ((noreturn)) void allow_init(struct su_context *ctx) {
    if(ctx->init[0]=='!') {
        int ret = init_remove(ctx->init+1, ctx->from.uid);
        if(!ret) {
            fprintf(stderr, "The mentioned init path didn't exist\n");
            exit(1);
        }
        exit(0);
    }
    if(strcmp("--ls", ctx->init) == 0) {
        init_ls(ctx->from.uid);
        exit(0);
    }
    if(!init_uniq(ctx->init))
        //This script is already in init list
        exit(1);

	int fd = open("/data/su/init", O_WRONLY|O_APPEND|O_CREAT, 0600);
	if(fd<0) {
		fprintf(stderr, "Failed to open init file\n");
        exit(1);
	}
    char *str = NULL;
    int len = asprintf(&str, "%d:%s", ctx->from.uid, ctx->init);
    write(fd, str, len+1); //len doesn't include final \0 and we want to write it
    free(str);
	close(fd);
    exit(0);
}
Exemplo n.º 2
0
void init_subsystems(){
 init_cal();
 init_cli_macro();
 init_clipboard();
 init_commandline();
 init_evilloop();
 init_exec_cmd();
 init_expanded();
 init_file();
 init_file_ascii();
 init_file_help();
 init_file_hnb();
 init_file_html();
 init_file_opml();
 init_file_ps();
 init_file_xml();
 init_go();
 init_insertbelow();
 init_keepstate();
 init_mem();
 init_movenode();
 init_nodetest();
 init_outdent_indent();
 init_prefs();
 init_query();
 init_quit();
 init_remove();
 init_search();
 init_sort();
 init_spell();
 init_stats();
 init_tree_todo();
 init_ui_binding();
 init_ui_cli();
 init_ui_draw();
 init_ui_edit();
 init_ui_menu();
 init_ui_overlay();
 init_ui_style();
}