patches/gnome-system-tools-02-forkpty.diff
author dcarbery
Fri, 24 Nov 2006 16:37:59 +0000
branch217update
changeset 19096 d542fc2c823e
parent 8394 bcd58bae020d
child 9235 b2a55defbb7e
permissions -rw-r--r--
Merged trunk changes r9797:9829 into 217update branch.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8394
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
     1
--- gnome-system-tools-2.14.0.orig/src/common/gst-auth.c	Tue Jan 31 06:40:32 2006
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
     2
+++ gnome-system-tools-2.14.0/src/common/gst-auth.c	Thu Oct 19 16:46:03 2006
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
     3
@@ -43,10 +43,20 @@
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"
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
    24
@@ -53,6 +63,10 @@
7859
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    25
 
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    26
 #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
    27
 
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    28
+#ifdef __sun
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    29
+#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
    30
+#endif /* __sun */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    31
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    32
 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
    33
 					   required */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    34
 
8394
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
    35
@@ -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
    36
 	return TRUE;	
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
 
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    39
+#ifdef __sun
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    40
+/* 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
    41
+ * 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
    42
+ * for the moment
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    43
+ */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    44
+#ifdef NOPTY
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    45
+/*
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    46
+ * 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
    47
+ * bug 4907342.
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    48
+ */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    49
+static
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    50
+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
    51
+{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    52
+	pid_t pid;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    53
+	int pp[2];
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    54
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    55
+	pipe (pp);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    56
+	pid = fork ();
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    57
+	switch (pid)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    58
+	{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    59
+	case -1: /* Error */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    60
+		return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    61
+	case 0: /* Child */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    62
+		if (setsid() < 0)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    63
+			return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    64
+		close (pp[1]);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    65
+		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
    66
+		return 0;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    67
+	default: /* Parent */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    68
+		close (pp[0]);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    69
+		*amaster = pp[1];
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    70
+		return pid;
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
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    73
+	return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    74
+}
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    75
+#else
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    76
+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
    77
+{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    78
+	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
    79
+	char *slave_name;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    80
+	pid_t pid;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    81
+	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
    82
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    83
+	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
    84
+	if (master < 0)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    85
+		return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    86
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    87
+	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
    88
+	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
    89
+	{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    90
+		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
    91
+		close (master);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    92
+		return -1;
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
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    95
+	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
    96
+	{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    97
+		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
    98
+		close (master);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
    99
+		return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   100
+	}
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   101
+	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
   102
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   103
+	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
   104
+	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
   105
+	{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   106
+		close (master);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   107
+		return -1;
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
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   110
+	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
   111
+	if (slave < 0)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   112
+	{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   113
+		close (master);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   114
+		return -1;
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
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   117
+	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
   118
+	    || 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
   119
+	    || 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
   120
+	{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   121
+		close (slave);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   122
+		close (master);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   123
+		return -1;
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
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   126
+	if (amaster)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   127
+		*amaster = master;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   128
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   129
+	if (name)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   130
+		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
   131
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   132
+	pid = fork ();
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   133
+	switch (pid)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   134
+	{
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   135
+	case -1: /* Error */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   136
+		return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   137
+	case 0: /* Child */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   138
+		if (setsid() < 0)
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   139
+			return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   140
+		close (master);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   141
+		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
   142
+		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
   143
+		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
   144
+		return 0;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   145
+	default: /* Parent */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   146
+		close (slave);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   147
+		return pid;
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
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   150
+	return -1;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   151
+}
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
+#endif
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   154
+
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   155
 /* 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
   156
 static void
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   157
 gst_auth_run_term (GstTool *tool, gchar *args[])
8394
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   158
@@ -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
   159
 	gchar        *s, *str;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   160
 	gint          ret;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   161
 
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   162
+#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
   163
+        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
   164
+#endif
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   165
 	while (!cont) {
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   166
+#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
   167
+		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
   168
+#else
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   169
 		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
   170
+#endif /* __sun */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   171
 		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
   172
 
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   173
 		/* 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
   174
@@ -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
   175
 			/* 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
   176
 			cont = TRUE;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   177
 			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
   178
+#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
   179
+		} 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
   180
+			cont = TRUE;
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   181
+			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
   182
+#endif /* __sun */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   183
 		} 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
   184
 			/* 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
   185
 			   used to synchronize communication */
8394
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   186
@@ -286,7 +428,61 @@
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   187
 	gchar *password;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   188
 	gint result;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   189
 	struct termios t;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   190
+	GksuContext *context;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   191
+	GError *error = NULL;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   192
+	GtkWidget *gksuui_dialog;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   193
+	gint response;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   194
 
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   195
+#ifdef HAVE_GKSU
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   196
+	context = gksu_context_new ();
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   197
+#ifdef GST_DEBUG
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   198
+	gksu_context_set_debug (context, TRUE);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   199
+#endif
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   200
+	gksu_context_set_command (context, args[3]);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   201
+	gksu_context_set_wait_for_child_to_exit (context, FALSE);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   202
+      	if (gksu_context_try_need_password (context) )
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   203
+	{
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   204
+	  password = NULL;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   205
+	  gchar *pw_prompt = NULL;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   206
+	  gksuui_dialog = gksuui_dialog_new ();
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   207
+	  gksuui_dialog_set_message (GKSUUI_DIALOG(gksuui_dialog), 
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   208
+			   g_strdup_printf("<b>You need %s privileges to use this tool. "
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   209
+					"Enter a password to modify your system configuration.</b>",
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   210
+					context->user));
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   211
+	  gtk_widget_show (gksuui_dialog);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   212
+
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   213
+	  response = gtk_dialog_run (GTK_DIALOG(gksuui_dialog));
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   214
+ 	  
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   215
+	  switch (response) {
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   216
+	  case GTK_RESPONSE_OK:
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   217
+		break;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   218
+	  default:
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   219
+		/* Cancel */
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   220
+		exit (0);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   221
+		break;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   222
+	  }
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   223
+#ifdef GST_DEBUG
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   224
+	  fprintf (stderr, "response ID: %d\n", response);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   225
+#endif	
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   226
+	  password = gksuui_dialog_get_password (GKSUUI_DIALOG(gksuui_dialog));
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   227
+	  gtk_widget_destroy ( gksuui_dialog );
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   228
+	  gksu_context_set_password (context, password);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   229
+	}
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   230
+      
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   231
+      error = NULL;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   232
+      gksu_context_run (context, &error);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   233
+      tool->read_fd = gksu_context_get_child_stdin_fd (context);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   234
+      tool->write_fd = gksu_context_get_child_stdout_fd (context);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   235
+      tool->backend_pid = gksu_context_get_child_pid (context);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   236
+      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
   237
+#ifdef GST_DEBUG
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   238
+      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
   239
+#endif
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   240
+      tool->read_stream = gksu_context_get_child_stdin_file (context);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   241
+      tool->write_stream = gksu_context_get_child_stdout_file (context);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   242
+      setvbuf ( tool->read_stream, NULL, _IONBF, 0);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   243
+      fcntl (tool->read_fd, F_SETFL, 0);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   244
+#else
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   245
 	gst_auth_run_term (tool, args);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   246
 	result = gst_auth_get_auth_required (tool);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   247
 
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   248
@@ -296,7 +492,14 @@
7859
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   249
 
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   250
 		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
   251
 			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
   252
+#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
   253
+                {
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   254
+                    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
   255
+                    g_free(s);
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   256
+                }
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   257
+#endif /* __sun */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   258
 	}
8394
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   259
+#endif
7859
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   260
 
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   261
 	tool->root_access = ROOT_ACCESS_REAL;
8394
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   262
 
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   263
@@ -368,7 +571,7 @@
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   264
 	GString *command;
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   265
 
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   266
 	command = g_string_new (NULL);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   267
-	gst_auth_save_locale   (command);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   268
+//	gst_auth_save_locale   (command);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   269
 	command = g_string_append (command, tool->script_path);
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   270
 	command = g_string_append (command, " --report");
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   271
 
bcd58bae020d 2006-10-21 Jim Li <[email protected]>
jim
parents: 7859
diff changeset
   272
@@ -378,7 +581,11 @@
7859
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   273
 	}
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   274
 
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   275
 	/* 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
   276
+#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
   277
+	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
   278
+#else
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   279
 	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
   280
+#endif /* __sun */
8517272aace0 Unbump gnome-system-tools back to 2.14.0. Other modules need work before it can
dc144907
parents:
diff changeset
   281
 	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
   282
 	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
   283
 	su_args[3] = command->str;