#include <signal.h>
#include <netdb.h>
#include <syslog.h>
-#include <pwd.h>
-#include <grp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include <stdarg.h>
+#include <time.h>
#define _PATH_INETDCONF "/etc/inetd.conf"
#define _PATH_INETDPID "/var/run/inetd.pid"
static struct rlimit rlim_ofile;
#endif
+#define INETD_UNSUPPORT_BILTIN 1
+
+/* Check unsupporting builtin */
+#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO
+#undef INETD_UNSUPPORT_BILTIN
+#endif
+#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DISCARD
+#undef INETD_UNSUPPORT_BILTIN
+#endif
+#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_TIME
+#undef INETD_UNSUPPORT_BILTIN
+#endif
+#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DAYTIME
+#undef INETD_UNSUPPORT_BILTIN
+#endif
+#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_CHARGEN
+#undef INETD_UNSUPPORT_BILTIN
+#endif
static struct servtab {
char *se_service; /* name of service */
static sigset_t blockmask, emptymask;
-#define INETD_UNSUPPORT_BILTIN 1
-
/* Echo received data */
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO
-#undef INETD_UNSUPPORT_BILTIN
static void echo_stream(int, struct servtab *);
static void echo_dg(int, struct servtab *);
#endif
/* Internet /dev/null */
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DISCARD
-#undef INETD_UNSUPPORT_BILTIN
static void discard_stream(int, struct servtab *);
static void discard_dg(int, struct servtab *);
#endif
/* Return 32 bit time since 1900 */
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_TIME
-#undef INETD_UNSUPPORT_BILTIN
static void machtime_stream(int, struct servtab *);
static void machtime_dg(int, struct servtab *);
#endif
/* Return human-readable time */
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DAYTIME
-#undef INETD_UNSUPPORT_BILTIN
static void daytime_stream(int, struct servtab *);
static void daytime_dg(int, struct servtab *);
#endif
/* Familiar character generator */
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_CHARGEN
-#undef INETD_UNSUPPORT_BILTIN
static void chargen_stream(int, struct servtab *);
static void chargen_dg(int, struct servtab *);
#endif
sep = (struct servtab *)malloc(sizeof (*sep));
if (sep == NULL) {
- syslog_err_and_discard_dg(SOCK_STREAM, memory_exhausted);
+ syslog_err_and_discard_dg(SOCK_STREAM, bb_msg_memory_exhausted);
}
*sep = *cp;
sep->se_fd = -1;
rl.rlim_cur = MIN(rl.rlim_max, rl.rlim_cur + FD_CHUNK);
if (rl.rlim_cur <= rlim_ofile_cur) {
syslog(LOG_ERR,
- "bump_nofile: cannot extend file limit, max = %d",
+#if _FILE_OFFSET_BITS == 64
+ "bump_nofile: cannot extend file limit, max = %lld",
+#else
+ "bump_nofile: cannot extend file limit, max = %ld",
+#endif
rl.rlim_cur);
return -1;
}
struct passwd *pwd;
struct group *grp = NULL;
struct sigaction sa;
- int ch, pid;
+ int pid;
+ unsigned long opt;
+ char *sq;
gid_t gid;
#ifdef INETD_UNSUPPORT_BILTIN
LastArg = environ[-1] + strlen(environ[-1]);
#endif
- while ((ch = getopt(argc, argv, "q:")) != EOF)
- switch(ch) {
- case 'q':
+#if defined(__uClinux__)
+ opt = bb_getopt_ulflags(argc, argv, "q:f", &sq);
+ if (!(opt & 4)) {
+ daemon(0, 0);
+ /* reexec for vfork() do continue parent */
+ vfork_daemon_rexec(argc, argv, "-f");
+ }
+#else
+ opt = bb_getopt_ulflags(ac, av, "q:", &sq);
+ daemon(0, 0);
+#endif /* uClinux */
+
+ if(opt & 1) {
global_queuelen = atoi(optarg);
if (global_queuelen < 8) global_queuelen=8;
- break;
- default:
- show_usage(); // "[-q len] [conf]"
}
argc -= optind;
argv += optind;
if (argc > 0)
CONFIG = argv[0];
- daemon(0, 0);
- openlog(applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
+ openlog(bb_applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
{
FILE *fp;