X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/7ac48069b111a991ee5975cb6088c4563b57b670..3fb6166b7fdd6d387cef56076f7aee127cdd6b72:/clients/mailmaint/mailmaint.c diff --git a/clients/mailmaint/mailmaint.c b/clients/mailmaint/mailmaint.c index 43a4e305..5cbedefe 100644 --- a/clients/mailmaint/mailmaint.c +++ b/clients/mailmaint/mailmaint.c @@ -1,4 +1,4 @@ -/* $Id $ +/* $Id$ * * Simple add-me-to/remove-me-from list client * @@ -14,13 +14,17 @@ #include #include +#ifdef HAVE_CURSES #include +#endif #include #include #include #include #include +#include + RCSID("$Header$"); #define STARTCOL 0 @@ -104,8 +108,8 @@ void menu_err_hook(const char *who, long code, const char *fmt, va_list args); int main(int argc, char *argv[]) { void (*old_hook)(const char *, long, const char *, va_list); - int use_menu = 1; - char buf[BUFSIZ], *motd; + int use_menu = 1, k_errno; + char buf[BUFSIZ], pname[ANAME_SZ], *motd; if ((whoami = strrchr(argv[0], '/')) == NULL) whoami = argv[0]; @@ -125,9 +129,15 @@ int main(int argc, char *argv[]) current_li->modby = NULL; current_li->modwith = NULL; } - if (!(username = getlogin())) - username = getpwuid(getuid())->pw_name; - username = username ? strdup(username) : ""; + + if ((k_errno = tf_init(TKT_FILE, R_TKT_FIL)) || + (k_errno = tf_get_pname(pname))) + { + com_err(whoami, k_errno, "reading Kerberos ticket file"); + exit(1); + } + tf_close(); + username = pname; printf("Connecting to database for %s...please hold on.\n", username); @@ -159,33 +169,29 @@ int main(int argc, char *argv[]) goto punt; } - if (use_menu) + initscr(); + if ((LINES < 24) || (COLS < 60)) { - initscr(); - if ((LINES < 24) || (COLS < 60)) - { - display_buff("Display window too small.\n\n"); - sprintf(buf, - "Current window parameters are (%d lines, %d columns)\n", - LINES, COLS); - display_buff(buf); - display_buff("Please resize your window\n"); - display_buff("to at least 24 lines and 60 columns.\n"); - exit(0); - } - raw(); - noecho(); - old_hook = set_com_err_hook(menu_err_hook); - position[0] = oldpos[0] = 1; - level = 0; - pack_main_menu(); - pack_help_menu(); - display_menu(main_menu); - get_main_input(); - cls(); - endwin(); - set_com_err_hook(old_hook); + display_buff("Display window too small.\n\n"); + sprintf(buf, "Current window parameters are (%d lines, %d columns)\n", + LINES, COLS); + display_buff(buf); + display_buff("Please resize your window\n"); + display_buff("to at least 24 lines and 60 columns.\n"); + exit(0); } + raw(); + noecho(); + old_hook = set_com_err_hook(menu_err_hook); + position[0] = oldpos[0] = 1; + level = 0; + pack_main_menu(); + pack_help_menu(); + display_menu(main_menu); + get_main_input(); + cls(); + endwin(); + set_com_err_hook(old_hook); exit(0); punt: