1 --- pconsole-1.1/pconsole.c 2018-08-19 13:30:22.000000000 +0000
2 +++ pconsole-1.1/pconsole.c 2019-07-21 05:29:54.242138304 +0000
8 +#include "sys/termios.h"
16 @@ -163,9 +166,7 @@ Conn *c, *c_next;
20 - seteuid(0); /* regain root privs */
21 if (ioctl(c->fd, TIOCSTI, &kar) == -1) { /* simulate terminal input */
22 - seteuid(getuid()); /* drop root privs again */
23 printf("\nioctl() : %s\n", strerror(errno));
24 if (c->hostname != NULL)
25 printf("detaching from %s#%s\n", c->hostname, c->dev);
26 @@ -173,8 +174,7 @@ Conn *c, *c_next;
27 printf("detaching from %s\n", c->dev);
31 - seteuid(getuid()); /* drop the root privs */
36 @@ -188,19 +188,34 @@ RETSIGTYPE sig_exit(int sig) {
39 int main(int argc, char **argv) {
41 - fprintf(stderr, "You must be root to run this program or this program should be setuid root.\n");
44 - if (seteuid(getuid())) { /* drop root privs */
45 - fprintf(stderr, "failed to drop root privileges\n");
48 + priv_set_t *privset = NULL;
50 + if ((privset = priv_allocset()) == NULL) {
51 + fprintf(stderr, "couldn't allocate privilege\n");
55 + if (getppriv(PRIV_EFFECTIVE, privset) < 0) {
56 + fprintf(stderr, "couldn't get privilege\n");
60 + if (priv_isfullset(privset) != B_TRUE) {
61 + fprintf(stderr, "You must be root or granted the \"Parallel Console Access\" rights profile.\n");
64 + priv_freeset(privset);
66 + if ((argc > 1) && (!strcmp(argv[1],"-t"))) {
70 if (!isatty(fileno(stdin))) {
71 fprintf(stderr, "pconsole: not a tty\n");
74 - printf("pconsole WJ101\n");
75 + printf("pconsole 1.0\n");
77 signal(SIGTERM, sig_exit);
78 signal(SIGINT, sig_exit);