|
|
01552a |
From a2c6a448d38a5150c593ca388eea8537ec0489ee Mon Sep 17 00:00:00 2001
|
|
|
01552a |
From: Ray Strode <rstrode@redhat.com>
|
|
|
01552a |
Date: Thu, 11 May 2017 11:10:36 -0400
|
|
|
01552a |
Subject: [PATCH] Revert "Make boot.log world readable by default"
|
|
|
01552a |
|
|
|
01552a |
This reverts commit fc5cd88767db61805519fef53182386ba56c6405.
|
|
|
01552a |
---
|
|
|
01552a |
src/libply/ply-logger.c | 16 ++--------------
|
|
|
01552a |
src/libply/ply-logger.h | 5 ++---
|
|
|
01552a |
src/libply/ply-terminal-session.c | 2 +-
|
|
|
01552a |
3 files changed, 5 insertions(+), 18 deletions(-)
|
|
|
01552a |
|
|
|
01552a |
diff --git a/src/libply/ply-logger.c b/src/libply/ply-logger.c
|
|
|
01552a |
index dfd5c0a..6f25801 100644
|
|
|
01552a |
--- a/src/libply/ply-logger.c
|
|
|
01552a |
+++ b/src/libply/ply-logger.c
|
|
|
01552a |
@@ -292,84 +292,72 @@ ply_logger_free_filters (ply_logger_t *logger)
|
|
|
01552a |
next_node = ply_list_get_next_node (logger->filters, node);
|
|
|
01552a |
free (filter);
|
|
|
01552a |
node = next_node;
|
|
|
01552a |
}
|
|
|
01552a |
|
|
|
01552a |
ply_list_free (logger->filters);
|
|
|
01552a |
}
|
|
|
01552a |
|
|
|
01552a |
void
|
|
|
01552a |
ply_logger_free (ply_logger_t *logger)
|
|
|
01552a |
{
|
|
|
01552a |
if (logger == NULL)
|
|
|
01552a |
return;
|
|
|
01552a |
|
|
|
01552a |
if (logger->output_fd >= 0)
|
|
|
01552a |
{
|
|
|
01552a |
if (ply_logger_is_logging (logger))
|
|
|
01552a |
ply_logger_flush (logger);
|
|
|
01552a |
close (logger->output_fd);
|
|
|
01552a |
}
|
|
|
01552a |
|
|
|
01552a |
ply_logger_free_filters (logger);
|
|
|
01552a |
|
|
|
01552a |
free (logger->filename);
|
|
|
01552a |
free (logger->buffer);
|
|
|
01552a |
free (logger);
|
|
|
01552a |
}
|
|
|
01552a |
|
|
|
01552a |
bool
|
|
|
01552a |
ply_logger_open_file (ply_logger_t *logger,
|
|
|
01552a |
- const char *filename,
|
|
|
01552a |
- bool world_readable)
|
|
|
01552a |
+ const char *filename)
|
|
|
01552a |
{
|
|
|
01552a |
int fd;
|
|
|
01552a |
- mode_t mode;
|
|
|
01552a |
|
|
|
01552a |
assert (logger != NULL);
|
|
|
01552a |
assert (filename != NULL);
|
|
|
01552a |
|
|
|
01552a |
- if (world_readable)
|
|
|
01552a |
- mode = 0644;
|
|
|
01552a |
- else
|
|
|
01552a |
- mode = 0600;
|
|
|
01552a |
-
|
|
|
01552a |
- fd = open (filename, PLY_LOGGER_OPEN_FLAGS, mode);
|
|
|
01552a |
+ fd = open (filename, PLY_LOGGER_OPEN_FLAGS, 0600);
|
|
|
01552a |
|
|
|
01552a |
if (fd < 0)
|
|
|
01552a |
return false;
|
|
|
01552a |
|
|
|
01552a |
- if (fchmod (fd, mode) < 0) {
|
|
|
01552a |
- close (fd);
|
|
|
01552a |
- return false;
|
|
|
01552a |
- }
|
|
|
01552a |
-
|
|
|
01552a |
ply_logger_set_output_fd (logger, fd);
|
|
|
01552a |
|
|
|
01552a |
free (logger->filename);
|
|
|
01552a |
|
|
|
01552a |
logger->filename = strdup (filename);
|
|
|
01552a |
|
|
|
01552a |
return true;
|
|
|
01552a |
}
|
|
|
01552a |
|
|
|
01552a |
void
|
|
|
01552a |
ply_logger_close_file (ply_logger_t *logger)
|
|
|
01552a |
{
|
|
|
01552a |
assert (logger != NULL);
|
|
|
01552a |
|
|
|
01552a |
if (logger->output_fd < 0)
|
|
|
01552a |
return;
|
|
|
01552a |
|
|
|
01552a |
close (logger->output_fd);
|
|
|
01552a |
ply_logger_set_output_fd (logger, -1);
|
|
|
01552a |
}
|
|
|
01552a |
|
|
|
01552a |
void
|
|
|
01552a |
ply_logger_set_output_fd (ply_logger_t *logger,
|
|
|
01552a |
int fd)
|
|
|
01552a |
{
|
|
|
01552a |
assert (logger != NULL);
|
|
|
01552a |
|
|
|
01552a |
logger->output_fd = fd;
|
|
|
01552a |
}
|
|
|
01552a |
|
|
|
01552a |
diff --git a/src/libply/ply-logger.h b/src/libply/ply-logger.h
|
|
|
01552a |
index 596bed5..fc25db9 100644
|
|
|
01552a |
--- a/src/libply/ply-logger.h
|
|
|
01552a |
+++ b/src/libply/ply-logger.h
|
|
|
01552a |
@@ -19,120 +19,119 @@
|
|
|
01552a |
*/
|
|
|
01552a |
#ifndef PLY_LOGGER_H
|
|
|
01552a |
#define PLY_LOGGER_H
|
|
|
01552a |
|
|
|
01552a |
#include <errno.h>
|
|
|
01552a |
#include <stdbool.h>
|
|
|
01552a |
#include <stdint.h>
|
|
|
01552a |
#include <string.h>
|
|
|
01552a |
#include <sys/types.h>
|
|
|
01552a |
#include <unistd.h>
|
|
|
01552a |
|
|
|
01552a |
typedef struct _ply_logger ply_logger_t;
|
|
|
01552a |
|
|
|
01552a |
typedef enum
|
|
|
01552a |
{
|
|
|
01552a |
PLY_LOGGER_FLUSH_POLICY_WHEN_ASKED = 0,
|
|
|
01552a |
PLY_LOGGER_FLUSH_POLICY_EVERY_TIME
|
|
|
01552a |
} ply_logger_flush_policy_t;
|
|
|
01552a |
|
|
|
01552a |
typedef void (* ply_logger_filter_handler_t) (void *user_data,
|
|
|
01552a |
const void *in_bytes,
|
|
|
01552a |
size_t in_size,
|
|
|
01552a |
void **out_bytes,
|
|
|
01552a |
size_t *out_size,
|
|
|
01552a |
ply_logger_t *logger);
|
|
|
01552a |
|
|
|
01552a |
#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
|
|
|
01552a |
ply_logger_t *ply_logger_new (void);
|
|
|
01552a |
void ply_logger_free (ply_logger_t *logger);
|
|
|
01552a |
bool ply_logger_open_file (ply_logger_t *logger,
|
|
|
01552a |
- const char *filename,
|
|
|
01552a |
- bool world_readable);
|
|
|
01552a |
+ const char *filename);
|
|
|
01552a |
void ply_logger_close_file (ply_logger_t *logger);
|
|
|
01552a |
void ply_logger_set_output_fd (ply_logger_t *logger,
|
|
|
01552a |
int fd);
|
|
|
01552a |
int ply_logger_get_output_fd (ply_logger_t *logger);
|
|
|
01552a |
bool ply_logger_flush (ply_logger_t *logger);
|
|
|
01552a |
void ply_logger_set_flush_policy (ply_logger_t *logger,
|
|
|
01552a |
ply_logger_flush_policy_t policy);
|
|
|
01552a |
ply_logger_flush_policy_t ply_logger_get_flush_policy (ply_logger_t *logger);
|
|
|
01552a |
void ply_logger_toggle_logging (ply_logger_t *logger);
|
|
|
01552a |
bool ply_logger_is_logging (ply_logger_t *logger);
|
|
|
01552a |
void ply_logger_inject_bytes (ply_logger_t *logger,
|
|
|
01552a |
const void *bytes,
|
|
|
01552a |
size_t number_of_bytes);
|
|
|
01552a |
void ply_logger_add_filter (ply_logger_t *logger,
|
|
|
01552a |
ply_logger_filter_handler_t filter_handler,
|
|
|
01552a |
void *user_data);
|
|
|
01552a |
#define ply_logger_inject(logger, format, args...) \
|
|
|
01552a |
ply_logger_inject_with_non_literal_format_string (logger, \
|
|
|
01552a |
format "", ##args)
|
|
|
01552a |
__attribute__((__format__ (__printf__, 2, 3)))
|
|
|
01552a |
void ply_logger_inject_with_non_literal_format_string (ply_logger_t *logger,
|
|
|
01552a |
const char *format, ...);
|
|
|
01552a |
|
|
|
01552a |
ply_logger_t *ply_logger_get_default (void);
|
|
|
01552a |
ply_logger_t *ply_logger_get_error_default (void);
|
|
|
01552a |
|
|
|
01552a |
/* tracing is a debugging facility that incurs a hefty performance hit on the
|
|
|
01552a |
* program, so we conditionally compile support for it
|
|
|
01552a |
*/
|
|
|
01552a |
#ifdef PLY_ENABLE_TRACING
|
|
|
01552a |
void ply_logger_toggle_tracing (ply_logger_t *logger);
|
|
|
01552a |
bool ply_logger_is_tracing_enabled (ply_logger_t *logger);
|
|
|
01552a |
|
|
|
01552a |
#define ply_logger_trace(logger, format, args...) \
|
|
|
01552a |
do \
|
|
|
01552a |
{ \
|
|
|
01552a |
int _old_errno; \
|
|
|
01552a |
_old_errno = errno; \
|
|
|
01552a |
if (ply_logger_is_tracing_enabled (logger)) \
|
|
|
01552a |
{ \
|
|
|
01552a |
ply_logger_flush (logger); \
|
|
|
01552a |
errno = _old_errno; \
|
|
|
01552a |
ply_logger_inject (logger, \
|
|
|
01552a |
"[%s:%d] %45.45s:" format "\r\n", \
|
|
|
01552a |
__FILE__, __LINE__, __func__, ##args); \
|
|
|
01552a |
ply_logger_flush (logger); \
|
|
|
01552a |
errno = _old_errno; \
|
|
|
01552a |
} \
|
|
|
01552a |
} \
|
|
|
01552a |
while (0)
|
|
|
01552a |
#else
|
|
|
01552a |
#define ply_logger_trace(logger, format, args...)
|
|
|
01552a |
#define ply_logger_toggle_tracing(logger)
|
|
|
01552a |
#define ply_logger_is_tracing_enabled(logger) (false)
|
|
|
01552a |
#endif /* PLY_ENABLE_TRACING */
|
|
|
01552a |
|
|
|
01552a |
/* convenience macros
|
|
|
01552a |
*/
|
|
|
01552a |
#define ply_open_log_file(filename) \
|
|
|
01552a |
- ply_logger_open_file (ply_logger_get_default (), filename, false)
|
|
|
01552a |
+ ply_logger_open_file (ply_logger_get_default (), filename)
|
|
|
01552a |
#define ply_close_log_file() \
|
|
|
01552a |
ply_logger_close_file (ply_logger_get_default ())
|
|
|
01552a |
#define ply_flush_log() \
|
|
|
01552a |
ply_logger_flush (ply_logger_get_default ())
|
|
|
01552a |
#define ply_free_log() \
|
|
|
01552a |
ply_logger_free (ply_logger_get_default ())
|
|
|
01552a |
#define ply_log(format, args...) \
|
|
|
01552a |
ply_logger_inject (ply_logger_get_default (), format "\n", ##args)
|
|
|
01552a |
#define ply_log_without_new_line(format, args...) \
|
|
|
01552a |
ply_logger_inject (ply_logger_get_default (), format, ##args)
|
|
|
01552a |
#define ply_error(format, args...) \
|
|
|
01552a |
ply_logger_inject (ply_logger_get_error_default (), format "\n", ##args)
|
|
|
01552a |
#define ply_error_without_new_line(format, args...) \
|
|
|
01552a |
ply_logger_inject (ply_logger_get_error_default (), format, ##args)
|
|
|
01552a |
#define ply_free_error_log() \
|
|
|
01552a |
ply_logger_free (ply_logger_get_error_default ())
|
|
|
01552a |
|
|
|
01552a |
#define ply_toggle_tracing() \
|
|
|
01552a |
ply_logger_toggle_tracing (ply_logger_get_error_default ())
|
|
|
01552a |
#define ply_is_tracing() \
|
|
|
01552a |
ply_logger_is_tracing_enabled (ply_logger_get_error_default ())
|
|
|
01552a |
#define ply_trace(format, args...) \
|
|
|
01552a |
ply_logger_trace (ply_logger_get_error_default (), format, ##args)
|
|
|
01552a |
|
|
|
01552a |
#endif
|
|
|
01552a |
|
|
|
01552a |
#endif /* PLY_LOGGER_H */
|
|
|
01552a |
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
|
|
|
01552a |
diff --git a/src/libply/ply-terminal-session.c b/src/libply/ply-terminal-session.c
|
|
|
01552a |
index 143eed6..50ddd28 100644
|
|
|
01552a |
--- a/src/libply/ply-terminal-session.c
|
|
|
01552a |
+++ b/src/libply/ply-terminal-session.c
|
|
|
01552a |
@@ -542,48 +542,48 @@ ply_terminal_session_start_logging (ply_terminal_session_t *session)
|
|
|
01552a |
}
|
|
|
01552a |
|
|
|
01552a |
static void
|
|
|
01552a |
ply_terminal_session_stop_logging (ply_terminal_session_t *session)
|
|
|
01552a |
{
|
|
|
01552a |
assert (session != NULL);
|
|
|
01552a |
assert (session->logger != NULL);
|
|
|
01552a |
|
|
|
01552a |
ply_trace ("stopping logging of incoming console messages");
|
|
|
01552a |
if (ply_logger_is_logging (session->logger))
|
|
|
01552a |
ply_logger_toggle_logging (session->logger);
|
|
|
01552a |
|
|
|
01552a |
if (session->loop != NULL &&
|
|
|
01552a |
session->fd_watch != NULL)
|
|
|
01552a |
ply_event_loop_stop_watching_fd (session->loop,
|
|
|
01552a |
session->fd_watch);
|
|
|
01552a |
session->fd_watch = NULL;
|
|
|
01552a |
}
|
|
|
01552a |
|
|
|
01552a |
bool
|
|
|
01552a |
ply_terminal_session_open_log (ply_terminal_session_t *session,
|
|
|
01552a |
const char *filename)
|
|
|
01552a |
{
|
|
|
01552a |
bool log_is_opened;
|
|
|
01552a |
|
|
|
01552a |
assert (session != NULL);
|
|
|
01552a |
assert (filename != NULL);
|
|
|
01552a |
assert (session->logger != NULL);
|
|
|
01552a |
|
|
|
01552a |
ply_save_errno ();
|
|
|
01552a |
- log_is_opened = ply_logger_open_file (session->logger, filename, true);
|
|
|
01552a |
+ log_is_opened = ply_logger_open_file (session->logger, filename);
|
|
|
01552a |
if (log_is_opened)
|
|
|
01552a |
ply_logger_flush (session->logger);
|
|
|
01552a |
ply_restore_errno ();
|
|
|
01552a |
|
|
|
01552a |
return log_is_opened;
|
|
|
01552a |
}
|
|
|
01552a |
|
|
|
01552a |
void
|
|
|
01552a |
ply_terminal_session_close_log (ply_terminal_session_t *session)
|
|
|
01552a |
{
|
|
|
01552a |
assert (session != NULL);
|
|
|
01552a |
assert (session->logger != NULL);
|
|
|
01552a |
|
|
|
01552a |
return ply_logger_close_file (session->logger);
|
|
|
01552a |
}
|
|
|
01552a |
|
|
|
01552a |
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
|
|
|
01552a |
--
|
|
|
01552a |
2.12.2
|
|
|
01552a |
|