[PATCH 07/10] Improve logging of xdm's script handling
Julien Cristau
jcristau at debian.org
Tue Jan 5 10:18:21 PST 2010
From: Branden Robinson <branden at debian.org>
* Make execution of the session program an informational log message (with
LogInfo()), not a Debug() message.
* Ensure that source()d scripts (Xreset, Xsetup, Xstartup) can be
fopen()ed before invoking runAndWait() on them. If they can, LogInfo()
the fact. If they cannot, LogInfo() that, too, and use _SysErrorMsg() to
report why fopen() failed.
* Make source() complain using Debug() when it is given a null pointer in
its file argument.
* For clarity, make source() return from only one location.
Also see Debian bug #219311.
Forward ported by Eugene Konev.
---
session.c | 33 ++++++++++++++++++++-------------
1 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/session.c b/session.c
index 5040d3b..01800ee 100644
--- a/session.c
+++ b/session.c
@@ -791,7 +791,7 @@ StartClient (
verify->userEnviron = setEnv(verify->userEnviron, "HOME", "/");
}
if (verify->argv) {
- Debug ("executing session %s\n", verify->argv[0]);
+ LogInfo ("executing session %s\n", verify->argv[0]);
execute (verify->argv, verify->userEnviron);
LogError ("Session \"%s\" execution failed (err %d)\n", verify->argv[0], errno);
} else {
@@ -821,21 +821,28 @@ int
source (char **environ, char *file)
{
char **args, *args_safe[2];
- int ret;
+ int ret = 0;
+ FILE *f;
if (file && file[0]) {
- Debug ("source %s\n", file);
- args = parseArgs ((char **) 0, file);
- if (!args) {
- args = args_safe;
- args[0] = file;
- args[1] = NULL;
+ f = fopen (file, "r");
+ if (!f)
+ LogInfo ("not sourcing %s (%s)\n", file, _SysErrorMsg (errno));
+ else {
+ fclose (f);
+ LogInfo ("sourcing %s\n", file);
+ args = parseArgs ((char **) 0, file);
+ if (!args) {
+ args = args_safe;
+ args[0] = file;
+ args[1] = NULL;
+ }
+ ret = runAndWait (args, environ);
+ freeArgs (args);
}
- ret = runAndWait (args, environ);
- freeArgs (args);
- return ret;
- }
- return 0;
+ } else
+ Debug ("source() given null pointer in file argument\n");
+ return ret;
}
static int
--
1.6.5.7
More information about the xorg-devel
mailing list