blob: 08ce8b08d5906f5fd99cfbdee5f882777defb548 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
$NetBSD: patch-ad,v 1.2 2013/07/19 12:54:58 joerg Exp $
--- misc.c.orig 2007-04-01 17:56:30.000000000 +0000
+++ misc.c
@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <string.h>
#include <signal.h>
+#include <termios.h>
#ifdef HAVE_TERMIO_H
@@ -108,8 +109,17 @@ int win; /* 0 for upper, 1 for lower */
/* "touch" the tty so 'w' reports proper idle times */
(void) utime(get_ttyname(), NULL);
+ /* Set our gid to our real gid if necessary */
+ if (setgid(getgid()) != 0) {
+ perror("setgid");
+ exit(EXIT_FAILURE);
+ }
+
/* Set our uid to our real uid if necessary */
- (void) setuid(getuid());
+ if (setuid(getuid()) != 0) {
+ perror("setgid");
+ exit(EXIT_FAILURE);
+ }
/* Run the requested program, with possible leading dash. */
execvp(((*argv[0] == '-') ? argv[0]+1 : argv[0]), argv);
@@ -876,8 +886,17 @@ char *type;
}
close(pipe_fds[0]); close(pipe_fds[1]);
+ /* Set our gid to our real gid if necessary */
+ if (setgid(getgid()) != 0) {
+ perror("setgid");
+ exit(EXIT_FAILURE);
+ }
+
/* Set our uid to our real uid if necessary */
- (void) setuid(getuid());
+ if (setuid(getuid()) != 0) {
+ perror("setuid");
+ exit(EXIT_FAILURE);
+ }
/* Run the requested program */
argv[0]="/bin/sh";
|