]> andersk Git - moira.git/blobdiff - gen/passwd.dc
clean up doc directory too
[moira.git] / gen / passwd.dc
index 23a5f03d124cd680ec24e4617d1481dc3111507e..9fcbce2cb5b0fa0afccbc5172a38e61f5ccffe96 100644 (file)
@@ -2,8 +2,13 @@
  *
  * This generates a master /etc/passwd containing all active (status != 0)
  * accounts.
+ *
+ *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
+ *  For copying and distribution information, please see the file
+ *  <mit-copyright.h>.
  */
 
+#include <mit-copyright.h>
 #include <stdio.h>
 #include <sms.h>
 #include <sys/types.h>
@@ -12,6 +17,7 @@
 
 extern int errno;
 char *ingres_date_and_time();
+char *whoami = "passwd.gen";
 
 
 main(argc, argv)
@@ -22,8 +28,11 @@ char **argv;
     char *outf, outft[64];
     struct stat sb;
 ##  char login[9], shell[33], fullname[33], oa[17], op[13], hp[17], *filetime;
+##  char nickname[17];
 ##  int uid, error, flag;
+    int ingerr();
 
+    IIseterr(ingerr);
 ##  ingres sms
 
     if (argc == 2) {
@@ -55,16 +64,18 @@ char **argv;
 ##  range of u is users
 ##  retrieve (login = u.#login, uid = u.#uid, shell = u.#shell,
 ##           fullname = u.#fullname, oa = u.office_addr,
+##           nickname = u.#nickname,
 ##           op = u.office_phone, hp = u.home_phone)
 ##     where u.status = 1 {
-           trim(login);
-           trim(fullname);
-           trim(oa);
-           trim(op);
-           trim(hp);
-           trim(shell);
-           fprintf(out, "%s:*:%d:101:%s,%s,%s,%s:/mit/%s:%s\n",
-                   login, uid, fullname, oa, op, hp, login, shell);
+           strtrim(login);
+           strtrim(fullname);
+           strtrim(nickname);
+           strtrim(oa);
+           strtrim(op);
+           strtrim(hp);
+           strtrim(shell);
+           fprintf(out, "%s:*:%d:101:%s,%s,%s,%s,%s:/mit/%s:%s\n",
+                   login, uid, fullname, nickname, oa, op, hp, login, shell);
 ##  }
 ##  inquire_equel(error = "errorno")
     if (error)  {
@@ -82,3 +93,29 @@ char **argv;
       fix_file(outf);
     exit(SMS_SUCCESS);
 }
+
+
+/*
+ * ingerr: (supposedly) called when Ingres indicates an error.
+ * I have not yet been able to get this to work to intercept a
+ * database open error.
+ */
+#define INGRES_DEADLOCK 4700
+
+static int ingerr(num)
+    int *num;
+{
+    char buf[256];
+    int ingres_errno;
+
+    switch (*num) {
+    case INGRES_DEADLOCK:
+       ingres_errno = SMS_DEADLOCK;
+       break;
+    default:
+       ingres_errno = SMS_INGRES_ERR;
+    }
+    com_err(whoami, SMS_INGRES_ERR, " code %d\n", *num);
+    critical_alert("DCM", "Passwd build encountered INGRES ERROR %d", *num);
+    exit(ingres_errno);
+}
This page took 0.065392 seconds and 4 git commands to generate.