diff options
author | Branden Robinson <branden@debian.org> | 2010-01-05 16:40:21 +0000 |
---|---|---|
committer | Julien Cristau <jcristau@debian.org> | 2010-01-12 18:08:17 +0000 |
commit | 90c2cc57cdf911cec2eec185f357868209212c79 (patch) | |
tree | ed1d7f58df31b2de316922c82f25c2ccc08fa3d0 | |
parent | 5222d28e8d8e5b4cc705f1a637aace405ad32bd5 (diff) |
Improve logging of xdm's script handling
* 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.
Signed-off-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Alan Coopersmith <alan.coopersmith@sun.com>
Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr>
-rw-r--r-- | session.c | 33 |
1 files changed, 20 insertions, 13 deletions
@@ -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 |