FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 08-06-2010, 05:06 PM
Ales Kozumplik
 
Default logging: fix logic in getSyslog().

Not working right since 88958d9d84f48cfa0f3ca7ff94326b49c252ebe1.

Related: rhbz#576439
---
loader/init.c | 74 +++++++++++++++++++++-----------------------------------
1 files changed, 28 insertions(+), 46 deletions(-)

diff --git a/loader/init.c b/loader/init.c
index b0d8978..a6a805f 100644
--- a/loader/init.c
+++ b/loader/init.c
@@ -96,6 +96,8 @@ char * env[] = {
NULL
};

+static char *VIRTIO_PORT = "/dev/virtio-ports/org.fedoraproject.anaconda.log.0";
+
/*
* this needs to handle the following cases:
*
@@ -108,7 +110,7 @@ char * env[] = {

void shutDown(int doKill, reboot_action rebootAction);
static int getKillPolicy(void);
-static gchar *getSyslog(gchar **);
+static int getSyslog(gchar **, gchar **);
static int onQEMU(void);
struct termios ts;

@@ -147,28 +149,26 @@ static void startSyslog(void) {
const char *forward_format_virtio = ";virtio_ForwardFormat
";

/* update the config file with command line arguments first */
- addr = getSyslog(&virtiolog);
- if (addr != NULL) {
+
+ if (getSyslog(&addr, &virtiolog)) {
conf_fd = open("/etc/rsyslog.conf", O_WRONLY|O_APPEND);
if (conf_fd < 0) {
printf("error opening /etc/rsyslog.conf: %d
", errno);
printf("syslog forwarding will not be enabled
");
sleep(5);
} else {
- ret = write(conf_fd, forward_tcp, strlen(forward_tcp));
- ret = write(conf_fd, addr, strlen(addr));
- ret = write(conf_fd, forward_format_tcp, strlen(forward_format_tcp));
-
+ if (addr != NULL) {
+ ret = write(conf_fd, forward_tcp, strlen(forward_tcp));
+ ret = write(conf_fd, addr, strlen(addr));
+ ret = write(conf_fd, forward_format_tcp, strlen(forward_format_tcp));
+ }
if (virtiolog != NULL) {
ret = write(conf_fd, forward_virtio, strlen(forward_virtio));
ret = write(conf_fd, virtiolog, strlen(virtiolog));
ret = write(conf_fd, forward_format_virtio, strlen(forward_format_virtio));
}
-
close(conf_fd);
}
-
- g_free(addr);
}

/* rsyslog is going to take care of things, so disable console logging */
@@ -323,29 +323,22 @@ static int getKillPolicy(void) {
* line. Remote virtio-serial logging is enabled if the declared virtio port
* exists.
*/
-static gchar *getSyslog(gchar **virtiolog) {
+static int getSyslog(gchar **addr, gchar **virtiolog) {
gpointer value = NULL;
- gchar *addr = NULL;
- const char *virtio_port = "/dev/virtio-ports/org.fedoraproject.anaconda.log.0";
-
- if (!g_hash_table_lookup_extended(cmdline, "syslog", NULL, &value)) {
- return NULL;
- } else {
- addr = (gchar *) value;
- }
+ int ret = 0;

- if (!g_hash_table_lookup_extended(cmdline, "virtiolog", NULL, &value)) {
- *virtiolog = NULL;
- } else {
- *virtiolog = (gchar *) value;
-
- /* virtiolog can only be letters and digits, dots, dashes
- * and underscores */
- if (!g_regex_match_simple("^[w.-_]*$", *virtiolog, 0, 0)) {
- /* the parameter is malformed, disable its use */
- *virtiolog = NULL;
- printf("The virtiolog= command line parameter is malformed and will
");
- printf("be ignored by the installer.
");
+ if (g_hash_table_lookup_extended(cmdline, "syslog", NULL, &value)) {
+ *addr = (gchar *) value;
+ /* address can be either a hostname or IPv4 or IPv6, with or without port;
+ thus we only allow the following characters in the address: letters and
+ digits, dots, colons, slashes, dashes and square brackets */
+ if (g_regex_match_simple("^[w.:/-[]]*$", *addr, 0, 0)) {
+ ++ret;
+ } else {
+ /* malformed, disable use */
+ *addr = NULL;
+ printf("The syslog= command line parameter is malformed and will be
");
+ printf("ignored by the installer.
");
sleep(5);
}
}
@@ -359,25 +352,14 @@ static gchar *getSyslog(gchar **virtiolog) {
} else {
printf("done.
");
}
- if (!access(virtio_port, W_OK)) {
+ if (!access(VIRTIO_PORT, W_OK)) {
/* that means we really have virtio-serial logging */
- g_free(*virtiolog);
- *virtiolog = g_strdup(virtio_port);
+ *virtiolog = VIRTIO_PORT;
+ ++ret;
}
}

- /* address can be either a hostname or IPv4 or IPv6, with or without port;
- thus we only allow the following characters in the address: letters and
- digits, dots, colons, slashes, dashes and square brackets */
- if (!g_regex_match_simple("^[w.:/-[]]*$", addr, 0, 0)) {
- /* the parameter is malformed, disable its use */
- addr = NULL;
- printf("The syslog= command line parameter is malformed and will be
");
- printf("ignored by the installer.
");
- sleep(5);
- }
-
- return addr;
+ return ret;
}

/*
--
1.7.1.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 08-06-2010, 06:15 PM
Chris Lumens
 
Default logging: fix logic in getSyslog().

> Not working right since 88958d9d84f48cfa0f3ca7ff94326b49c252ebe1.
>
> Related: rhbz#576439

These both look okay. Should we consider for f14-branch, too? Might be
nice to have proper logging there for later debugging.

- Chris

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 08-09-2010, 08:33 AM
Ales Kozumplik
 
Default logging: fix logic in getSyslog().

On 08/06/2010 08:15 PM, Chris Lumens wrote:

Not working right since 88958d9d84f48cfa0f3ca7ff94326b49c252ebe1.

Related: rhbz#576439


These both look okay. Should we consider for f14-branch, too? Might be
nice to have proper logging there for later debugging.

- Chris


Pushed to both, let James and Liam see how useful this really is as soon
as possible.


Ales

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 08:33 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org