Attachment 'members.c'
Download 1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4
5 /*
6 The members.c file is compiled via
7
8 gcc members.c -o /usr/local/mailman/bin/members
9
10 The object has permissions
11
12 -r-xr-s--- 1 apache mailman 5382 Mar 3 11:57 /usr/local/mailman/bin/members
13
14 If it is necessary to recompile, ownership and permissions need to be reset.
15
16 chown apache:mailman /usr/local/mailman/bin/members
17 chmod 2550 /usr/local/mailman/bin/members
18
19 If your web server user is not 'apache', replace 'apache' above with whatever
20 user name your web server runs under.
21
22 The idea is this is SETGID mailman and executable by the web server. It wraps
23 a few Mailman bin/ commands so that they can be executed by php scripts (or
24 anyone who can execute the file). The commands it recognizes/allows are in the
25 legals[] array in the source - currently just find_member, list_members
26
27 Once this is done, a command such as "list_members <arguments> list_name"
28 can be executed by apache in a php script using the php system() or exec()
29 functions, depending on how you want to handle output, using the string
30
31 "/usr/local/mailman/bin/members list_members <arguments> list_name"
32
33 as the command.
34 */
35
36 main(int argc, char** argv, char** env) {
37
38 char* legals[] = {
39 "list_members",
40 "find_member",
41 (char*) NULL
42 };
43
44 int i;
45 int flag = 0;
46 char command[100];
47
48 if (argc < 2) {
49 dprintf(STDERR_FILENO,
50 "Usage: %s command command_args\nNo command found\n",
51 argv[0]);
52 exit(1);
53 }
54
55 for ( i = 0; legals[i] != (char*) NULL; i++ ) {
56 if (strcmp(legals[i], argv[1]) == 0) {
57 flag = 1;
58 break;
59 }
60 }
61 if (!flag){
62 dprintf(STDERR_FILENO,
63 "Usage: %s command command_args\nUnknown command: %s\n",
64 argv[0], argv[1]);
65 exit(1);
66 }
67 sprintf(command, "/usr/local/mailman/bin/%s", argv[1]);
68 execve(command, &argv[1], env);
69 dprintf(STDERR_FILENO, "execve of %s failed\n", command);
70 exit(2);
71 }
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.