saned: parse inetd args in main()

move argument parsing logic from run_inetd() to main()
merge-requests/1/head
Matteo Croce 2015-09-20 19:55:36 +02:00 zatwierdzone przez Olaf Meeuwissen
rodzic 2c3cb206ce
commit a79cd0abe7
1 zmienionych plików z 10 dodań i 10 usunięć

Wyświetl plik

@ -3172,7 +3172,7 @@ run_standalone (char *user)
static void static void
run_inetd (int argc, char **argv) run_inetd (char *sock)
{ {
int fd = -1; int fd = -1;
@ -3238,18 +3238,13 @@ run_inetd (int argc, char **argv)
close (dave_null); close (dave_null);
} }
#ifndef HAVE_OS2_H #ifdef HAVE_OS2_H
/* Unused in this function */
argc = argc;
argv = argv;
#else
/* under OS/2, the socket handle is passed as argument on the command /* under OS/2, the socket handle is passed as argument on the command
line; the socket handle is relative to IBM TCP/IP, so a call line; the socket handle is relative to IBM TCP/IP, so a call
to impsockethandle() is required to add it to the EMX runtime */ to impsockethandle() is required to add it to the EMX runtime */
if (argc == 2) if (sock)
{ {
fd = _impsockhandle (atoi (argv[1]), 0); fd = _impsockhandle (atoi (sock), 0);
if (fd == -1) if (fd == -1)
perror ("impsockhandle"); perror ("impsockhandle");
} }
@ -3265,6 +3260,7 @@ main (int argc, char *argv[])
char options[64] = ""; char options[64] = "";
debug = DBG_WARN; debug = DBG_WARN;
char *user = NULL; char *user = NULL;
char *sock = NULL;
prog_name = strrchr (argv[0], '/'); prog_name = strrchr (argv[0], '/');
if (prog_name) if (prog_name)
@ -3351,7 +3347,11 @@ main (int argc, char *argv[])
} }
else else
{ {
run_inetd(argc, argv); #ifdef HAVE_OS2_H
if (argc == 2)
sock = argv[1];
#endif
run_inetd(sock);
} }
DBG (DBG_WARN, "saned exiting\n"); DBG (DBG_WARN, "saned exiting\n");