|
|
9fc0f6 |
From a454e9c726630fe4811a1c93b2d88b0e77b3094f Mon Sep 17 00:00:00 2001
|
|
|
9fc0f6 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
|
9fc0f6 |
Date: Wed, 28 Aug 2013 08:01:30 -0400
|
|
|
9fc0f6 |
Subject: [PATCH] execute: more debugging messages
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
---
|
|
|
9fc0f6 |
src/core/execute.c | 35 +++++++++++++++++++++--------------
|
|
|
9fc0f6 |
src/login/pam-module.c | 3 ++-
|
|
|
9fc0f6 |
2 files changed, 23 insertions(+), 15 deletions(-)
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
diff --git a/src/core/execute.c b/src/core/execute.c
|
|
|
9fc0f6 |
index a53ef48..981b9e4 100644
|
|
|
9fc0f6 |
--- a/src/core/execute.c
|
|
|
9fc0f6 |
+++ b/src/core/execute.c
|
|
|
9fc0f6 |
@@ -317,12 +317,12 @@ static int setup_input(const ExecContext *context, int socket_fd, bool apply_tty
|
|
|
9fc0f6 |
case EXEC_INPUT_TTY_FAIL: {
|
|
|
9fc0f6 |
int fd, r;
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
- if ((fd = acquire_terminal(
|
|
|
9fc0f6 |
- tty_path(context),
|
|
|
9fc0f6 |
- i == EXEC_INPUT_TTY_FAIL,
|
|
|
9fc0f6 |
- i == EXEC_INPUT_TTY_FORCE,
|
|
|
9fc0f6 |
- false,
|
|
|
9fc0f6 |
- (usec_t) -1)) < 0)
|
|
|
9fc0f6 |
+ fd = acquire_terminal(tty_path(context),
|
|
|
9fc0f6 |
+ i == EXEC_INPUT_TTY_FAIL,
|
|
|
9fc0f6 |
+ i == EXEC_INPUT_TTY_FORCE,
|
|
|
9fc0f6 |
+ false,
|
|
|
9fc0f6 |
+ (usec_t) -1);
|
|
|
9fc0f6 |
+ if (fd < 0)
|
|
|
9fc0f6 |
return fd;
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
if (fd != STDIN_FILENO) {
|
|
|
9fc0f6 |
@@ -748,6 +748,7 @@ static int setup_pam(
|
|
|
9fc0f6 |
char **e = NULL;
|
|
|
9fc0f6 |
bool close_session = false;
|
|
|
9fc0f6 |
pid_t pam_pid = 0, parent_pid;
|
|
|
9fc0f6 |
+ int flags = 0;
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
assert(name);
|
|
|
9fc0f6 |
assert(user);
|
|
|
9fc0f6 |
@@ -760,6 +761,9 @@ static int setup_pam(
|
|
|
9fc0f6 |
* daemon. We do things this way to ensure that the main PID
|
|
|
9fc0f6 |
* of the daemon is the one we initially fork()ed. */
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
+ if (log_get_max_level() < LOG_PRI(LOG_DEBUG))
|
|
|
9fc0f6 |
+ flags |= PAM_SILENT;
|
|
|
9fc0f6 |
+
|
|
|
9fc0f6 |
pam_code = pam_start(name, user, &conv, &handle);
|
|
|
9fc0f6 |
if (pam_code != PAM_SUCCESS) {
|
|
|
9fc0f6 |
handle = NULL;
|
|
|
9fc0f6 |
@@ -772,11 +776,11 @@ static int setup_pam(
|
|
|
9fc0f6 |
goto fail;
|
|
|
9fc0f6 |
}
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
- pam_code = pam_acct_mgmt(handle, PAM_SILENT);
|
|
|
9fc0f6 |
+ pam_code = pam_acct_mgmt(handle, flags);
|
|
|
9fc0f6 |
if (pam_code != PAM_SUCCESS)
|
|
|
9fc0f6 |
goto fail;
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
- pam_code = pam_open_session(handle, PAM_SILENT);
|
|
|
9fc0f6 |
+ pam_code = pam_open_session(handle, flags);
|
|
|
9fc0f6 |
if (pam_code != PAM_SUCCESS)
|
|
|
9fc0f6 |
goto fail;
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
@@ -850,7 +854,7 @@ static int setup_pam(
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
/* If our parent died we'll end the session */
|
|
|
9fc0f6 |
if (getppid() != parent_pid) {
|
|
|
9fc0f6 |
- pam_code = pam_close_session(handle, PAM_DATA_SILENT);
|
|
|
9fc0f6 |
+ pam_code = pam_close_session(handle, flags);
|
|
|
9fc0f6 |
if (pam_code != PAM_SUCCESS)
|
|
|
9fc0f6 |
goto child_finish;
|
|
|
9fc0f6 |
}
|
|
|
9fc0f6 |
@@ -858,7 +862,7 @@ static int setup_pam(
|
|
|
9fc0f6 |
r = 0;
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
child_finish:
|
|
|
9fc0f6 |
- pam_end(handle, pam_code | PAM_DATA_SILENT);
|
|
|
9fc0f6 |
+ pam_end(handle, pam_code | flags);
|
|
|
9fc0f6 |
_exit(r);
|
|
|
9fc0f6 |
}
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
@@ -880,16 +884,19 @@ static int setup_pam(
|
|
|
9fc0f6 |
return 0;
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
fail:
|
|
|
9fc0f6 |
- if (pam_code != PAM_SUCCESS)
|
|
|
9fc0f6 |
+ if (pam_code != PAM_SUCCESS) {
|
|
|
9fc0f6 |
+ log_error("PAM failed: %s", pam_strerror(handle, pam_code));
|
|
|
9fc0f6 |
err = -EPERM; /* PAM errors do not map to errno */
|
|
|
9fc0f6 |
- else
|
|
|
9fc0f6 |
+ } else {
|
|
|
9fc0f6 |
+ log_error("PAM failed: %m");
|
|
|
9fc0f6 |
err = -errno;
|
|
|
9fc0f6 |
+ }
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
if (handle) {
|
|
|
9fc0f6 |
if (close_session)
|
|
|
9fc0f6 |
- pam_code = pam_close_session(handle, PAM_DATA_SILENT);
|
|
|
9fc0f6 |
+ pam_code = pam_close_session(handle, flags);
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
- pam_end(handle, pam_code | PAM_DATA_SILENT);
|
|
|
9fc0f6 |
+ pam_end(handle, pam_code | flags);
|
|
|
9fc0f6 |
}
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
strv_free(e);
|
|
|
9fc0f6 |
diff --git a/src/login/pam-module.c b/src/login/pam-module.c
|
|
|
9fc0f6 |
index 49296b5..973daf7 100644
|
|
|
9fc0f6 |
--- a/src/login/pam-module.c
|
|
|
9fc0f6 |
+++ b/src/login/pam-module.c
|
|
|
9fc0f6 |
@@ -199,7 +199,8 @@ _public_ PAM_EXTERN int pam_sm_open_session(
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
dbus_error_init(&error);
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
- /* pam_syslog(handle, LOG_INFO, "pam-systemd initializing"); */
|
|
|
9fc0f6 |
+ if (debug)
|
|
|
9fc0f6 |
+ pam_syslog(handle, LOG_INFO, "pam-systemd initializing");
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
/* Make this a NOP on non-logind systems */
|
|
|
9fc0f6 |
if (!logind_running())
|