patches/gnome-system-tools-02-forkpty.diff
author rohinis
Tue, 29 Nov 2011 17:32:55 +0000
branchs11express-2010-11
changeset 22234 c23e64da3e06
parent 15569 f5ee708e987d
child 21149 fa4e4a07e832
child 21308 9a98b77f065c
permissions -rw-r--r--
2011-11-29 Rohini S <[email protected]> * patches/Python26-22-audio.diff: Fixes CVE-2010-1634 * specs/SUNWPython26.spec: Fixes CR 7085446
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9235
b2a55defbb7e 2007-02-09 Jim Li <[email protected]>
jim
parents: 8394
diff changeset
     1
--- gnome-system-tools-2.14.0.orig/src/common/gst-auth.c	2006-01-31 06:40:32.000000000 +0800
14761
ada30a14249c 2008-12-12 Jim Li <[email protected]>
jim
parents: 9235
diff changeset
     2
+++ gnome-system-tools-2.14.0/src/common/gst-auth.c	2008-12-12 14:10:17.161439000 +0800
9235
b2a55defbb7e 2007-02-09 Jim Li <[email protected]>
jim
parents: 8394
diff changeset
     3
@@ -43,16 +43,30 @@
7859
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
     4
 #ifdef __FreeBSD__
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
     5
 # include <errno.h>
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
     6
 # include <libutil.h>
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
     7
+#elif defined(__sun)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
     8
+#include <fcntl.h>
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
     9
+#include <unistd.h>
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    10
+#include <stdlib.h>
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    11
+#include <sys/ioctl.h>
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    12
+#include <sys/stream.h>
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    13
+#include <sys/stropts.h>
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    14
 #else
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    15
 #include <pty.h>
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    16
 #endif
8394
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
    17
 
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
    18
+#include <gksu.h>
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
    19
+#include <gksuui-dialog.h>
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
    20
+
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
    21
 #include "gst-auth.h"
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
    22
 #include "gst-tool.h"
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
    23
 #include "gst-platform.h"
7859
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    24
 
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    25
 #define GST_AUTH_RESPONSE_NP 1
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    26
 
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    27
+#ifdef __sun
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    28
+#define EMBEDDED_SU "/usr/lib/embedded_su"
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    29
+#endif /* __sun */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    30
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    31
 static int root;			/* if we are root, no password is
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    32
 					   required */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    33
 
8394
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
    34
