~ubuntu-branches/debian/sid/rlinetd/sid

« back to all changes in this revision

Viewing changes to main.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Luberda
  • Date: 2010-03-20 18:03:45 UTC
  • mfrom: (2.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100320180345-x1srfbe2tg00ezsf
Tags: 0.7-1
* New upstream version.
* Recommend rsyslog instead of sysklogd (closes: #526922).
* update-inetd:
  + add support for enabling, disabling and removing entries;
  + use ucf for managing generated files;
  + ignore ucf files in rlinetd.conf;
  + make appropriate changes in  postinst and postrm scripts.
* Set debhelper compat level to 7
* Standards-Version: 3.8.4 (no changes). 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <errno.h>
2
 
#include <fcntl.h>
3
 
#include <grp.h>
4
 
#include <signal.h>
5
 
#include <stdio.h>
6
 
#include <stdlib.h>
7
 
#include <string.h>
8
 
#include <unistd.h>
9
 
#include <stdarg.h>
10
 
#include <sysexits.h>
11
 
#include <syslog.h>
12
 
#include <sys/types.h>
13
 
#include <sys/stat.h>
14
 
#include <sys/wait.h>
15
 
 
16
 
#include <config.h>
17
 
#include <installpaths.h>
18
 
 
19
 
#if TIME_WITH_SYS_TIME
20
 
# include <sys/time.h>
21
 
# include <time.h>
22
 
#else
23
 
# if HAVE_SYS_TIME_H
24
 
#  include <sys/time.h>
25
 
# else
26
 
#  include <time.h>
27
 
# endif
28
 
#endif
29
 
 
30
 
#ifdef HAVE_GETOPT_H
31
 
#include <getopt.h>
32
 
#endif
33
 
 
34
 
#include <sys/resource.h>
35
 
 
36
 
#include "bytecode.h"
37
 
#include "db.h"
38
 
#include "rlinetd.h"
39
 
#include "signals.h"
40
 
 
41
 
void main_loop();
42
 
 
43
 
int rl_debug = 0;
44
 
char *rl_parser = MODULESDIR "/libparse.so";
45
 
char *rl_config = SYSCONFDIR "/rlinetd.conf";
46
 
char rl_lf[] = "\n";
47
 
#ifdef HAVE_GETOPT_LONG
48
 
struct option options[] = {
49
 
                { "help", 0, NULL, 'h' },
50
 
                { "debug", 0, NULL, 'd' },
51
 
                { "parser", 1, NULL, 'p' },
52
 
                { "config", 1, NULL, 'f' },
53
 
                { NULL, 0, NULL, 0 }
54
 
};
55
 
#endif
56
 
 
57
 
int main(int argc, char **argv) {
58
 
        int i;
59
 
 
60
 
#ifdef HAVE_GETOPT
61
 
        while((i =
62
 
#ifdef HAVE_GETOPT_LONG
63
 
                                 getopt_long
64
 
#else
65
 
                                 getopt
66
 
#endif                           
67
 
                                 (argc, argv, "p:f:dh"
68
 
#ifdef HAVE_GETOPT_LONG
69
 
                                                                                                 , options, NULL
70
 
#endif                                                                                           
71
 
                                                                                                 )) != -1) {
72
 
                switch(i) {
73
 
                        case 'p':
74
 
                                rl_parser = optarg;
75
 
                                break;
76
 
                        case 'f':
77
 
                                rl_config = optarg;
78
 
                                break;
79
 
                        case 'd':
80
 
                                rl_debug++;
81
 
                                break;
82
 
                        case 'h':
83
 
                                fprintf(stderr, "%s Version %s\n"
84
 
                                                                "Usage %s: [options]\n"
85
 
                                                                "\t-p file\t\talternative parser module (default %s)\n"
86
 
                                                                "\t-f file\t\talternative config file (default %s)\n"
87
 
                                                                "\t-h\t\tthis message\n", PACKAGE, VERSION, argv[0],
88
 
                                                                rl_parser, rl_config);
89
 
                                exit(0);
90
 
                        default:
91
 
                                fprintf(stderr, "Unknown option '%c'\n", i);
92
 
                                exit(EX_USAGE);
93
 
                }
94
 
        }
95
 
#endif  
96
 
        if(!rl_debug) {
97
 
                switch(fork()) {
98
 
                        case -1:
99
 
                                perror("fork");
100
 
                                exit(EX_OSERR);
101
 
                        case 0:
102
 
                                chdir("/");
103
 
                                setgroups(0, NULL);
104
 
                                setsid();
105
 
                                break;
106
 
                        default:
107
 
                                exit(0);
108
 
                }
109
 
        }
110
 
        openlog("rlinetd", LOG_NDELAY|LOG_PID, LOG_DAEMON);
111
 
        rl_siginit();
112
 
        main_loop();
113
 
        return 0;
114
 
}
115
 
 
116
 
/* vim: set ts=2: */