aboutsummaryrefslogtreecommitdiff
path: root/jabberd
diff options
context:
space:
mode:
Diffstat (limited to 'jabberd')
-rw-r--r--jabberd/Makefile.am22
-rw-r--r--jabberd/jabberd.h62
-rw-r--r--jabberd/main.c910
-rw-r--r--jabberd/progman.c647
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
17bin_PROGRAMS = jabberd
18jabberd_SOURCES = main.c progman.c jabberd.h
19LDADD = ../lib/libgsc.a ../gnu/libgnu.a
20INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gnu -I../gnu
21AM_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
43void register_transport (char *tag, char **argv, int retr[2], char **depv,
44 char *pidfile);
45void register_jabber_process (char *cmd, char *cfg);
46void logmsg (int prio, char *fmt, ...);
47void signal_setup (RETSIGTYPE (*sf)(int));
48
49void *emalloc (size_t size);
50
51void progman_start (void);
52void progman_stop (void);
53void progman_cleanup (int);
54void progman_wake_disabled (void);
55void progman_stop_component (const char *);
56void progman_dump_stats (const char *);
57
58extern int debug_level;
59extern char *syslog_tag;
60extern int log_facility;
61extern 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
19char *progname;
20char *config_file = SYSCONFDIR "/jabberd.cfg";
21int debug_level = 0;
22int foreground = 0;
23int log_to_stderr = 0;
24char *user = "jabber";
25char *syslog_tag = "jabberd";
26int log_facility = LOG_LOCAL7;
27int x_argc;
28char **x_argv;
29char *pidfile = STATEDIR "/jabberd.pid";
30char *ctlfile = STATEDIR "/.jabberd.ctl";
31char *statfile = STATEDIR "/.jabberd.stat";
32unsigned long shutdown_timeout = 5;
33mode_t jabberd_umask = 037;
34
35void
36syslog_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
47void
48stderr_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
61static void (*log_printer) (int prio, const char *fmt, va_list ap) =
62 stderr_printer;
63
64void
65logmsg (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
73void *
74emalloc (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
85void
86usage ()
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
116void
117cfg_syslog_tag (gsc_config_file_t *file, char *kw, char *val, void *unused)
118{
119 syslog_tag = strdup (val);
120}
121
122void
123cfg_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
130void
131cfg_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
144struct group_list
145{
146 struct group_list *next;
147 gid_t gid;
148};
149
150static struct group_list *group_list;
151
152void
153cfg_group (gsc_config_file_t *file, char *kw, char *val, void *unused)
154{
155 struct group *group = getgrnam (val);
156 if (group)
157 {