Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/fish This patch makes fish(6) honour PAGER for viewing...
details: https://anonhg.NetBSD.org/src/rev/1f3cd48bd73b
branches: trunk
changeset: 474650:1f3cd48bd73b
user: hubertf <hubertf%NetBSD.org@localhost>
date: Wed Jul 14 17:30:21 1999 +0000
description:
This patch makes fish(6) honour PAGER for viewing the instructions.
The detailed behaviour follows POSIX.2. A similar patch for wump(6)
which was accepted is in bin/6699. Fish does not need any setgid
privileges it gets from dm, so this patch also moves the gid resetting
earlier.
Reported in PR 7986 by Joseph Myers <jsm28%cam.ac.uk@localhost>
diffstat:
games/fish/fish.c | 24 ++++++++++++++++++------
1 files changed, 18 insertions(+), 6 deletions(-)
diffs (59 lines):
diff -r b0a3af1f390a -r 1f3cd48bd73b games/fish/fish.c
--- a/games/fish/fish.c Wed Jul 14 17:23:53 1999 +0000
+++ b/games/fish/fish.c Wed Jul 14 17:30:21 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fish.c,v 1.7 1999/04/24 22:09:06 kristerw Exp $ */
+/* $NetBSD: fish.c,v 1.8 1999/07/14 17:30:21 hubertf Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -46,7 +46,7 @@
#if 0
static char sccsid[] = "@(#)fish.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: fish.c,v 1.7 1999/04/24 22:09:06 kristerw Exp $");
+__RCSID("$NetBSD: fish.c,v 1.8 1999/07/14 17:30:21 hubertf Exp $");
#endif
#endif /* not lint */
@@ -104,6 +104,8 @@
{
int ch, move;
+ setgid(getgid());
+
while ((ch = getopt(argc, argv, "p")) != -1)
switch(ch) {
case 'p':
@@ -450,6 +452,8 @@
{
int input;
pid_t pid;
+ int fd;
+ const char *pager;
int status;
(void)printf("Would you like instructions (y or n)? ");
@@ -460,10 +464,18 @@
switch (pid = fork()) {
case 0: /* child */
- (void)setuid(getuid());
- (void)setgid(getgid());
- (void)execl(_PATH_MORE, "more", _PATH_INSTR, NULL);
- err(1, "%s %s", _PATH_MORE, _PATH_INSTR);
+ if (!isatty(1))
+ pager = "cat";
+ else {
+ if (!(pager = getenv("PAGER")) || (*pager == 0))
+ pager = _PATH_MORE;
+ }
+ if ((fd = open(_PATH_INSTR, O_RDONLY)) == -1)
+ err(1, "open %s", _PATH_INSTR);
+ if (dup2(fd, 0) == -1)
+ err(1, "dup2");
+ (void)execl("/bin/sh", "sh", "-c", pager, NULL);
+ err(1, "exec sh -c %s", pager);
/*NOTREACHED*/
case -1:
err(1, "fork");
Home |
Main Index |
Thread Index |
Old Index