Compare commits
4 Commits
12c829376a
...
c199cc0704
Author | SHA1 | Date |
---|---|---|
Yu Watanabe | c199cc0704 | |
Zbigniew Jędrzejewski-Szmek | ecfd9a990c | |
Zbigniew Jędrzejewski-Szmek | 7d895205ef | |
Zbigniew Jędrzejewski-Szmek | ce2f43797a |
|
@ -266,7 +266,6 @@ static int request_handler(
|
||||||
int r, code, fd;
|
int r, code, fd;
|
||||||
_cleanup_free_ char *hostname = NULL;
|
_cleanup_free_ char *hostname = NULL;
|
||||||
bool chunked = false;
|
bool chunked = false;
|
||||||
size_t len;
|
|
||||||
|
|
||||||
assert(connection);
|
assert(connection);
|
||||||
assert(connection_cls);
|
assert(connection_cls);
|
||||||
|
@ -302,6 +301,8 @@ static int request_handler(
|
||||||
|
|
||||||
header = MHD_lookup_connection_value(connection, MHD_HEADER_KIND, "Content-Length");
|
header = MHD_lookup_connection_value(connection, MHD_HEADER_KIND, "Content-Length");
|
||||||
if (header) {
|
if (header) {
|
||||||
|
size_t len;
|
||||||
|
|
||||||
if (chunked)
|
if (chunked)
|
||||||
return mhd_respond(connection, MHD_HTTP_BAD_REQUEST,
|
return mhd_respond(connection, MHD_HTTP_BAD_REQUEST,
|
||||||
"Content-Length must not specified when Transfer-Encoding type is 'chuncked'");
|
"Content-Length must not specified when Transfer-Encoding type is 'chuncked'");
|
||||||
|
|
|
@ -337,7 +337,7 @@ static int process_and_watch_password_files(bool watch) {
|
||||||
};
|
};
|
||||||
|
|
||||||
_cleanup_close_ int notify = -1, signal_fd = -1, tty_block_fd = -1;
|
_cleanup_close_ int notify = -1, signal_fd = -1, tty_block_fd = -1;
|
||||||
struct pollfd pollfd[_FD_MAX] = {};
|
struct pollfd pollfd[_FD_MAX];
|
||||||
sigset_t mask;
|
sigset_t mask;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -354,8 +354,7 @@ static int process_and_watch_password_files(bool watch) {
|
||||||
if (signal_fd < 0)
|
if (signal_fd < 0)
|
||||||
return log_error_errno(errno, "Failed to allocate signal file descriptor: %m");
|
return log_error_errno(errno, "Failed to allocate signal file descriptor: %m");
|
||||||
|
|
||||||
pollfd[FD_SIGNAL].fd = signal_fd;
|
pollfd[FD_SIGNAL] = (struct pollfd) { .fd = signal_fd, .events = POLLIN };
|
||||||
pollfd[FD_SIGNAL].events = POLLIN;
|
|
||||||
|
|
||||||
notify = inotify_init1(IN_CLOEXEC);
|
notify = inotify_init1(IN_CLOEXEC);
|
||||||
if (notify < 0)
|
if (notify < 0)
|
||||||
|
@ -365,8 +364,7 @@ static int process_and_watch_password_files(bool watch) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
pollfd[FD_INOTIFY].fd = notify;
|
pollfd[FD_INOTIFY] = (struct pollfd) { .fd = notify, .events = POLLIN };
|
||||||
pollfd[FD_INOTIFY].events = POLLIN;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -389,7 +387,7 @@ static int process_and_watch_password_files(bool watch) {
|
||||||
if (!watch)
|
if (!watch)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (poll(pollfd, watch ? _FD_MAX : _FD_MAX-1, timeout) < 0) {
|
if (poll(pollfd, _FD_MAX, timeout) < 0) {
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "main-func.h"
|
#include "main-func.h"
|
||||||
#include "process-util.h"
|
#include "process-util.h"
|
||||||
#include "special.h"
|
#include "special.h"
|
||||||
|
#include "stdio-util.h"
|
||||||
#include "strv.h"
|
#include "strv.h"
|
||||||
#include "unit-name.h"
|
#include "unit-name.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -188,10 +189,8 @@ static int on_runlevel(Context *c) {
|
||||||
|
|
||||||
/* Secondly, get new runlevel */
|
/* Secondly, get new runlevel */
|
||||||
runlevel = get_current_runlevel(c);
|
runlevel = get_current_runlevel(c);
|
||||||
|
|
||||||
if (runlevel < 0)
|
if (runlevel < 0)
|
||||||
return runlevel;
|
return runlevel;
|
||||||
|
|
||||||
if (runlevel == 0)
|
if (runlevel == 0)
|
||||||
return log_warning("Failed to get new runlevel, utmp update skipped.");
|
return log_warning("Failed to get new runlevel, utmp update skipped.");
|
||||||
|
|
||||||
|
@ -200,23 +199,21 @@ static int on_runlevel(Context *c) {
|
||||||
|
|
||||||
#if HAVE_AUDIT
|
#if HAVE_AUDIT
|
||||||
if (c->audit_fd >= 0) {
|
if (c->audit_fd >= 0) {
|
||||||
_cleanup_free_ char *s = NULL;
|
char s[STRLEN("old-level=_ new-level=_") + 1];
|
||||||
|
|
||||||
if (asprintf(&s, "old-level=%c new-level=%c",
|
xsprintf(s, "old-level=%c new-level=%c",
|
||||||
previous > 0 ? previous : 'N',
|
previous > 0 ? previous : 'N',
|
||||||
runlevel > 0 ? runlevel : 'N') < 0)
|
runlevel);
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
if (audit_log_user_comm_message(c->audit_fd, AUDIT_SYSTEM_RUNLEVEL, s, "systemd-update-utmp", NULL, NULL, NULL, 1) < 0 && errno != EPERM)
|
if (audit_log_user_comm_message(c->audit_fd, AUDIT_SYSTEM_RUNLEVEL, s,
|
||||||
|
"systemd-update-utmp", NULL, NULL, NULL, 1) < 0 && errno != EPERM)
|
||||||
r = log_error_errno(errno, "Failed to send audit message: %m");
|
r = log_error_errno(errno, "Failed to send audit message: %m");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
q = utmp_put_runlevel(runlevel, previous);
|
q = utmp_put_runlevel(runlevel, previous);
|
||||||
if (q < 0 && !IN_SET(q, -ESRCH, -ENOENT)) {
|
if (q < 0 && !IN_SET(q, -ESRCH, -ENOENT))
|
||||||
log_error_errno(q, "Failed to write utmp record: %m");
|
return log_error_errno(q, "Failed to write utmp record: %m");
|
||||||
r = q;
|
|
||||||
}
|
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue