diff options
Diffstat (limited to 'jabberd')
-rw-r--r-- | jabberd/Makefile.am | 22 | ||||
-rw-r--r-- | jabberd/jabberd.h | 62 | ||||
-rw-r--r-- | jabberd/main.c | 910 | ||||
-rw-r--r-- | jabberd/progman.c | 647 |
4 files changed, 0 insertions, 1641 deletions
diff --git a/jabberd/Makefile.am b/jabberd/Makefile.am deleted file mode 100644 index 726eeb4..0000000 --- a/jabberd/Makefile.am +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | # This file is part of GSC | ||
2 | # Copyright (C) 2005, 2006, 2007 Sergey Poznyakoff | ||
3 | # | ||
4 | # GSC is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GSC is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GSC. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | bin_PROGRAMS = jabberd | ||
18 | jabberd_SOURCES = main.c progman.c jabberd.h | ||
19 | LDADD = ../lib/libgsc.a ../gnu/libgnu.a | ||
20 | INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gnu -I../gnu | ||
21 | AM_CPPFLAGS=-DSYSCONFDIR=\"$(sysconfdir)\"\ | ||
22 | -DSTATEDIR=\"$(localstatedir)/jabberd\" | ||
diff --git a/jabberd/jabberd.h b/jabberd/jabberd.h deleted file mode 100644 index 1537db4..0000000 --- a/jabberd/jabberd.h +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | /* jabberd - a dispatcher program for jabber 2.x | ||
2 | Copyright (C) 2007 Sergey Poznyakoff | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU General Public License as published by the | ||
6 | Free Software Foundation; either version 3 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along | ||
15 | with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | #ifdef HAVE_CONFIG_H | ||
18 | # include <config.h> | ||
19 | #endif | ||
20 | #include <sys/types.h> | ||
21 | #include <sys/wait.h> | ||
22 | #include <stdio.h> | ||
23 | #include <stdlib.h> | ||
24 | #include <stdarg.h> | ||
25 | #include <unistd.h> | ||
26 | #include <syslog.h> | ||
27 | #include <getopt.h> | ||
28 | #include <errno.h> | ||
29 | #include <string.h> | ||
30 | #include <pwd.h> | ||
31 | #include <grp.h> | ||
32 | #include <signal.h> | ||
33 | |||
34 | #include "gsc.h" | ||
35 | |||
36 | #define RETR_OUT 0 | ||
37 | #define RETR_ERR 1 | ||
38 | |||
39 | #define TESTTIME 2*60 | ||
40 | #define SLEEPTIME 5*60 | ||
41 | #define MAXSPAWN 10 | ||
42 | |||
43 | void register_transport (char *tag, char **argv, int retr[2], char **depv, | ||
44 | char *pidfile); | ||
45 | void register_jabber_process (char *cmd, char *cfg); | ||
46 | void logmsg (int prio, char *fmt, ...); | ||
47 | void signal_setup (RETSIGTYPE (*sf)(int)); | ||
48 | |||
49 | void *emalloc (size_t size); | ||
50 | |||
51 | void progman_start (void); | ||
52 | void progman_stop (void); | ||
53 | void progman_cleanup (int); | ||
54 | void progman_wake_disabled (void); | ||
55 | void progman_stop_component (const char *); | ||
56 | void progman_dump_stats (const char *); | ||
57 | |||
58 | extern int debug_level; | ||
59 | extern char *syslog_tag; | ||
60 | extern int log_facility; | ||
61 | extern unsigned long shutdown_timeout; | ||
62 | |||
diff --git a/jabberd/main.c b/jabberd/main.c deleted file mode 100644 index de0551f..0000000 --- a/jabberd/main.c +++ /dev/null | |||
@@ -1,910 +0,0 @@ | |||
1 | /* jabberd - a dispatcher program for jabber 2.x | ||
2 | Copyright (C) 2007 Sergey Poznyakoff | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU General Public License as published by the | ||
6 | Free Software Foundation; either version 3 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along | ||
15 | with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | #include "jabberd.h" | ||
18 | |||
19 | char *progname; | ||
20 | char *config_file = SYSCONFDIR "/jabberd.cfg"; | ||
21 | int debug_level = 0; | ||
22 | int foreground = 0; | ||
23 | int log_to_stderr = 0; | ||
24 | char *user = "jabber"; | ||
25 | char *syslog_tag = "jabberd"; | ||
26 | int log_facility = LOG_LOCAL7; | ||
27 | int x_argc; | ||
28 | char **x_argv; | ||
29 | char *pidfile = STATEDIR "/jabberd.pid"; | ||
30 | char *ctlfile = STATEDIR "/.jabberd.ctl"; | ||
31 | char *statfile = STATEDIR "/.jabberd.stat"; | ||
32 | unsigned long shutdown_timeout = 5; | ||
33 | mode_t jabberd_umask = 037; | ||
34 | |||
35 | void | ||
36 | syslog_printer (int prio, const char *fmt, va_list ap) | ||
37 | { | ||
38 | #if HAVE_VSYSLOG | ||
39 | vsyslog (prio, fmt, ap); | ||
40 | #else | ||
41 | char buf[128]; | ||
42 | vsnprintf (buf, sizeof buf, fmt, ap); | ||
43 | syslog (prio, "%s", buf); | ||
44 | #endif | ||
45 | } | ||
46 | |||
47 | void | ||
48 | stderr_printer (int prio, const char *fmt, va_list ap) | ||
49 | { | ||
50 | const char *p = gsc_syslog_priority_to_str (prio); | ||
51 | fprintf (stderr, "%s: ", progname); | ||
52 | |||
53 | if (p) | ||
54 | fprintf (stderr, "[%s] ", p); | ||
55 | |||
56 | vfprintf (stderr, fmt, ap); | ||
57 | fputc ('\n', stderr); | ||
58 | } | ||
59 | |||
60 | |||
61 | static void (*log_printer) (int prio, const char *fmt, va_list ap) = | ||
62 | stderr_printer; | ||
63 | |||
64 | void | ||
65 | logmsg (int prio, char *fmt, ...) | ||
66 | { | ||
67 | va_list ap; | ||
68 | va_start (ap, fmt); | ||
69 | log_printer (prio, fmt, ap); | ||
70 | va_end (ap); | ||
71 | } | ||
72 | |||
73 | void * | ||
74 | emalloc (size_t size) | ||
75 | { | ||
76 | char *p = malloc (size); | ||
77 | if (!p) | ||
78 | { | ||
79 | logmsg (LOG_EMERG, "%s", strerror (errno)); | ||
80 | exit (1); | ||
81 | } | ||
82 | return p; | ||
83 | } | ||
84 | |||
85 | void | ||
86 | usage () | ||
87 | { | ||
88 | printf ("usage: jabberd [-Dfehv][-c config][-r tag [tag...]]\n"); | ||
89 | printf ("jabberd -- A dispatcher program for jabber 2.x\n"); | ||
90 | printf ("\n"); | ||
91 | printf ("General-purpose options:\n"); | ||
92 | printf (" -c, --config-file=FILE use this configuration file\n"); | ||
93 | printf (" -D, --debug increase debugging level\n"); | ||
94 | printf (" -e, --stderr use standard error for diagnostics output\n"); | ||
95 | printf (" -f, --foreground run in foreground mode (implies -e)\n"); | ||
96 | printf (" --force start up even if another copy seems to be running\n"); | ||
97 | |||
98 | printf ("\nControlling running instance:\n"); | ||
99 | printf (" --status display status information\n"); | ||
100 | printf (" --stop stop the running copy\n"); | ||
101 | printf (" --reload, --hup reload the running copy\n"); | ||
102 | printf (" -r, --restart tag [tag...] restart named components\n"); | ||
103 | |||
104 | printf ("\nInformational options:\n"); | ||
105 | printf (" -h, --help display this help list\n"); | ||
106 | printf (" -v, --version display program version\n"); | ||
107 | |||
108 | |||
109 | printf ("\n"); | ||
110 | printf ("Report bugs to <%s>\n", PACKAGE_BUGREPORT); | ||
111 | } | ||
112 | |||
113 | |||
114 | /* Configuration file handling */ | ||
115 | |||
116 | void | ||
117 | cfg_syslog_tag (gsc_config_file_t *file, char *kw, char *val, void *unused) | ||
118 | { | ||
119 | syslog_tag = strdup (val); | ||
120 | } | ||
121 | |||
122 | void | ||
123 | cfg_syslog_facility (gsc_config_file_t *file, char *kw, char *val, void *unused) | ||
124 | { | ||
125 | if (gsc_str_to_syslog_facility (val, &log_facility)) | ||
126 | file->error_msg (file->file_name, file->line, "Unknown facility `%s'", | ||
127 | val); | ||
128 | } | ||
129 | |||
130 | void | ||
131 | cfg_user (gsc_config_file_t *file, char *kw, char *val, void *unused) | ||
132 | { | ||
133 | struct passwd *pwd = getpwnam (val); | ||
134 | if (!pwd) | ||
135 | file->error_msg (file->file_name, file->line, "no such user `%s'", | ||
136 | val); | ||
137 | else if (pwd->pw_uid == 0) | ||
138 | file->error_msg (file->file_name, file->line, "user `%s' has zero UID", | ||
139 | val); | ||
140 | else | ||
141 | user = strdup (val); | ||
142 | } | ||
143 | |||
144 | struct group_list | ||
145 | { | ||
146 | struct group_list *next; | ||
147 | gid_t gid; | ||
148 | }; | ||
149 | |||
150 | static struct group_list *group_list; | ||
151 | |||
152 | void | ||
153 | cfg_group (gsc_config_file_t *file, char *kw, char *val, void *unused) | ||
154 | { | ||
155 | struct group *group = getgrnam (val); | ||
156 | if (group) | ||
157 | { | ||
158 | struct group_list *p = emalloc (sizeof *p); | ||
159 | p->gid = group->gr_gid; | ||