@@ -118,6 +132,122 @@
7859
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    35
 	return TRUE;	
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    36
 }
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    37
 
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    38
+#ifdef __sun
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    39
+/* forkpty() rmplacement for Solaris.
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    40
+ * This ignore the last two arguments
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    41
+ * for the moment
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    42
+ */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    43
+#ifdef NOPTY
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    44
+/*
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    45
+ * This is implemented using pipes instead of pseudo tty to avoid
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    46
+ * bug 4907342.
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    47
+ */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    48
+static
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    49
+int forkpty (int *amaster, char *name, void *unused1, void *unused2)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    50
+{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    51
+	pid_t pid;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    52
+	int pp[2];
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    53
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    54
+	pipe (pp);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    55
+	pid = fork ();
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    56
+	switch (pid)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    57
+	{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    58
+	case -1: /* Error */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    59
+		return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    60
+	case 0: /* Child */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    61
+		if (setsid() < 0)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    62
+			return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    63
+		close (pp[1]);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    64
+		dup2 (pp[0], 0);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    65
+		return 0;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    66
+	default: /* Parent */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    67
+		close (pp[0]);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    68
+		*amaster = pp[1];
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    69
+		return pid;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    70
+	}
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    71
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    72
+	return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    73
+}
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    74
+#else
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    75
+int forkpty (int *amaster, char *name, void *unused1, void *unused2)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    76
+{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    77
+	int master, slave, fd;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    78
+	char *slave_name;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    79
+	pid_t pid;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    80
+	void (*sig_saved)(int);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    81
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    82
+	master = open("/dev/ptmx", O_RDWR | O_NOCTTY);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    83
+	if (master < 0)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    84
+		return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    85
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    86
+	sig_saved = signal (SIGCHLD, SIG_DFL);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    87
+	if (grantpt (master) < 0)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    88
+	{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    89
+		signal (SIGCHLD, sig_saved);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    90
+		close (master);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    91
+		return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    92
+	}
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    93
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    94
+	if (unlockpt (master) < 0)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    95
+	{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    96
+		signal (SIGCHLD, sig_saved);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    97
+		close (master);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    98
+		return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    99
+	}
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   100
+	signal (SIGCHLD, sig_saved);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   101
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   102
+	slave_name = ptsname (master);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   103
+	if (slave_name == NULL)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   104
+	{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   105
+		close (master);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   106
+		return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   107
+	}
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   108
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   109
+	slave = open (slave_name, O_RDWR | O_NOCTTY);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   110
+	if (slave < 0)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   111
+	{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   112
+		close (master);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   113
+		return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   114
+	}
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   115
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   116
+	if (ioctl (slave, I_PUSH, "ptem") < 0
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   117
+	    || ioctl (slave, I_PUSH, "ldterm") < 0
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   118
+	    || ioctl (slave, I_PUSH, "ttcompat") < 0)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   119
+	{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   120
+		close (slave);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   121
+		close (master);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   122
+		return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   123
+	}
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   124
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   125
+	if (amaster)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   126
+		*amaster = master;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   127
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   128
+	if (name)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   129
+		strcpy (name, slave_name);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   130
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   131
+	pid = fork ();
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   132
+	switch (pid)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   133
+	{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   134
+	case -1: /* Error */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   135
+		return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   136
+	case 0: /* Child */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   137
+		if (setsid() < 0)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   138
+			return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   139
+		close (master);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   140
+		dup2 (slave, STDIN_FILENO);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   141
+		dup2 (slave, STDOUT_FILENO);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   142
+		dup2 (slave, STDERR_FILENO);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   143
+		return 0;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   144
+	default: /* Parent */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   145
+		close (slave);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   146
+		return pid;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   147
+	}
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   148
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   149
+	return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   150
+}
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   151
+#endif
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   152
+#endif
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   153
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   154
 /* runs a term with su in it */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   155
 static void
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   156
 gst_auth_run_term (GstTool *tool, gchar *args[])
