[1815] in Moira Commits
/svn/moira r3962 - trunk/moira/gen
daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Thu Jan 7 02:06:23 2010
Date: Thu, 7 Jan 2010 02:06:20 -0500
From: Garry Zacheiss <zacheiss@MIT.EDU>
Message-Id: <201001070706.o0776Kn9010081@drugstore.mit.edu>
To: moira-commits@mit.edu
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Author: zacheiss
Date: 2010-01-07 02:06:20 -0500 (Thu, 07 Jan 2010)
New Revision: 3962
Modified:
trunk/moira/gen/cups-cluster.pc
trunk/moira/gen/cups-print.pc
trunk/moira/gen/mailhub.pc
Log:
Expand all lists completely, including owner-foo aliases.
Modified: trunk/moira/gen/cups-cluster.pc
===================================================================
--- trunk/moira/gen/cups-cluster.pc 2010-01-06 18:20:31 UTC (rev 3961)
+++ trunk/moira/gen/cups-cluster.pc 2010-01-07 07:06:20 UTC (rev 3962)
@@ -53,7 +53,6 @@
const char *canceljob = "<Limit Cancel-Job>";
const char *catchall = "<Limit All>";
const char *phost = "cluster-printers.MIT.EDU";
-const char *svrlist = "cups-hosts";
void do_host(char *host);
void sqlerr(void);
@@ -595,7 +594,6 @@
fprintf (out, "AuthType Default\n");
fprintf (out, "Require user @OWNER @SYSTEM\n");
printer_user_list(out, "LIST", lpc_acl, "Require user", 1);
- printer_user_list(out, "LIST", svrlist, "Require user", 1);
fprintf (out, "Order deny,allow\n");
fprintf (out, "Allow from all\n");
fprintf (out, "</Limit>\n");
@@ -612,10 +610,8 @@
else
fprintf (out, "AuthType None\n");
/* Access-control list. */
- if (ac) {
+ if (ac)
printer_user_list(out, "LIST", ac, "Require user", 1);
- printer_user_list(out, "LIST", svrlist, "Require user", 1);
- }
else if (ka)
fprintf (out, "Require valid-user\n");
fprintf (out, "Order deny,allow\n");
Modified: trunk/moira/gen/cups-print.pc
===================================================================
--- trunk/moira/gen/cups-print.pc 2010-01-06 18:20:31 UTC (rev 3961)
+++ trunk/moira/gen/cups-print.pc 2010-01-07 07:06:20 UTC (rev 3962)
@@ -53,7 +53,6 @@
const char *canceljob = "<Limit Cancel-Job>";
const char *catchall = "<Limit All>";
const char *phost = "printers.MIT.EDU";
-const char *svrlist = "cups-servers";
void do_host(char *host);
void sqlerr(void);
@@ -133,7 +132,7 @@
char service[SERVERHOSTS_SERVICE_SIZE];
char *spoolhost = host, *unixtime_fmt = UNIXTIME_FMT, *p;
char *lhost;
- int ka, pc, ac, lpc_acl, top_lpc_acl, banner, rm, svrlist_id;
+ int ka, pc, ac, lpc_acl, top_lpc_acl, banner, rm;
EXEC SQL END DECLARE SECTION;
TARFILE *tf;
FILE *out;
@@ -531,10 +530,6 @@
FROM printservers ps, machine m
WHERE m.name = :spoolhost AND m.mach_id = ps.mach_id;
- /* svrlist */
- EXEC SQL SELECT list_id INTO :svrlist_id
- FROM list l WHERE l.name = :svrlist;
-
/* first, what's our defaults? */
fprintf (out, "<Policy default>\n");
fprintf (out, "%s\n", alterjob);
@@ -602,7 +597,6 @@
fprintf (out, "AuthType Default\n");
fprintf (out, "Require user @OWNER @SYSTEM\n");
printer_user_list(out, "LIST", lpc_acl, "Require user", 1);
- printer_user_list(out, "LIST", svrlist_id, "Require user", 1);
fprintf (out, "Order deny,allow\n");
fprintf (out, "Allow from all\n");
fprintf (out, "</Limit>\n");
@@ -619,10 +613,8 @@
else
fprintf (out, "AuthType None\n");
/* Access-control list. */
- if (ac) {
+ if (ac)
printer_user_list(out, "LIST", ac, "Require user", 1);
- printer_user_list(out, "LIST", svrlist_id, "Require user", 1);
- }
else if (ka)
fprintf (out, "Require valid-user\n");
fprintf (out, "Order deny,allow\n");
Modified: trunk/moira/gen/mailhub.pc
===================================================================
--- trunk/moira/gen/mailhub.pc 2010-01-06 18:20:31 UTC (rev 3961)
+++ trunk/moira/gen/mailhub.pc 2010-01-07 07:06:20 UTC (rev 3962)
@@ -35,8 +35,6 @@
#define FALSE 0
#define TRUE (!FALSE)
-FILE *out;
-
struct hash *users, *machines, *strings, *lists;
struct user {
char *login;
@@ -59,10 +57,10 @@
};
void get_info(void);
-void save_mlist(int id, void *list, void *force);
int check_string(char *s);
void output_login(int dummy, void *names, void *out);
-void output_mlist(int id, struct list *l);
+void output_mlist(int id, void *list, void *out);
+void output_membership(struct list *l, FILE *out);
void put_fill(FILE *aliases, char *string);
void do_people(void);
@@ -72,9 +70,11 @@
{
time_t tm = time(NULL);
char filename[MAXPATHLEN], *targetfile;
+ FILE *out;
out = stdout;
+ srand(tm);
EXEC SQL CONNECT :db;
if (argc == 2)
@@ -103,7 +103,7 @@
incount = 0;
fprintf(out, "\n%s\n# Mailing lists\n%s\n\n", divide, divide);
- hash_step(lists, save_mlist, FALSE);
+ hash_step(lists, output_mlist, out);
fprintf(stderr, "Output %d lists\n", incount);
incount = 0;
@@ -153,7 +153,7 @@
WHERE status = 1
AND ( mach_id IN ( SELECT UNIQUE pop_id FROM users ) OR
mach_id IN ( SELECT UNIQUE mach_id FROM filesys
- WHERE type = 'IMAP' ) )
+ WHERE type = 'IMAP' ) )
ORDER BY mach_id;
EXEC SQL OPEN m_cursor;
while (1)
@@ -198,7 +198,7 @@
cnt++;
}
EXEC SQL CLOSE e_cursor;
-
+
fprintf(stderr, "Loaded %d machines\n", cnt);
cnt = 0;
@@ -238,8 +238,7 @@
{
char *saddr = NULL, *paddr = NULL;
- EXEC SQL FETCH u_cursor INTO :id, :login, :potype, :pid, :iid, :bid,
- :eid;
+ EXEC SQL FETCH u_cursor INTO :id, :login, :potype, :pid, :iid, :bid, :eid;
if (sqlca.sqlcode)
break;
u = malloc(sizeof(struct user));
@@ -339,7 +338,6 @@
EXEC SQL DECLARE m_cursor2 CURSOR FOR
SELECT list_id, member_type, member_id
FROM imembers
- WHERE direct = 1
ORDER BY list_id;
EXEC SQL OPEN m_cursor2;
while (1)
@@ -358,13 +356,6 @@
m->next = l->m;
l->m = m;
}
- else if (type[0] == 'L' && (memberlist = hash_lookup(lists, mid)))
- {
- m->list_id = mid;
- m->name = memberlist->name;
- m->next = l->m;
- l->m = m;
- }
else if (type[0] == 'S' && (s = hash_lookup(strings, mid)))
{
m->list_id = 0;
@@ -385,34 +376,6 @@
}
-void save_mlist(int id, void *list, void *force)
-{
- struct member *m;
- struct list *l = list, *l1;
-
- if (l->maillist > 1 || (l->maillist == 0 && !force) ||
- !check_string(l->name))
- return;
-
- /* If user group appears on list, replace with user. */
- if (l->m && l->m->next == NULL && !strcasecmp(l->name, l->m->name))
- {
- l->maillist = 3;
- return;
- }
- l->maillist = 2;
- output_mlist(id, l);
-
- if (l->acl_t == 'L' && (l1 = hash_lookup(lists, l->acl_id)))
- save_mlist(0, l1, (void *)TRUE);
-
- for (m = l->m; m; m = m->next)
- {
- if (m->list_id && (l1 = hash_lookup(lists, m->list_id)))
- save_mlist(0, l1, (void *)TRUE);
- }
-}
-
void output_login(int dummy, void *user, void *out)
{
struct user *u = user;
@@ -422,21 +385,25 @@
fprintf(out, "%s: %s\n", u->login, u->pobox);
}
+int line_width, alias_width;
static const char *mailman_suffixes[] = { "-admin", "-owner", "-request",
- "-bounces", "-confirm", "-join",
- "-leave", "-subscribe",
- "-unsubscribe", NULL };
+ "-bounces", "-confirm", "-join",
+ "-leave", "-subscribe",
+ "-unsubscribe", NULL };
-void output_mlist(int id, struct list *l)
+void output_mlist(int id, void *list, void *out)
{
- struct list *l1;
- struct member *m;
+ struct list *l = list, *l1;
struct user *u;
- int line_width, alias_width, word_width, beginning;
- static int cont = 1;
- char str[8];
- int i;
+ int len = strlen(l->name), i;
+ if (!l->maillist || !check_string(l->name))
+ return;
+
+ /* If standard user group appears on a list, substitute in the user. */
+ if (l->m && l->m->next == NULL && !strcasecmp(l->name, l->m->name))
+ return;
+
put_fill(out, l->description);
if (l->mailman && strcmp(l->mailman_server, "[NONE]"))
@@ -444,23 +411,39 @@
for (i = 0; mailman_suffixes[i]; i++)
fprintf(out, "%s%s: %s%s@%s\n", l->name, mailman_suffixes[i], l->name,
mailman_suffixes[i], l->mailman_server);
- fprintf(out, "owner-%s: %s-owner@%s\n%s: ", l->name, l->name,
- l->mailman_server, l->name);
+ fprintf(out, "owner-%s: %s-owner@%s\n", l->name, l->name,
+ l->mailman_server);
}
else if (l->acl_t == 'L' && (l1 = hash_lookup(lists, l->acl_id)))
- fprintf(out, "owner-%s: %s\n%s: ", l->name, l1->name, l->name);
+ {
+ fprintf(out, "owner-%s: ", l->name);
+ alias_width = line_width = len + 8;
+ output_membership(l1, out);
+ fprintf(out, "\n");
+ }
else if (l->acl_t == 'U' && (u = hash_lookup(users, l->acl_id)))
- fprintf(out, "owner-%s: %s\n%s: ", l->name, u->login, l->name);
- else
- fprintf(out, "%s: ", l->name);
+ fprintf(out, "owner-%s: %s\n", l->name, u->login);
- alias_width = line_width = strlen(l->name) + 2;
- beginning = 1;
+ fprintf(out, "%s: ", l->name);
+ alias_width = line_width = len + 2;
+ output_membership(l, out);
+ fprintf(out, "\n\n");
+ incount++;
+}
+
+void output_membership(struct list *l, FILE *out)
+{
+ struct member *m;
+ struct list *l1;
+ int word_width, linestart = 1;
+ static int cont = 1;
+ char str[8];
+
for (m = l->m; m; m = m->next)
{
word_width = strlen(m->name);
- if (!beginning && alias_width + word_width + 2 > MAX_ALIAS_WIDTH)
+ if (!linestart && alias_width + word_width + 2 > MAX_ALIAS_WIDTH)
{
/* Make a continuation. */
sprintf(str, "%c%c%c%c%c%c", rand() % 26 + 97, rand() % 26 + 97,
@@ -469,20 +452,18 @@
fprintf(out, ",\n\tcont%d-%s\ncont%d-%s: ", cont, str, cont, str);
cont++;
alias_width = line_width = 17 + word_width;
- fputs(m->name, out);
}
- else if (beginning)
+ else if (linestart)
{
- /* Beginning of alias, so don't wrap. */
+ /* First word on line, so we can't wrap. */
line_width += word_width;
alias_width = line_width;
- fputs(m->name, out);
- beginning = 0;
+ linestart = 0;
}
else if (line_width + word_width + 2 > MAX_LINE_WIDTH)
{
/* Wrap. */
- fprintf(out, ",\n\t%s", m->name);
+ fputs(",\n\t", out);
alias_width += line_width + word_width + 2;
line_width = word_width + 8;
}
@@ -490,13 +471,16 @@
{
/* Continue line. */
line_width += word_width + 2;
- fprintf(out, ", %s", m->name);
+ fputs(", ", out);
}
+
+ if (m->list_id && (l1 = hash_lookup(lists, m->list_id)) && !l1->maillist)
+ output_membership(l1, out);
+ else
+ fputs(m->name, out);
}
if (!l->m)
fprintf(out, "/dev/null");
- fprintf(out, "\n\n");
- incount++;
}
/* Write a word-wrapped list description to the aliases file as a
@@ -553,7 +537,7 @@
}
-/* Illegal chars: this no longer corresponds to the array
+/* Illegal chars: this no longer corresponds to the array
* in setup_alis. '+' is a valid character in a string on
* a list, but is not a valid character in a listname.
*/