diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2004-03-31 19:12:23 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2004-03-31 19:12:23 +0000 |
commit | 7b658f969738eb7ab20fe70aaca5297581c1314e (patch) | |
tree | b10c8fcc896155b292e18150e643b9c30ccad147 | |
parent | 56b73e67770f6fa5d8c4a770c5ac26a66ae5df9a (diff) |
For non-internal services, if no program arguments are specified use
the program's basename as argv[0]. Problem found by mpech@.
OK deraadt@ beck@
-rw-r--r-- | usr.sbin/inetd/inetd.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c index 73e8a2d1e9e..b0598034dbe 100644 --- a/usr.sbin/inetd/inetd.c +++ b/usr.sbin/inetd/inetd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inetd.c,v 1.115 2004/01/06 19:45:54 millert Exp $ */ +/* $OpenBSD: inetd.c,v 1.116 2004/03/31 19:12:22 millert Exp $ */ /* * Copyright (c) 1983,1991 The Regents of the University of California. @@ -37,7 +37,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)inetd.c 5.30 (Berkeley) 6/3/91";*/ -static char rcsid[] = "$OpenBSD: inetd.c,v 1.115 2004/01/06 19:45:54 millert Exp $"; +static char rcsid[] = "$OpenBSD: inetd.c,v 1.116 2004/03/31 19:12:22 millert Exp $"; #endif /* not lint */ /* @@ -1331,6 +1331,13 @@ more: if (argc < MAXARGV) sep->se_argv[argc++] = newstr(arg); } + if (argc == 0 && sep->se_bi == NULL) { + if ((arg = strrchr(sep->se_server, '/')) != NULL) + arg++; + else + arg = sep->se_server; + sep->se_argv[argc++] = newstr(arg); + } while (argc <= MAXARGV) sep->se_argv[argc++] = NULL; @@ -2009,7 +2016,7 @@ spawn(struct servtab *sep, int ctrl) } } if (debug) - fprintf(stderr, "%ld execl %s\n", + fprintf(stderr, "%ld execv %s\n", (long)getpid(), sep->se_server); if (ctrl != STDIN_FILENO) { dup2(ctrl, STDIN_FILENO); |