8 int createpipeto(char *alfile, char *user, char *listname, int owner);
13 fprint(2, "usage:\t%s -c listname\n", argv0);
14 fprint(2, "\t%s -[ar] listname addr\n", argv0);
19 main(int argc, char **argv)
21 char *listname, *addr;
22 String *owner, *alfile;
38 if(aflag + rflag + cflag > 1){
39 fprint(2, "%s: -a, -r, and -c are mutually exclusive\n", argv0);
48 mboxpath("address-list", listname, alfile, 0);
51 owner = s_copy(listname);
52 s_append(owner, "-owner");
53 if(creatembox(listname, nil) < 0)
54 sysfatal("creating %s's mbox: %r", listname);
55 if(creatembox(s_to_c(owner), nil) < 0)
56 sysfatal("creating %s's mbox: %r", s_to_c(owner));
57 if(createpipeto(s_to_c(alfile), listname, listname, 0) < 0)
58 sysfatal("creating %s's pipeto: %r", s_to_c(owner));
59 if(createpipeto(s_to_c(alfile), s_to_c(owner), listname, 1) < 0)
60 sysfatal("creating %s's pipeto: %r", s_to_c(owner));
61 writeaddr(s_to_c(alfile), "# mlmgr c flag", 0, listname);
66 writeaddr(s_to_c(alfile), "# mlmgr r flag", 0, listname);
67 writeaddr(s_to_c(alfile), addr, 1, listname);
72 writeaddr(s_to_c(alfile), "# mlmgr a flag", 0, listname);
73 writeaddr(s_to_c(alfile), addr, 0, listname);
80 createpipeto(char *alfile, char *user, char *listname, int owner)
87 mboxpath("pipeto", user, f, 0);
88 fprint(2, "creating new pipeto: %s\n", s_to_c(f));
89 fd = create(s_to_c(f), OWRITE, 0775);
94 fprint(fd, "Couldn't stat %s: %r\n", s_to_c(f));
98 if(dirfwstat(fd, d) < 0)
99 fprint(fd, "Couldn't wstat %s: %r\n", s_to_c(f));
102 fprint(fd, "#!/bin/rc\n");
104 fprint(fd, "/bin/upas/mlowner %s %s\n", alfile, listname);
106 fprint(fd, "/bin/upas/ml %s %s\n", alfile, user);