From: "Alexandre Restovtsev" <tetromino@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/openrc-settingsd:master commit in: src/
Date: Wed, 8 Feb 2012 05:01:54 +0000 (UTC) [thread overview]
Message-ID: <fb55754fc1b2ad11dc51ed96126fc0cfacab569b.tetromino@gentoo> (raw)
commit: fb55754fc1b2ad11dc51ed96126fc0cfacab569b
Author: Alexandre Rostovtsev <tetromino <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 8 04:01:45 2012 +0000
Commit: Alexandre Restovtsev <tetromino <AT> gmail <DOT> com>
CommitDate: Wed Feb 8 04:01:45 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc-settingsd.git;a=commit;h=fb55754f
Fix transient hostname error handling, and dynamically allocate it
Ensure that setting the transient hostname behaves as described in
http://www.freedesktop.org/wiki/Software/systemd/hostnamed
---
src/hostnamed.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/hostnamed.c b/src/hostnamed.c
index c5f6f9c..88c166e 100644
--- a/src/hostnamed.c
+++ b/src/hostnamed.c
@@ -46,7 +46,7 @@ gboolean read_only = FALSE;
static OpenrcSettingsdHostnamedHostname1 *hostname1 = NULL;
-static gchar hostname[HOST_NAME_MAX + 1];
+static gchar *hostname = NULL;
G_LOCK_DEFINE_STATIC (hostname);
static gchar *static_hostname = NULL;
static GFile *static_hostname_file = NULL;
@@ -128,8 +128,8 @@ on_handle_set_hostname_authorized_cb (GObject *source_object,
if (data->name != NULL)
g_free (data->name);
- if (hostname_is_valid (hostname))
- data->name = g_strdup (hostname);
+ if (hostname_is_valid (static_hostname))
+ data->name = g_strdup (static_hostname);
else
data->name = g_strdup ("localhost");
}
@@ -141,13 +141,13 @@ on_handle_set_hostname_authorized_cb (GObject *source_object,
G_UNLOCK (hostname);
goto out;
}
- g_strlcpy (hostname, data->name, HOST_NAME_MAX + 1);
+ g_free (hostname);
+ hostname = data->name; /* data->name is g_strdup-ed already */;
openrc_settingsd_hostnamed_hostname1_complete_set_hostname (hostname1, data->invocation);
openrc_settingsd_hostnamed_hostname1_set_hostname (hostname1, hostname);
G_UNLOCK (hostname);
out:
- g_free (data->name);
g_free (data);
if (err != NULL)
g_error_free (err);
@@ -416,10 +416,10 @@ hostnamed_init (gboolean _read_only)
{
GError *err = NULL;
- memset (hostname, 0, HOST_NAME_MAX + 1);
+ hostname = g_malloc0 (HOST_NAME_MAX + 1);
if (gethostname (hostname, HOST_NAME_MAX)) {
perror (NULL);
- hostname[0] = 0;
+ g_strlcpy (hostname, "localhost", HOST_NAME_MAX + 1);
}
static_hostname_file = g_file_new_for_path (SYSCONFDIR "/conf.d/hostname");
@@ -470,6 +470,7 @@ hostnamed_destroy (void)
bus_id = 0;
read_only = FALSE;
memset (hostname, 0, HOST_NAME_MAX + 1);
+ g_free (hostname);
g_free (static_hostname);
g_free (pretty_hostname);
g_free (icon_name);
next reply other threads:[~2012-02-08 5:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-08 5:01 Alexandre Restovtsev [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-09-09 3:47 [gentoo-commits] proj/openrc-settingsd:master commit in: src/ Alexandre Rostovtsev
2012-09-08 0:20 Alexandre Restovtsev
2012-09-05 23:46 Alexandre Restovtsev
2012-09-05 21:19 Alexandre Restovtsev
2012-09-05 21:19 Alexandre Restovtsev
2012-09-05 21:19 Alexandre Restovtsev
2012-09-05 16:54 Alexandre Restovtsev
2012-03-19 3:03 Alexandre Restovtsev
2012-03-19 2:05 Alexandre Restovtsev
2012-03-18 11:02 Alexandre Restovtsev
2012-02-08 6:53 Alexandre Restovtsev
2012-02-08 5:57 Alexandre Restovtsev
2012-02-06 10:24 Alexandre Restovtsev
2012-02-05 7:52 Alexandre Restovtsev
2012-02-05 0:20 Alexandre Restovtsev
2012-01-29 23:22 Alexandre Restovtsev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fb55754fc1b2ad11dc51ed96126fc0cfacab569b.tetromino@gentoo \
--to=tetromino@gmail.com \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox