kov changed libgksu/trunk/libgksu/gksu-context.c
Gustavo Noronha
kov at costa.debian.org
Sat Apr 15 14:12:30 UTC 2006
Mensagem de log:
remove trailing whitespaces
-----
Modified: libgksu/trunk/libgksu/gksu-context.c
===================================================================
--- libgksu/trunk/libgksu/gksu-context.c 2006-04-08 09:10:56 UTC (rev 535)
+++ libgksu/trunk/libgksu/gksu-context.c 2006-04-15 14:12:28 UTC (rev 536)
@@ -111,7 +111,7 @@
* gksu_context_get_user:
* @context: the #GksuContext from which to grab the information
*
- * Gets the user the command will be run as, as set
+ * Gets the user the command will be run as, as set
* by gksu_context_set_user.
*
* Returns: a pointer to the string containing the username.
@@ -144,7 +144,7 @@
* gksu_context_get_command:
* @context: the #GksuContext from which to grab the information
*
- * Gets the command that will be run, as set by
+ * Gets the command that will be run, as set by
* gksu_context_set_command.
*
* Returns: a pointer to the string containing the command.
@@ -246,7 +246,7 @@
* Finds out if the environment in which the program will be
* run will be reset.
*
- * Returns: TRUE if the environment is going to be kept,
+ * Returns: TRUE if the environment is going to be kept,
* FALSE otherwise.
*/
gboolean
@@ -423,7 +423,7 @@
f = fopen(cmdfile, "r");
g_free (cmdfile);
- if(f != NULL)
+ if(f != NULL)
{
fgets(cmdline, 255, f);
cmdline[255] = '\0';
@@ -438,7 +438,7 @@
/**
* prepare_xauth:
*
- * Sets up the variables with values for the $DISPLAY
+ * Sets up the variables with values for the $DISPLAY
* environment variable and xauth-related stuff. Also
* creates a temporary directory to hold a .Xauthority
*
@@ -458,9 +458,9 @@
display = g_strdup (getenv ("DISPLAY"));
tmpv = g_strsplit (display, ":", 3);
g_free (display);
-
+
context->display = g_strdup_printf (":%s", tmpv[1]);
-
+
g_strfreev (tmpv);
/* get the authorization token */
@@ -483,7 +483,7 @@
if (context->debug)
{
- fprintf(stderr,
+ fprintf(stderr,
"xauth: -%s-\n"
"display: -%s-\n",
context->xauth, context->display);
@@ -526,7 +526,7 @@
newfn = g_strdup_printf("%s/.Xauthority", dir);
out = open(newfn, O_WRONLY | O_CREAT | O_EXCL, 0600);
- if (out == -1)
+ if (out == -1)
{
if (errno == EEXIST)
fprintf (stderr,
@@ -540,7 +540,7 @@
return TRUE;
}
-
+
in = open(fn, O_RDONLY);
if (in == -1)
{
@@ -549,8 +549,8 @@
fn, dir, strerror(errno));
return TRUE;
}
-
- while ((r = read(in, buf, BUFSIZ)) > 0)
+
+ while ((r = read(in, buf, BUFSIZ)) > 0)
{
if (full_write(out, buf, r) == -1)
{
@@ -585,7 +585,7 @@
fprintf (stderr, strerror(errno));
return 1;
}
-
+
xauth = g_strdup(g_getenv ("XAUTHORITY"));
if (xauth == NULL)
xauth = g_strdup_printf ("%s/.Xauthority", g_get_home_dir());
@@ -600,7 +600,7 @@
}
static void
-sudo_reset_xauth (GksuContext *context, gchar *xauth,
+sudo_reset_xauth (GksuContext *context, gchar *xauth,
gchar *xauth_env)
{
/* reset the env var as it was before or clean it */
@@ -608,11 +608,11 @@
setenv ("XAUTHORITY", xauth_env, TRUE);
else
unsetenv ("XAUTHORITY");
-
+
if (context->debug)
fprintf (stderr, "xauth: %s\nxauth_env: %s\ndir: %s\n",
xauth, xauth_env, context->dir);
-
+
unlink (xauth);
rmdir (context->dir);
@@ -653,14 +653,14 @@
/* executes the command */
if (execv (cmd[0], cmd) == -1)
{
- fprintf (stderr,
+ fprintf (stderr,
_("Unable to run /bin/su: %s"),
strerror(errno));
for (i = 0 ; cmd[i] != NULL ; i++)
g_free (cmd[i]);
g_free(cmd);
-
+
return TRUE;
}
}
@@ -694,7 +694,7 @@
usleep (100);
tcgetattr (fdpty, &tio);
-
+
if ((tio.c_lflag & ECHO))
need_pass = FALSE;
@@ -749,9 +749,9 @@
* Returns: the child's error status, 0 if all went fine, -1 if failed
*/
gboolean
-gksu_context_run_full (GksuContext *context,
- GksuAskPasswordFunc ask_pass, gpointer user_data,
- GksuPasswordNotNeededFunc pass_not_needed,
+gksu_context_run_full (GksuContext *context,
+ GksuAskPasswordFunc ask_pass, gpointer user_data,
+ GksuPasswordNotNeededFunc pass_not_needed,
gpointer pnn_user_data, GError **error)
{
GQuark gksu_quark;
@@ -780,7 +780,7 @@
return -1;
}
- /*
+ /*
FIXME: need to check if we are in X and also need to
provide GError stuff
*/
@@ -804,7 +804,7 @@
cmd[i] = g_strdup ("-c"); i++;
/* needs to get X authorization prior to running the program */
- cmd[i] = g_strdup_printf ("%s \"%s\"", auxcommand,
+ cmd[i] = g_strdup_printf ("%s \"%s\"", auxcommand,
context->command); i++;
cmd[i] = NULL;
@@ -812,7 +812,7 @@
/* executes the command */
if (execv (cmd[0], cmd) == -1)
{
- fprintf (stderr,
+ fprintf (stderr,
_("Unable to run /bin/su: %s"),
strerror(errno));
}
@@ -879,7 +879,7 @@
usleep (100);
password_needed = TRUE;
- write (fdpty, context->password,
+ write (fdpty, context->password,
strlen(context->password));
}
}
@@ -887,7 +887,7 @@
if (!password_needed)
pass_not_needed (context, pnn_user_data);
-
+
if (context->debug)
fprintf (stderr, "DEBUG (run:after-pass) buf: -%s-\n", buf);
if (strncmp (buf, "gksu", 4) && strncmp (buf, "su", 2))
@@ -904,7 +904,7 @@
if (!strncmp (buf, "su: Authentication failure", 26))
{
- g_set_error (error, gksu_quark,
+ g_set_error (error, gksu_quark,
GKSU_CONTEXT_ERROR_WRONGPASS,
_("Wrong password."));
if (context->debug)
@@ -913,14 +913,14 @@
else if (!strncmp (buf, "gksu: waiting", 13))
{
gchar *line;
-
+
if (context->debug)
fprintf (stderr, "DEBUG (gksu: waiting) buf: -%s-\n", buf);
line = g_strdup_printf ("gksu-run: %s\n", context->display);
write (fdpty, line, strlen(line));
g_free (line);
-
+
line = g_strdup_printf ("gksu-run: %s\n", context->xauth);
write (fdpty, line, strlen(line));
g_free (line);
@@ -1009,7 +1009,7 @@
}
if (error == NULL)
- g_set_error (error, gksu_quark,
+ g_set_error (error, gksu_quark,
GKSU_CONTEXT_ERROR_CHILDFAILED,
_("su terminated with %d status"),
WEXITSTATUS(status));
@@ -1025,7 +1025,7 @@
/* DO NOT USE -- Deprecated */
gboolean
-gksu_context_ask_and_run (GksuContext *context, GksuAskPasswordFunc ask_pass,
+gksu_context_ask_and_run (GksuContext *context, GksuAskPasswordFunc ask_pass,
gpointer user_data, GError **error)
{
return gksu_context_run_full (context, ask_pass, user_data, NULL, NULL, error);
@@ -1068,7 +1068,7 @@
int child_pipe[2]; /* For talking to the child */
gboolean need_pass = TRUE;
-
+
if ((pipe(parent_pipe)) == -1)
return TRUE;
@@ -1076,7 +1076,7 @@
return TRUE;
cmd = g_new (gchar *, argcount + 1);
-
+
argcount = 0;
/* sudo binary */
@@ -1104,22 +1104,22 @@
pid = fork();
if (pid == -1)
return TRUE;
- else if (pid == 0)
+ else if (pid == 0)
{
// Child
close(child_pipe[1]);
dup2(child_pipe[0], STDIN_FILENO);
dup2(parent_pipe[1], STDERR_FILENO);
-
+
execv(cmd[0], cmd);
-
+
return TRUE;
- }
- else
+ }
+ else
{
// Parent
close(parent_pipe[1]);
-
+
infile = fdopen(parent_pipe[0], "r");
if (!infile)
return TRUE;
@@ -1139,14 +1139,14 @@
if (context->debug)
fprintf (stderr, "buffer: -%s-\n", buffer);
- if (strncmp(buffer, "GNOME_SUDO_PASS", 15) == 0)
+ if (strncmp(buffer, "GNOME_SUDO_PASS", 15) == 0)
{
if (context->debug)
fprintf (stderr, "We'll need a password...\n");
fprintf (outfile, "\n");
- }
- else
+ }
+ else
{
if (context->debug)
fprintf (stderr, "We won't need a password, it seems!\n");
@@ -1204,9 +1204,9 @@
* Returns: the child's error status, 0 if all went fine, -1 if failed
*/
gboolean
-gksu_context_sudo_run_full (GksuContext *context,
- GksuAskPasswordFunc ask_pass, gpointer user_data,
- GksuPasswordNotNeededFunc pass_not_needed,
+gksu_context_sudo_run_full (GksuContext *context,
+ GksuAskPasswordFunc ask_pass, gpointer user_data,
+ GksuPasswordNotNeededFunc pass_not_needed,
gpointer pnn_user_data, GError **error)
{
char **cmd;
@@ -1216,7 +1216,7 @@
GQuark gksu_quark;
- gchar *xauth = NULL,
+ gchar *xauth = NULL,
*xauth_env = NULL;
pid_t pid;
@@ -1225,7 +1225,7 @@
FILE *infile, *outfile;
int parent_pipe[2]; /* For talking to the parent */
int child_pipe[2]; /* For talking to the child */
-
+
gksu_quark = g_quark_from_string (PACKAGE);
if (!context->command)
@@ -1236,7 +1236,7 @@
return -1;
}
- /*
+ /*
FIXME: need to check if we are in X
*/
if (sudo_prepare_xauth (context) == 1)
@@ -1255,7 +1255,7 @@
fprintf (stderr, "xauth: %s\n", xauth);
cmd = g_new (gchar *, argcount + 1);
-
+
argcount = 0;
/* sudo binary */
@@ -1313,7 +1313,7 @@
inside_quotes = !inside_quotes;
}
- if ((context->command[i] == ' ' && inside_quotes == FALSE)
+ if ((context->command[i] == ' ' && inside_quotes == FALSE)
|| context->command[i] == '\0')
{
tmp_arg = g_realloc (tmp_arg, sizeof(gchar)*(j+1));
@@ -1378,29 +1378,29 @@
sudo_reset_xauth (context, xauth, xauth_env);
return -1;
}
- else if (pid == 0)
+ else if (pid == 0)
{
// Child
setsid(); // make us session leader
close(child_pipe[1]);
dup2(child_pipe[0], STDIN_FILENO);
dup2(parent_pipe[1], STDERR_FILENO);
-
+
execv(cmd[0], cmd);
-
+
g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_EXEC,
_("Failed to exec new process: %s"),
strerror(errno));
sudo_reset_xauth (context, xauth, xauth_env);
return -1;
- }
- else
+ }
+ else
{
gchar *cmdline = NULL;
// Parent
close(parent_pipe[1]);
-
+
infile = fdopen(parent_pipe[0], "r");
if (!infile)
{
@@ -1431,7 +1431,7 @@
if (context->debug)
fprintf (stderr, "buffer: -%s-\n", buffer);
- if (strncmp(buffer, "GNOME_SUDO_PASS", 15) == 0)
+ if (strncmp(buffer, "GNOME_SUDO_PASS", 15) == 0)
{
if (context->debug)
fprintf (stderr, "Yeah, we're in...\n");
@@ -1450,10 +1450,10 @@
{
if (ask_pass (context, _("Password: "), user_data, error))
return -1;
-
+
g_return_val_if_fail (context->password, -1);
}
-
+
usleep (100);
fprintf (outfile, "%s", context->password);
@@ -1464,8 +1464,8 @@
*/
fgets (buffer, 255, infile);
fgets (buffer, 255, infile);
- }
- else
+ }
+ else
{
if (context->debug)
fprintf (stderr, "No password prompt found; we'll assume we don't need a password.\n");
@@ -1524,7 +1524,7 @@
fprintf (stderr, "%s", buffer);
fflush (stderr);
}
-
+
sudo_reset_xauth (context, xauth, xauth_env);
if (WIFEXITED(status))
@@ -1545,14 +1545,14 @@
}
if (error == NULL)
- g_set_error (error, gksu_quark,
+ g_set_error (error, gksu_quark,
GKSU_CONTEXT_ERROR_CHILDFAILED,
_("sudo terminated with %d status"),
WEXITSTATUS(status));
}
}
}
-
+
/* if error is set we have found an error condition */
if (error)
return TRUE;
@@ -1562,7 +1562,7 @@
/* DO NOT USE -- Deprecated */
gboolean
-gksu_context_sudo_ask_and_run (GksuContext *context, GksuAskPasswordFunc ask_pass,
+gksu_context_sudo_ask_and_run (GksuContext *context, GksuAskPasswordFunc ask_pass,
gpointer user_data, GError **error)
{
return gksu_context_sudo_run_full (context, ask_pass, user_data, NULL, NULL, error);
More information about the gksu-commits
mailing list