void test_auth(void) { int status; status = mr_auth("mrtest"); if (status) com_err("moira (auth)", status, ""); }
int main(int argc, char **argv) { int status; Menu *menu; char *motd, **arg; struct sigaction act; if (!(program_name = strrchr(argv[0], '/'))) program_name = argv[0]; else program_name++; program_name = strdup(program_name); whoami = strdup(program_name); /* used by menu.c, ugh !!! */ user = mrcl_krb_user(); if (!user) exit(1); verbose = TRUE; arg = argv; moira_server = NULL; while (++arg - argv < argc) { if (**arg == '-') { if (!strcmp(*arg, "-nomenu")) { #ifdef HAVE_CURSES use_menu = FALSE; #else ; #endif } else if (!strcmp(*arg, "-menu")) { #ifdef HAVE_CURSES use_menu = TRUE; #else fprintf(stderr, "%s: No curses support. -menu option ignored\n", whoami); #endif } else if (!strcmp(*arg, "-db")) if (arg - argv < argc - 1) { ++arg; moira_server = *arg; } else Usage(); else Usage(); } } if (mrcl_connect(moira_server, program_name, QUERY_VERSION, 0) != MRCL_SUCCESS) exit(1); if ((status = mr_krb5_auth(program_name))) { if (status == MR_UNKNOWN_PROC) status = mr_auth(program_name); if (status) { if (status == MR_USER_AUTH) { char buf[BUFSIZ]; com_err(program_name, status, "\nPress [RETURN] to continue"); fgets(buf, BUFSIZ, stdin); } else ErrorExit("\nAuthorization failed -- please run kinit", status); } } /* * These signals should not be set until just before we fire up the menu * system. */ sigemptyset(&act.sa_mask); act.sa_flags = 0; act.sa_handler = Signal_Handler; sigaction(SIGHUP, &act, NULL); sigaction(SIGQUIT, &act, NULL); #ifdef HAVE_CURSES if (use_menu) sigaction(SIGINT, &act, NULL); else #endif { act.sa_handler = CatchInterrupt; sigaction(SIGINT, &act, NULL); } menu = &namespace_menu; #ifdef HAVE_CURSES if (use_menu) /* Start menus that execute program */ { Start_paging(); Start_menu(menu); Stop_paging(); } else /* Start program without menus. */ #endif Start_no_menu(menu); mr_disconnect(); exit(0); }