dnsd fix; option_mask32 added. dnsd needs more love.
This commit is contained in:
parent
4e6ceb4455
commit
c12f53090b
@ -206,9 +206,10 @@ extern void xsetgid(gid_t gid);
|
||||
extern void xsetuid(uid_t uid);
|
||||
extern off_t fdlength(int fd);
|
||||
|
||||
#define BB_GETOPT_ERROR 0x80000000UL
|
||||
enum { BB_GETOPT_ERROR = 0x80000000 };
|
||||
extern const char *opt_complementary;
|
||||
extern const struct option *applet_long_options;
|
||||
extern uint32_t option_mask32;
|
||||
extern uint32_t getopt32(int argc, char **argv, const char *applet_opts, ...);
|
||||
|
||||
extern int bb_vfprintf(FILE * __restrict stream, const char * __restrict format,
|
||||
|
@ -302,6 +302,8 @@ static const struct option bb_default_long_options[] = {
|
||||
const struct option *applet_long_options = bb_default_long_options;
|
||||
#endif
|
||||
|
||||
uint32_t option_mask32;
|
||||
|
||||
uint32_t
|
||||
getopt32(int argc, char **argv, const char *applet_opts, ...)
|
||||
{
|
||||
@ -512,5 +514,7 @@ loop_arg_is_opt:
|
||||
argc -= optind;
|
||||
if (argc < min_arg || (max_arg >= 0 && argc > max_arg))
|
||||
bb_show_usage();
|
||||
|
||||
option_mask32 = flags;
|
||||
return flags;
|
||||
}
|
||||
|
@ -693,7 +693,6 @@ enum { STRVERSIONLEN = 32 };
|
||||
|
||||
/*======================================================================*/
|
||||
|
||||
static unsigned option_mask;
|
||||
#define OPTION_STR "sLo:fkvqx" USE_FEATURE_INSMOD_LOAD_MAP("m")
|
||||
enum {
|
||||
OPT_s = 0x1, // -s /* log to syslog */
|
||||
@ -713,13 +712,13 @@ enum {
|
||||
OPT_x = 0x80, // -x /* do not export externs */
|
||||
OPT_m = 0x100, // -m /* print module load map */
|
||||
};
|
||||
#define flag_force_load (option_mask & OPT_f)
|
||||
#define flag_autoclean (option_mask & OPT_k)
|
||||
#define flag_verbose (option_mask & OPT_v)
|
||||
#define flag_quiet (option_mask & OPT_q)
|
||||
#define flag_noexport (option_mask & OPT_x)
|
||||
#define flag_force_load (option_mask32 & OPT_f)
|
||||
#define flag_autoclean (option_mask32 & OPT_k)
|
||||
#define flag_verbose (option_mask32 & OPT_v)
|
||||
#define flag_quiet (option_mask32 & OPT_q)
|
||||
#define flag_noexport (option_mask32 & OPT_x)
|
||||
#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP
|
||||
#define flag_print_load_map (option_mask & OPT_m)
|
||||
#define flag_print_load_map (option_mask32 & OPT_m)
|
||||
#else
|
||||
#define flag_print_load_map 0
|
||||
#endif
|
||||
@ -3983,8 +3982,8 @@ int insmod_main( int argc, char **argv)
|
||||
struct utsname myuname;
|
||||
|
||||
/* Parse any options */
|
||||
option_mask = getopt32(argc, argv, OPTION_STR, &opt_o);
|
||||
if (option_mask & OPT_o) { // -o /* name the output module */
|
||||
getopt32(argc, argv, OPTION_STR, &opt_o);
|
||||
if (option_mask32 & OPT_o) { // -o /* name the output module */
|
||||
free(m_name);
|
||||
m_name = xstrdup(opt_o);
|
||||
}
|
||||
|
@ -23,6 +23,12 @@ static char *fileconf = "/etc/dnsd.conf";
|
||||
#define LOCK_FILE "/var/run/dnsd.lock"
|
||||
#define LOG_FILE "/var/log/dnsd.log"
|
||||
|
||||
// Must matct getopt32 call
|
||||
#define OPT_daemon (option_mask32 & 0x10)
|
||||
#define OPT_verbose (option_mask32 & 0x20)
|
||||
|
||||
//#define DEBUG 1
|
||||
|
||||
enum {
|
||||
MAX_HOST_LEN = 16, // longest host name allowed is 15
|
||||
IP_STRING_LEN = 18, // .xxx.xxx.xxx.xxx\0
|
||||
@ -70,7 +76,8 @@ struct dns_entry { // element of known name, ip address and reversed ip address
|
||||
};
|
||||
|
||||
static struct dns_entry *dnsentry = NULL;
|
||||
static int daemonmode = 0;
|
||||
// FIXME! unused! :(
|
||||
static int daemonmode;
|
||||
static uint32_t ttl = DEFAULT_TTL;
|
||||
|
||||
/*
|
||||
@ -79,7 +86,7 @@ static uint32_t ttl = DEFAULT_TTL;
|
||||
static void convname(char *a, uint8_t *q)
|
||||
{
|
||||
int i = (q[0] == '.') ? 0 : 1;
|
||||
for(; i < MAX_HOST_LEN-1 && *q; i++, q++)
|
||||
for (; i < MAX_HOST_LEN-1 && *q; i++, q++)
|
||||
a[i] = tolower(*q);
|
||||
a[0] = i - 1;
|
||||
a[i] = 0;
|
||||
@ -91,9 +98,10 @@ static void convname(char *a, uint8_t *q)
|
||||
static void undot(uint8_t * rip)
|
||||
{
|
||||
int i = 0, s = 0;
|
||||
while(rip[i]) i++;
|
||||
for(--i; i >= 0; i--) {
|
||||
if(rip[i] == '.') {
|
||||
while (rip[i])
|
||||
i++;
|
||||
for (--i; i >= 0; i--) {
|
||||
if (rip[i] == '.') {
|
||||
rip[i] = s;
|
||||
s = 0;
|
||||
} else s++;
|
||||
@ -124,41 +132,42 @@ static void log_message(char *filename, char *message)
|
||||
* converting to a length/string substring for that label.
|
||||
*/
|
||||
|
||||
static int getfileentry(FILE * fp, struct dns_entry *s, int verb)
|
||||
static int getfileentry(FILE * fp, struct dns_entry *s)
|
||||
{
|
||||
unsigned int a,b,c,d;
|
||||
char *r, *name;
|
||||
|
||||
restart:
|
||||
if(!(r = bb_get_line_from_file(fp)))
|
||||
restart:
|
||||
r = bb_get_line_from_file(fp);
|
||||
if (!r)
|
||||
return -1;
|
||||
while(*r == ' ' || *r == '\t') {
|
||||
while (*r == ' ' || *r == '\t') {
|
||||
r++;
|
||||
if(!*r || *r == '#' || *r == '\n')
|
||||
if (!*r || *r == '#' || *r == '\n')
|
||||
goto restart; /* skipping empty/blank and commented lines */
|
||||
}
|
||||
name = r;
|
||||
while(*r != ' ' && *r != '\t')
|
||||
while (*r != ' ' && *r != '\t')
|
||||
r++;
|
||||
*r++ = 0;
|
||||
if(sscanf(r,"%u.%u.%u.%u",&a,&b,&c,&d) != 4)
|
||||
goto restart; /* skipping wrong lines */
|
||||
if (sscanf(r, "%u.%u.%u.%u", &a, &b, &c, &d) != 4)
|
||||
goto restart; /* skipping wrong lines */
|
||||
|
||||
sprintf(s->ip,"%u.%u.%u.%u",a,b,c,d);
|
||||
sprintf(s->rip,".%u.%u.%u.%u",d,c,b,a);
|
||||
sprintf(s->ip, "%u.%u.%u.%u", a, b, c, d);
|
||||
sprintf(s->rip, ".%u.%u.%u.%u", d, c, b, a);
|
||||
undot((uint8_t*)s->rip);
|
||||
convname(s->name,(uint8_t*)name);
|
||||
|
||||
if(verb)
|
||||
fprintf(stderr,"\tname:%s, ip:%s\n",&(s->name[1]),s->ip);
|
||||
if (OPT_verbose)
|
||||
fprintf(stderr, "\tname:%s, ip:%s\n", &(s->name[1]),s->ip);
|
||||
|
||||
return 0; /* warningkiller */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read hostname/IP records from file
|
||||
*/
|
||||
static void dnsentryinit(int verb)
|
||||
static void dnsentryinit(void)
|
||||
{
|
||||
FILE *fp;
|
||||
struct dns_entry *m, *prev;
|
||||
@ -170,7 +179,7 @@ static void dnsentryinit(int verb)
|
||||
m = xmalloc(sizeof(struct dns_entry));
|
||||
|
||||
m->next = NULL;
|
||||
if (getfileentry(fp, m, verb))
|
||||
if (getfileentry(fp, m))
|
||||
break;
|
||||
|
||||
if (prev == NULL)
|
||||
@ -224,28 +233,32 @@ static int table_lookup(uint16_t type, uint8_t * as, uint8_t * qs)
|
||||
char *p,*q;
|
||||
q = (char *)&(qs[1]);
|
||||
p = &(d->name[1]);
|
||||
fprintf(stderr, "\ntest: %d <%s> <%s> %d", strlen(p), p, q, strlen(q));
|
||||
fprintf(stderr, "\n%s: %d/%d p:%s q:%s %d",
|
||||
__FUNCTION__, strlen(p), (int)(d->name[0]), p, q, strlen(q));
|
||||
#endif
|
||||
if (type == REQ_A) { /* search by host name */
|
||||
for(i = 1; i <= (int)(d->name[0]); i++)
|
||||
if(tolower(qs[i]) != d->name[i])
|
||||
continue;
|
||||
for (i = 1; i <= (int)(d->name[0]); i++)
|
||||
if (tolower(qs[i]) != d->name[i])
|
||||
break;
|
||||
if (i > (int)(d->name[0])) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " OK");
|
||||
fprintf(stderr, " OK");
|
||||
#endif
|
||||
strcpy((char *)as, d->ip);
|
||||
strcpy((char *)as, d->ip);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " %s ", as);
|
||||
fprintf(stderr, " as:%s\n", as);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
else if (type == REQ_PTR) { /* search by IP-address */
|
||||
}
|
||||
} else
|
||||
if (type == REQ_PTR) { /* search by IP-address */
|
||||
if (!strncmp((char*)&d->rip[1], (char*)&qs[1], strlen(d->rip)-1)) {
|
||||
strcpy((char *)as, d->name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} while ((d = d->next) != NULL);
|
||||
d = d->next;
|
||||
} while (d);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -253,7 +266,7 @@ static int table_lookup(uint16_t type, uint8_t * as, uint8_t * qs)
|
||||
/*
|
||||
* Decode message and generate answer
|
||||
*/
|
||||
#define eret(s) do { fprintf (stderr, "%s\n", s); return -1; } while (0)
|
||||
#define eret(s) do { fputs(s, stderr); return -1; } while (0)
|
||||
static int process_packet(uint8_t * buf)
|
||||
{
|
||||
struct dns_head *head;
|
||||
@ -269,13 +282,13 @@ static int process_packet(uint8_t * buf)
|
||||
|
||||
head = (struct dns_head *)buf;
|
||||
if (head->nquer == 0)
|
||||
eret("no queries");
|
||||
eret("no queries\n");
|
||||
|
||||
if ((head->flags & 0x8000))
|
||||
eret("ignoring response packet");
|
||||
if (head->flags & 0x8000)
|
||||
eret("ignoring response packet\n");
|
||||
|
||||
from = (void *)&head[1]; // start of query string
|
||||
next = answb = from + strlen((char *)&head[1]) + 1 + sizeof(struct dns_prop); // where to append answer block
|
||||
next = answb = from + strlen((char *)from) + 1 + sizeof(struct dns_prop); // where to append answer block
|
||||
|
||||
outr.rlen = 0; // may change later
|
||||
outr.r = NULL;
|
||||
@ -299,9 +312,8 @@ static int process_packet(uint8_t * buf)
|
||||
goto empty_packet;
|
||||
|
||||
// We have a standard query
|
||||
|
||||
log_message(LOG_FILE, (char *)head);
|
||||
lookup_result = table_lookup(type, answstr, (uint8_t*)(&head[1]));
|
||||
log_message(LOG_FILE, (char *)from);
|
||||
lookup_result = table_lookup(type, answstr, (uint8_t*)from);
|
||||
if (lookup_result != 0) {
|
||||
outr.flags = 3 | 0x0400; //name do not exist and auth
|
||||
goto empty_packet;
|
||||
@ -335,7 +347,7 @@ static int process_packet(uint8_t * buf)
|
||||
memcpy(next, (void *)answstr, outr.rlen);
|
||||
next += outr.rlen;
|
||||
|
||||
empty_packet:
|
||||
empty_packet:
|
||||
|
||||
flags = ntohs(head->flags);
|
||||
// clear rcode and RA, set responsebit and our new flags
|
||||
@ -358,35 +370,31 @@ static void interrupt(int x)
|
||||
exit(2);
|
||||
}
|
||||
|
||||
#define is_daemon() (flags&16)
|
||||
#define is_verbose() (flags&32)
|
||||
//#define DEBUG 1
|
||||
|
||||
int dnsd_main(int argc, char **argv)
|
||||
{
|
||||
int udps;
|
||||
uint16_t port = 53;
|
||||
uint8_t buf[MAX_PACK_LEN];
|
||||
unsigned long flags = 0;
|
||||
char *listen_interface = "0.0.0.0";
|
||||
char *sttl=NULL, *sport=NULL;
|
||||
char *sttl, *sport;
|
||||
|
||||
if(argc > 1)
|
||||
flags = getopt32(argc, argv, "i:c:t:p:dv", &listen_interface, &fileconf, &sttl, &sport);
|
||||
if(sttl)
|
||||
if(!(ttl = atol(sttl)))
|
||||
getopt32(argc, argv, "i:c:t:p:dv", &listen_interface, &fileconf, &sttl, &sport);
|
||||
//if (option_mask32 & 0x1) // -i
|
||||
//if (option_mask32 & 0x2) // -c
|
||||
if (option_mask32 & 0x4) // -t
|
||||
if (!(ttl = atol(sttl)))
|
||||
bb_show_usage();
|
||||
if(sport)
|
||||
if(!(port = atol(sport)))
|
||||
if (option_mask32 & 0x8) // -p
|
||||
if (!(port = atol(sport)))
|
||||
bb_show_usage();
|
||||
|
||||
if(is_verbose()) {
|
||||
fprintf(stderr,"listen_interface: %s\n", listen_interface);
|
||||
fprintf(stderr,"ttl: %d, port: %d\n", ttl, port);
|
||||
fprintf(stderr,"fileconf: %s\n", fileconf);
|
||||
if (OPT_verbose) {
|
||||
bb_info_msg("listen_interface: %s", listen_interface);
|
||||
bb_info_msg("ttl: %d, port: %d", ttl, port);
|
||||
bb_info_msg("fileconf: %s", fileconf);
|
||||
}
|
||||
|
||||
if(is_daemon())
|
||||
if (OPT_daemon)
|
||||
#ifdef BB_NOMMU
|
||||
/* reexec for vfork() do continue parent */
|
||||
vfork_daemon_rexec(1, 0, argc, argv, "-d");
|
||||
@ -394,7 +402,7 @@ int dnsd_main(int argc, char **argv)
|
||||
xdaemon(1, 0);
|
||||
#endif
|
||||
|
||||
dnsentryinit(is_verbose());
|
||||
dnsentryinit();
|
||||
|
||||
signal(SIGINT, interrupt);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
@ -417,20 +425,20 @@ int dnsd_main(int argc, char **argv)
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(udps, &fdset);
|
||||
// Block until a message arrives
|
||||
if((r = select(udps + 1, &fdset, NULL, NULL, NULL)) < 0)
|
||||
r = select(udps + 1, &fdset, NULL, NULL, NULL);
|
||||
if (r < 0)
|
||||
bb_perror_msg_and_die("select error");
|
||||
else
|
||||
if(r == 0)
|
||||
if (r == 0)
|
||||
bb_perror_msg_and_die("select spurious return");
|
||||
|
||||
/* Can this test ever be false? */
|
||||
/* Can this test ever be false? - yes */
|
||||
if (FD_ISSET(udps, &fdset)) {
|
||||
struct sockaddr_in from;
|
||||
int fromlen = sizeof(from);
|
||||
r = recvfrom(udps, buf, sizeof(buf), 0,
|
||||
(struct sockaddr *)&from,
|
||||
(void *)&fromlen);
|
||||
if(is_verbose())
|
||||
if (OPT_verbose)
|
||||
fprintf(stderr, "\n--- Got UDP ");
|
||||
log_message(LOG_FILE, "\n--- Got UDP ");
|
||||
|
||||
@ -445,9 +453,7 @@ int dnsd_main(int argc, char **argv)
|
||||
r, 0, (struct sockaddr *)&from,
|
||||
fromlen);
|
||||
}
|
||||
} // end if
|
||||
} // end while
|
||||
} // end if
|
||||
} // end while
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,7 +89,6 @@ struct interfaces_file_t
|
||||
struct mapping_defn_t *mappings;
|
||||
};
|
||||
|
||||
static unsigned option_mask;
|
||||
#define OPTION_STR "anvf" USE_FEATURE_IFUPDOWN_MAPPING("m") "i:"
|
||||
enum {
|
||||
OPT_do_all = 0x1,
|
||||
@ -98,11 +97,11 @@ enum {
|
||||
OPT_force = 0x8,
|
||||
OPT_no_mappings = 0x10,
|
||||
};
|
||||
#define DO_ALL (option_mask & OPT_do_all)
|
||||
#define NO_ACT (option_mask & OPT_no_act)
|
||||
#define VERBOSE (option_mask & OPT_verbose)
|
||||
#define FORCE (option_mask & OPT_force)
|
||||
#define NO_MAPPINGS (option_mask & OPT_no_mappings)
|
||||
#define DO_ALL (option_mask32 & OPT_do_all)
|
||||
#define NO_ACT (option_mask32 & OPT_no_act)
|
||||
#define VERBOSE (option_mask32 & OPT_verbose)
|
||||
#define FORCE (option_mask32 & OPT_force)
|
||||
#define NO_MAPPINGS (option_mask32 & OPT_no_mappings)
|
||||
|
||||
static char **__myenviron;
|
||||
|
||||
@ -881,10 +880,10 @@ static void set_environ(struct interface_defn_t *iface, const char *mode)
|
||||
|
||||
static int doit(char *str)
|
||||
{
|
||||
if (option_mask & (OPT_no_act|OPT_verbose)) {
|
||||
if (option_mask32 & (OPT_no_act|OPT_verbose)) {
|
||||
puts(str);
|
||||
}
|
||||
if (!(option_mask & OPT_no_act)) {
|
||||
if (!(option_mask32 & OPT_no_act)) {
|
||||
pid_t child;
|
||||
int status;
|
||||
|
||||
@ -1088,7 +1087,7 @@ int ifupdown_main(int argc, char **argv)
|
||||
cmds = iface_down;
|
||||
}
|
||||
|
||||
option_mask = getopt32(argc, argv, OPTION_STR, &interfaces);
|
||||
getopt32(argc, argv, OPTION_STR, &interfaces);
|
||||
if (argc - optind > 0) {
|
||||
if (DO_ALL) bb_show_usage();
|
||||
} else
|
||||
|
11
procps/top.c
11
procps/top.c
@ -34,8 +34,7 @@ typedef int (*cmp_t)(procps_status_t *P, procps_status_t *Q);
|
||||
|
||||
static procps_status_t *top; /* Hehe */
|
||||
static int ntop;
|
||||
static unsigned option_mask;
|
||||
#define OPT_BATCH_MODE (option_mask & 0x4)
|
||||
#define OPT_BATCH_MODE (option_mask32 & 0x4)
|
||||
|
||||
#ifdef CONFIG_FEATURE_USE_TERMIOS
|
||||
static int pid_sort(procps_status_t *P, procps_status_t *Q)
|
||||
@ -398,11 +397,11 @@ int top_main(int argc, char **argv)
|
||||
/* do normal option parsing */
|
||||
interval = 5;
|
||||
opt_complementary = "-";
|
||||
option_mask = getopt32(argc, argv, "d:n:b",
|
||||
getopt32(argc, argv, "d:n:b",
|
||||
&sinterval, &siterations);
|
||||
if (option_mask & 0x1) interval = atoi(sinterval); // -d
|
||||
if (option_mask & 0x2) iterations = atoi(siterations); // -n
|
||||
//if (option_mask & 0x4) // -b
|
||||
if (option_mask32 & 0x1) interval = atoi(sinterval); // -d
|
||||
if (option_mask32 & 0x2) iterations = atoi(siterations); // -n
|
||||
//if (option_mask32 & 0x4) // -b
|
||||
|
||||
/* change to /proc */
|
||||
xchdir("/proc");
|
||||
|
@ -2,13 +2,12 @@
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
static unsigned option_mask;
|
||||
// Must match constants in chpst_main!
|
||||
#define OPT_verbose (option_mask & 0x2000)
|
||||
#define OPT_pgrp (option_mask & 0x4000)
|
||||
#define OPT_nostdin (option_mask & 0x8000)
|
||||
#define OPT_nostdout (option_mask & 0x10000)
|
||||
#define OPT_nostderr (option_mask & 0x20000)
|
||||
#define OPT_verbose (option_mask32 & 0x2000)
|
||||
#define OPT_pgrp (option_mask32 & 0x4000)
|
||||
#define OPT_nostdin (option_mask32 & 0x8000)
|
||||
#define OPT_nostdout (option_mask32 & 0x10000)
|
||||
#define OPT_nostderr (option_mask32 & 0x20000)
|
||||
|
||||
static char *set_user;
|
||||
static char *env_user;
|
||||
@ -224,28 +223,28 @@ int chpst_main(int argc, char **argv)
|
||||
|
||||
{
|
||||
char *m,*d,*o,*p,*f,*c,*r,*t,*n;
|
||||
option_mask = getopt32(argc, argv, "u:U:e:m:d:o:p:f:c:r:t:/:n:vP012",
|
||||
getopt32(argc, argv, "u:U:e:m:d:o:p:f:c:r:t:/:n:vP012",
|
||||
&set_user,&env_user,&env_dir,
|
||||
&m,&d,&o,&p,&f,&c,&r,&t,&root,&n);
|
||||
// if (option_mask & 0x1) // -u
|
||||
// if (option_mask & 0x2) // -U
|
||||
// if (option_mask & 0x4) // -e
|
||||
if (option_mask & 0x8) limits = limitl = limita = limitd = bb_xgetularg10(m); // -m
|
||||
if (option_mask & 0x10) limitd = bb_xgetularg10(d); // -d
|
||||
if (option_mask & 0x20) limito = bb_xgetularg10(o); // -o
|
||||
if (option_mask & 0x40) limitp = bb_xgetularg10(p); // -p
|
||||
if (option_mask & 0x80) limitf = bb_xgetularg10(f); // -f
|
||||
if (option_mask & 0x100) limitc = bb_xgetularg10(c); // -c
|
||||
if (option_mask & 0x200) limitr = bb_xgetularg10(r); // -r
|
||||
if (option_mask & 0x400) limitt = bb_xgetularg10(t); // -t
|
||||
// if (option_mask & 0x800) // -/
|
||||
if (option_mask & 0x1000) nicelvl = bb_xgetlarg_bnd_sfx(n, 10, -20, 20, NULL); // -n
|
||||
// if (option_mask32 & 0x1) // -u
|
||||
// if (option_mask32 & 0x2) // -U
|
||||
// if (option_mask32 & 0x4) // -e
|
||||
if (option_mask32 & 0x8) limits = limitl = limita = limitd = bb_xgetularg10(m); // -m
|
||||
if (option_mask32 & 0x10) limitd = bb_xgetularg10(d); // -d
|
||||
if (option_mask32 & 0x20) limito = bb_xgetularg10(o); // -o
|
||||
if (option_mask32 & 0x40) limitp = bb_xgetularg10(p); // -p
|
||||
if (option_mask32 & 0x80) limitf = bb_xgetularg10(f); // -f
|
||||
if (option_mask32 & 0x100) limitc = bb_xgetularg10(c); // -c
|
||||
if (option_mask32 & 0x200) limitr = bb_xgetularg10(r); // -r
|
||||
if (option_mask32 & 0x400) limitt = bb_xgetularg10(t); // -t
|
||||
// if (option_mask32 & 0x800) // -/
|
||||
if (option_mask32 & 0x1000) nicelvl = bb_xgetlarg_bnd_sfx(n, 10, -20, 20, NULL); // -n
|
||||
// The below consts should match #defines at top!
|
||||
//if (option_mask & 0x2000) OPT_verbose = 1; // -v
|
||||
//if (option_mask & 0x4000) OPT_pgrp = 1; // -P
|
||||
//if (option_mask & 0x8000) OPT_nostdin = 1; // -0
|
||||
//if (option_mask & 0x10000) OPT_nostdout = 1; // -1
|
||||
//if (option_mask & 0x20000) OPT_nostderr = 1; // -2
|
||||
//if (option_mask32 & 0x2000) OPT_verbose = 1; // -v
|
||||
//if (option_mask32 & 0x4000) OPT_pgrp = 1; // -P
|
||||
//if (option_mask32 & 0x8000) OPT_nostdin = 1; // -0
|
||||
//if (option_mask32 & 0x10000) OPT_nostdout = 1; // -1
|
||||
//if (option_mask32 & 0x20000) OPT_nostderr = 1; // -2
|
||||
}
|
||||
argv += optind;
|
||||
if (!argv || !*argv) bb_show_usage();
|
||||
@ -311,19 +310,19 @@ static void envdir(int argc, char **argv)
|
||||
static void softlimit(int argc, char **argv)
|
||||
{
|
||||
char *a,*c,*d,*f,*l,*m,*o,*p,*r,*s,*t;
|
||||
option_mask = getopt32(argc, argv, "a:c:d:f:l:m:o:p:r:s:t:",
|
||||
getopt32(argc, argv, "a:c:d:f:l:m:o:p:r:s:t:",
|
||||
&a,&c,&d,&f,&l,&m,&o,&p,&r,&s,&t);
|
||||
if (option_mask & 0x001) limita = bb_xgetularg10(a); // -a
|
||||
if (option_mask & 0x002) limitc = bb_xgetularg10(c); // -c
|
||||
if (option_mask & 0x004) limitd = bb_xgetularg10(d); // -d
|
||||
if (option_mask & 0x008) limitf = bb_xgetularg10(f); // -f
|
||||
if (option_mask & 0x010) limitl = bb_xgetularg10(l); // -l
|
||||
if (option_mask & 0x020) limits = limitl = limita = limitd = bb_xgetularg10(m); // -m
|
||||
if (option_mask & 0x040) limito = bb_xgetularg10(o); // -o
|
||||
if (option_mask & 0x080) limitp = bb_xgetularg10(p); // -p
|
||||
if (option_mask & 0x100) limitr = bb_xgetularg10(r); // -r
|
||||
if (option_mask & 0x200) limits = bb_xgetularg10(s); // -s
|
||||
if (option_mask & 0x400) limitt = bb_xgetularg10(t); // -t
|
||||
if (option_mask32 & 0x001) limita = bb_xgetularg10(a); // -a
|
||||
if (option_mask32 & 0x002) limitc = bb_xgetularg10(c); // -c
|
||||
if (option_mask32 & 0x004) limitd = bb_xgetularg10(d); // -d
|
||||
if (option_mask32 & 0x008) limitf = bb_xgetularg10(f); // -f
|
||||
if (option_mask32 & 0x010) limitl = bb_xgetularg10(l); // -l
|
||||
if (option_mask32 & 0x020) limits = limitl = limita = limitd = bb_xgetularg10(m); // -m
|
||||
if (option_mask32 & 0x040) limito = bb_xgetularg10(o); // -o
|
||||
if (option_mask32 & 0x080) limitp = bb_xgetularg10(p); // -p
|
||||
if (option_mask32 & 0x100) limitr = bb_xgetularg10(r); // -r
|
||||
if (option_mask32 & 0x200) limits = bb_xgetularg10(s); // -s
|
||||
if (option_mask32 & 0x400) limitt = bb_xgetularg10(t); // -t
|
||||
argv += optind;
|
||||
if (!argv[0]) bb_show_usage();
|
||||
slimit();
|
||||
|
@ -55,7 +55,6 @@ static struct sockaddr_in remoteaddr;
|
||||
#endif
|
||||
|
||||
/* options */
|
||||
static unsigned option_mask;
|
||||
/* Correct regardless of combination of CONFIG_xxx */
|
||||
enum {
|
||||
OPTBIT_mark = 0, // -m
|
||||
@ -298,7 +297,7 @@ static void message(char *fmt, ...)
|
||||
fl.l_len = 1;
|
||||
|
||||
#ifdef CONFIG_FEATURE_IPC_SYSLOG
|
||||
if ((option_mask & OPT_circularlog) && shbuf) {
|
||||
if ((option_mask32 & OPT_circularlog) && shbuf) {
|
||||
char b[1024];
|
||||
|
||||
va_start(arguments, fmt);
|
||||
@ -404,7 +403,7 @@ static void logMessage(int pri, char *msg)
|
||||
/* todo: supress duplicates */
|
||||
|
||||
#ifdef CONFIG_FEATURE_REMOTE_LOG
|
||||
if (option_mask & OPT_remotelog) {
|
||||
if (option_mask32 & OPT_remotelog) {
|
||||
char line[MAXLINE + 1];
|
||||
/* trying connect the socket */
|
||||
if (-1 == remotefd) {
|
||||
@ -419,12 +418,12 @@ static void logMessage(int pri, char *msg)
|
||||
}
|
||||
}
|
||||
|
||||
if (option_mask & OPT_locallog)
|
||||
if (option_mask32 & OPT_locallog)
|
||||
#endif
|
||||
{
|
||||
/* now spew out the message to wherever it is supposed to go */
|
||||
if (pri == 0 || LOG_PRI(pri) < logLevel) {
|
||||
if (option_mask & OPT_small)
|
||||
if (option_mask32 & OPT_small)
|
||||
message("%s %s\n", timestamp, msg);
|
||||
else
|
||||
message("%s %s %s %s\n", timestamp, LocalHostName, res, msg);
|
||||
@ -531,7 +530,7 @@ static void doSyslogd(void)
|
||||
if (chmod(lfile, 0666) < 0) {
|
||||
bb_perror_msg_and_die("cannot set permission on %s", lfile);
|
||||
}
|
||||
if (ENABLE_FEATURE_IPC_SYSLOG && (option_mask & OPT_circularlog)) {
|
||||
if (ENABLE_FEATURE_IPC_SYSLOG && (option_mask32 & OPT_circularlog)) {
|
||||
ipcsyslog_init();
|
||||
}
|
||||
|
||||
@ -575,26 +574,26 @@ int syslogd_main(int argc, char **argv)
|
||||
char *p;
|
||||
|
||||
/* do normal option parsing */
|
||||
option_mask = getopt32(argc, argv, OPTION_STR, OPTION_PARAM);
|
||||
if (option_mask & OPT_mark) MarkInterval = atoi(opt_m) * 60; // -m
|
||||
//if (option_mask & OPT_nofork) // -n
|
||||
//if (option_mask & OPT_outfile) // -O
|
||||
if (option_mask & OPT_loglevel) { // -l
|
||||
getopt32(argc, argv, OPTION_STR, OPTION_PARAM);
|
||||
if (option_mask32 & OPT_mark) MarkInterval = atoi(opt_m) * 60; // -m
|
||||
//if (option_mask32 & OPT_nofork) // -n
|
||||
//if (option_mask32 & OPT_outfile) // -O
|
||||
if (option_mask32 & OPT_loglevel) { // -l
|
||||
logLevel = atoi(opt_l);
|
||||
/* Valid levels are between 1 and 8 */
|
||||
if (logLevel < 1 || logLevel > 8)
|
||||
bb_show_usage();
|
||||
}
|
||||
//if (option_mask & OPT_small) // -S
|
||||
//if (option_mask32 & OPT_small) // -S
|
||||
#if ENABLE_FEATURE_ROTATE_LOGFILE
|
||||
if (option_mask & OPT_filesize) logFileSize = atoi(opt_s) * 1024; // -s
|
||||
if (option_mask & OPT_rotatecnt) { // -b
|
||||
if (option_mask32 & OPT_filesize) logFileSize = atoi(opt_s) * 1024; // -s
|
||||
if (option_mask32 & OPT_rotatecnt) { // -b
|
||||
logFileRotate = atoi(opt_b);
|
||||
if (logFileRotate > 99) logFileRotate = 99;
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_FEATURE_REMOTE_LOG
|
||||
if (option_mask & OPT_remotelog) { // -R
|
||||
if (option_mask32 & OPT_remotelog) { // -R
|
||||
int port = 514;
|
||||
char *host = xstrdup(opt_R);
|
||||
p = strchr(host, ':');
|
||||
@ -608,10 +607,10 @@ int syslogd_main(int argc, char **argv)
|
||||
remoteaddr.sin_port = htons(port);
|
||||
free(host);
|
||||
}
|
||||
//if (option_mask & OPT_locallog) // -L
|
||||
//if (option_mask32 & OPT_locallog) // -L
|
||||
#endif
|
||||
#if ENABLE_FEATURE_IPC_SYSLOG
|
||||
if (option_mask & OPT_circularlog) { // -C
|
||||
if (option_mask32 & OPT_circularlog) { // -C
|
||||
if (opt_C) {
|
||||
int buf_size = atoi(opt_C);
|
||||
if (buf_size >= 4)
|
||||
@ -621,8 +620,8 @@ int syslogd_main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
/* If they have not specified remote logging, then log locally */
|
||||
if (ENABLE_FEATURE_REMOTE_LOG && !(option_mask & OPT_remotelog))
|
||||
option_mask |= OPT_locallog;
|
||||
if (ENABLE_FEATURE_REMOTE_LOG && !(option_mask32 & OPT_remotelog))
|
||||
option_mask32 |= OPT_locallog;
|
||||
|
||||
/* Store away localhost's name before the fork */
|
||||
gethostname(LocalHostName, sizeof(LocalHostName));
|
||||
@ -633,7 +632,7 @@ int syslogd_main(int argc, char **argv)
|
||||
|
||||
umask(0);
|
||||
|
||||
if (!(option_mask & OPT_nofork)) {
|
||||
if (!(option_mask32 & OPT_nofork)) {
|
||||
#ifdef BB_NOMMU
|
||||
vfork_daemon_rexec(0, 1, argc, argv, "-n");
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user