]> andersk Git - moira.git/blobdiff - clients/mailmaint/mailmaint.c
make things depend on libmoira.a, libgdss.a, and rsaref.a as appropriate
[moira.git] / clients / mailmaint / mailmaint.c
index 43a4e305690b367d904025b605f5c820a2e1fefc..5cbedefee1e2446fa7f3f448149a09b25386aa48 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id $
+/* $Id$
  *
  * Simple add-me-to/remove-me-from list client
  *
 #include <moira_site.h>
 
 #include <ctype.h>
+#ifdef HAVE_CURSES
 #include <curses.h>
+#endif
 #include <pwd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
+#include <krb.h>
+
 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:
This page took 0.898728 seconds and 4 git commands to generate.