8394
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   157
@@ -177,8 +307,15 @@
7859
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   158
 	gchar        *s, *str;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   159
 	gint          ret;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   160
 
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   161
+#if defined(__sun) && defined (EMBEDDED_SU)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   162
+        gst_tool_write_to_backend(tool, (gchar*)".\n"); /* Send empty text block to start conversation */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   163
+#endif
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   164
 	while (!cont) {
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   165
+#if defined(__sun) && defined (EMBEDDED_SU)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   166
+		s   = gst_tool_read_from_backend (tool, "SUCCESS", "\n.\n", NULL); /* Look for end of text block - a period (.) on a line by itself */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   167
+#else
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   168
 		s   = gst_tool_read_from_backend (tool, "assword:", "/no)?", "\n", NULL);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   169
+#endif /* __sun */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   170
 		str = g_ascii_strup (s, -1);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   171
 
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   172
 		/* FIXME: hope that someday we can get rid of this ssh output string parsing */
8394
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   173
@@ -189,6 +326,11 @@
7859
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   174
 			/* it's asking for the password */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   175
 			cont = TRUE;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   176
 			ret  = GST_AUTH_PASSWORD;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   177
+#if defined(__sun) && defined (EMBEDDED_SU)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   178
+		} else if (g_strrstr (str, "SUCCESS") != NULL) {
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   179
+			cont = TRUE;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   180
+			ret  = GST_AUTH_PASSWORDLESS;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   181
+#endif /* __sun */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   182
 		} else if (g_strrstr (str, "\n") != NULL) {
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   183
 			/* this is the last case to test, it's the CR
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   184
 			   used to synchronize communication */
15569
f5ee708e987d 2009-04-06 Takao Fujiwara <[email protected]>
fujiwara
parents: 14771
diff changeset
   185
@@ -286,7 +428,77 @@
8394
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   186
 	gchar *password;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   187
 	gint result;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   188
 	struct termios t;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   189
+	GksuContext *context;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   190
+	GError *error = NULL;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   191
+	GtkWidget *gksuui_dialog;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   192
+	gint response;
14761
ada30a14249c 2008-12-12 Jim Li <[email protected]>
jim
parents: 9235
diff changeset
   193
+	gchar *primary_text   = NULL;
ada30a14249c 2008-12-12 Jim Li <[email protected]>
jim
parents: 9235
diff changeset
   194
+	gchar *secondary_text = NULL;
ada30a14249c 2008-12-12 Jim Li <[email protected]>
jim
parents: 9235
diff changeset
   195
+
9235
b2a55defbb7e 2007-02-09 Jim Li <[email protected]>
jim
parents: 8394
diff changeset
   196
+
8394
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   197
+#ifdef HAVE_GKSU
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   198
+	context = gksu_context_new ();
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   199
+#ifdef GST_DEBUG
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   200
+	gksu_context_set_debug (context, TRUE);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   201
+#endif
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   202
+	gksu_context_set_command (context, args[3]);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   203
+	gksu_context_set_wait_for_child_to_exit (context, FALSE);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   204
+      	if (gksu_context_try_need_password (context) )
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   205
+	{
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   206
+	  password = NULL;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   207
+	  gchar *pw_prompt = NULL;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   208
+	  gksuui_dialog = gksuui_dialog_new ();
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   209
+	  gksuui_dialog_set_message (GKSUUI_DIALOG(gksuui_dialog), 
15569
f5ee708e987d 2009-04-06 Takao Fujiwara <[email protected]>
fujiwara
parents: 14771
diff changeset
   210
+			   /* SUN_BRANDING */
f5ee708e987d 2009-04-06 Takao Fujiwara <[email protected]>
fujiwara
parents: 14771
diff changeset
   211
+			   g_strdup_printf(_("<b>You need %s privileges to use this tool. "
f5ee708e987d 2009-04-06 Takao Fujiwara <[email protected]>
fujiwara
parents: 14771
diff changeset
   212
+					"Enter a password to modify your system configuration.</b>"),
8394
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   213
+					context->user));
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   214
+	  gtk_widget_show (gksuui_dialog);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   215
+
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   216
+	  response = gtk_dialog_run (GTK_DIALOG(gksuui_dialog));
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   217
+ 	  
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   218
+	  switch (response) {
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   219
+	  case GTK_RESPONSE_OK:
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   220
+		break;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   221
+	  default:
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   222
+		/* Cancel */
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   223
+		exit (0);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   224
+		break;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   225
+	  }
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   226
+#ifdef GST_DEBUG
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   227
+	  fprintf (stderr, "response ID: %d\n", response);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   228
+#endif	
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   229
+	  password = gksuui_dialog_get_password (GKSUUI_DIALOG(gksuui_dialog));
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   230
+	  gtk_widget_destroy ( gksuui_dialog );
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   231
+	  gksu_context_set_password (context, password);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   232
+	}
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   233
+      
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   234
+      error = NULL;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   235
+      gksu_context_run (context, &error);
14761
ada30a14249c 2008-12-12 Jim Li <[email protected]>
jim
parents: 9235
diff changeset
   236
+
ada30a14249c 2008-12-12 Jim Li <[email protected]>
jim
parents: 9235
diff changeset
   237
+      if (error)
ada30a14249c 2008-12-12 Jim Li <[email protected]>
jim
parents: 9235
diff changeset
   238
+	{
14771
dbd1ae1f64ec 2008-12-15 Takao Fujiwara <[email protected]>
fujiwara
parents: 14761
diff changeset
   239
+	  /* SUN_BRANDING */
14761
ada30a14249c 2008-12-12 Jim Li <[email protected]>
jim
parents: 9235
diff changeset
   240
+	  primary_text   = g_strdup_printf (_("Authentication fails"));
ada30a14249c 2008-12-12 Jim Li <[email protected]>
jim
parents: 9235
diff changeset
   241
+	  secondary_text = g_strdup (error->message);
ada30a14249c 2008-12-12 Jim Li <[email protected]>
jim
parents: 9235
diff changeset
   242
+
ada30a14249c 2008-12-12 Jim Li <[email protected]>
jim
parents: 9235
diff changeset
   243
+	  gst_auth_display_error_message (tool, primary_text, secondary_text);
ada30a14249c 2008-12-12 Jim Li <[email protected]>
jim
parents: 9235
diff changeset
   244
+
ada30a14249c 2008-12-12 Jim Li <[email protected]>
jim
parents: 9235
diff changeset
   245
+	  g_free (primary_text);
ada30a14249c 2008-12-12 Jim Li <[email protected]>
jim
parents: 9235
diff changeset
   246
+	  g_free (secondary_text);
ada30a14249c 2008-12-12 Jim Li <[email protected]>
jim
parents: 9235
diff changeset
   247
+	  exit (0);
ada30a14249c 2008-12-12 Jim Li <[email protected]>
jim
parents: 9235
diff changeset
   248
+	}
ada30a14249c 2008-12-12 Jim Li <[email protected]>
jim
parents: 9235
diff changeset
   249
 
8394
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   250
+      tool->read_fd = gksu_context_get_child_stdin_fd (context);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   251
+      tool->write_fd = gksu_context_get_child_stdout_fd (context);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   252
+      tool->backend_pid = gksu_context_get_child_pid (context);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   253
+      tool->timeout_id   = g_timeout_add (1000, (GSourceFunc) gst_auth_wait_child, tool);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   254
+#ifdef GST_DEBUG
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   255
+      fprintf (stderr, "read_fd = %d, write_fd = %d\n", tool->read_fd, tool->write_fd);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   256
+#endif
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   257
+      tool->read_stream = gksu_context_get_child_stdin_file (context);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   258
+      tool->write_stream = gksu_context_get_child_stdout_file (context);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   259
+#else
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   260
 	gst_auth_run_term (tool, args);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   261
 	result = gst_auth_get_auth_required (tool);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   262
 
15569
f5ee708e987d 2009-04-06 Takao Fujiwara <[email protected]>
fujiwara
parents: 14771
diff changeset
   263
@@ -296,7 +508,14 @@
7859
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   264
 
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   265
 		if (strlen (password) > 0)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   266
 			memset (password, 0, strlen (password));
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   267
+#if defined(__sun) && defined (EMBEDDED_SU) && 0
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   268
+                {
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   269
+                    gchar *s  = gst_tool_read_from_backend (tool, "\n.\n", "SUCCESS", "\n", NULL);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   270
+                    g_free(s);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   271
+                }
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   272
+#endif /* __sun */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   273
 	}
