]> andersk Git - moira.git/blobdiff - gen/nfs.qc
close file descriptors before exec'ing the dcm
[moira.git] / gen / nfs.qc
index 7e6297b892423823254c01ea75251b6dc3cf0b4d..61516dbdf92483ce397acbdf30dddfb39102f38e 100644 (file)
@@ -1,8 +1,13 @@
 /* $Header$
  *
  * This generates the files necessary to load an nfs server.
+ *
+ *  (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 <sms_app.h>
 
 #define min(x,y)       ((x) < (y) ? (x) : (y))
 
-struct np {
-    char mach[33];
-    char dev[33];
-    char list[33];
-};
-
-struct fs {
-    int nfsphys;
-    char *dir;
-    int owner;
-    int owners;
-    struct qt *quota;
-};
-
-
 char *whoami = "nfs.gen";
 char *malloc(), *strsave();
 char *ingres_date_and_time(), *ingres_time(), *ingres_date();
@@ -125,7 +115,7 @@ int do_nfs()
 int do_lists(lists)
 struct save_queue *lists;
 ##{
-    struct save_queue *sq;
+    struct save_queue *sq, *members;
     char file[64], *u;
     struct hash *users, *do_everyone();
     struct stat sb;
@@ -172,19 +162,24 @@ struct save_queue *lists;
        }
        sq = sq_create();
        sq_save_data(sq, listname);
+       members = sq_create();
        while (sq_get_data(sq, &lsname)) {
 ##         repeat retrieve (lname = trim(l.name))
 ##             where m.list_id = l1.list_id and l1.name = @lsname and
 ##                   m.member_type = "LIST" and m.member_id = l.list_id {
-             sq_save_unique_string(sq, lname);
+             sq_save_unique_string(sq, strsave(lname));
 ##         }
 ##         repeat retrieve (id = m.member_id)
 ##             where m.list_id = l1.list_id and l1.name = @lsname and
 ##                   m.member_type = "USER" {
-             if (u = hash_lookup(users, id)) 
-               fprintf(fd, "%s\n", u);
+             if (u = hash_lookup(users, id)) {
+                 sq_save_unique_data(members, u);
+             }
 ##         }
        }
+       while (sq_get_data(members, &lsname))
+         fprintf(fd, "%s\n", lsname);
+       sq_destroy(members);
        sq_destroy(sq);
        if (fclose(fd)) {
            fprintf(stderr, "error closing %s\n", file);
This page took 0.033453 seconds and 4 git commands to generate.