telnetd: getopt_ulflags'isation
This commit is contained in:
parent
109d21fe74
commit
0e87d347e8
@ -362,23 +362,16 @@ free_session(struct tsession *ts)
|
|||||||
int
|
int
|
||||||
telnetd_main(int argc, char **argv)
|
telnetd_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_FEATURE_TELNETD_INETD
|
unsigned long opt;
|
||||||
sockaddr_type sa;
|
|
||||||
int master_fd;
|
|
||||||
#endif /* CONFIG_FEATURE_TELNETD_INETD */
|
|
||||||
fd_set rdfdset, wrfdset;
|
fd_set rdfdset, wrfdset;
|
||||||
int selret;
|
int selret;
|
||||||
#ifndef CONFIG_FEATURE_TELNETD_INETD
|
#ifndef CONFIG_FEATURE_TELNETD_INETD
|
||||||
|
sockaddr_type sa;
|
||||||
|
int master_fd;
|
||||||
int on = 1;
|
int on = 1;
|
||||||
int portnbr = 23;
|
int portnbr = 23;
|
||||||
struct in_addr bind_addr = { .s_addr = 0x0 };
|
struct in_addr bind_addr = { .s_addr = 0x0 };
|
||||||
#endif /* CONFIG_FEATURE_TELNETD_INETD */
|
char *opt_portnbr, *opt_bindaddr;
|
||||||
int c;
|
|
||||||
static const char options[] =
|
|
||||||
#ifdef CONFIG_FEATURE_TELNETD_INETD
|
|
||||||
"f:l:";
|
|
||||||
#else /* CONFIG_EATURE_TELNETD_INETD */
|
|
||||||
"f:l:p:b:";
|
|
||||||
#endif /* CONFIG_FEATURE_TELNETD_INETD */
|
#endif /* CONFIG_FEATURE_TELNETD_INETD */
|
||||||
int maxlen, w, r;
|
int maxlen, w, r;
|
||||||
|
|
||||||
@ -394,29 +387,16 @@ telnetd_main(int argc, char **argv)
|
|||||||
openlog(bb_applet_name, 0, LOG_USER);
|
openlog(bb_applet_name, 0, LOG_USER);
|
||||||
logmode = LOGMODE_SYSLOG;
|
logmode = LOGMODE_SYSLOG;
|
||||||
|
|
||||||
for (;;) {
|
opt = bb_getopt_ulflags(argc, argv, "f:l:" USE_FEATURE_TELNETD_INETD("p:b:"),
|
||||||
c = getopt( argc, argv, options);
|
&issuefile, &loginpath
|
||||||
if (c == EOF) break;
|
SKIP_FEATURE_TELNETD_INETD(, &opt_portnbr, &opt_bindaddr));
|
||||||
switch (c) {
|
//if (opt & 1) // -f
|
||||||
case 'f':
|
//if (opt & 2) // -l
|
||||||
issuefile = optarg;
|
|
||||||
break;
|
|
||||||
case 'l':
|
|
||||||
loginpath = optarg;
|
|
||||||
break;
|
|
||||||
#ifndef CONFIG_FEATURE_TELNETD_INETD
|
#ifndef CONFIG_FEATURE_TELNETD_INETD
|
||||||
case 'p':
|
if (opt & 4) portnbr = atoi(opt_portnbr); // -p
|
||||||
portnbr = atoi(optarg);
|
if (opt & 8) // -b
|
||||||
break;
|
if (inet_aton(opt_bindaddr, &bind_addr) == 0) bb_show_usage();
|
||||||
case 'b':
|
|
||||||
if (inet_aton(optarg, &bind_addr) == 0)
|
|
||||||
bb_show_usage();
|
|
||||||
break;
|
|
||||||
#endif /* CONFIG_FEATURE_TELNETD_INETD */
|
#endif /* CONFIG_FEATURE_TELNETD_INETD */
|
||||||
default:
|
|
||||||
bb_show_usage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (access(loginpath, X_OK) < 0) {
|
if (access(loginpath, X_OK) < 0) {
|
||||||
bb_error_msg_and_die("'%s' unavailable", loginpath);
|
bb_error_msg_and_die("'%s' unavailable", loginpath);
|
||||||
|
Loading…
Reference in New Issue
Block a user