8394
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   274
+#endif
7859
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   275
 
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   276
 	tool->root_access = ROOT_ACCESS_REAL;
8394
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   277
 
15569
f5ee708e987d 2009-04-06 Takao Fujiwara <[email protected]>
fujiwara
parents: 14771
diff changeset
   278
@@ -368,7 +587,7 @@
8394
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   279
 	GString *command;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   280
 
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   281
 	command = g_string_new (NULL);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   282
-	gst_auth_save_locale   (command);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   283
+//	gst_auth_save_locale   (command);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   284
 	command = g_string_append (command, tool->script_path);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   285
 	command = g_string_append (command, " --report");
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   286
 
15569
f5ee708e987d 2009-04-06 Takao Fujiwara <[email protected]>
fujiwara
parents: 14771
diff changeset
   287
@@ -378,7 +597,11 @@
7859
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   288
 	}
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   289
 
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   290
 	/* these are the su args */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   291
+#if defined(__sun) && defined (EMBEDDED_SU)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   292
+	su_args[0] = EMBEDDED_SU;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   293
+#else
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   294
 	su_args[0] = SU_PATH;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   295
+#endif /* __sun */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   296
 	su_args[1] = "root";
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   297
 	su_args[2] = "-c";
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   298
 	su_args[3] = command->str;