[libvirt] [PATCH] virsh: Report an error when virGetUserDirectory fails

Otherwise virsh shows the interactive greeting and the silently exists instead of enterting interactive mode. --- tools/virsh.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 3baa015..356e0ae 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -12495,8 +12495,10 @@ vshReadlineInit(vshControl *ctl) /* Prepare to read/write history from/to the ~/.virsh/history file */ userdir = virGetUserDirectory(getuid()); - if (userdir == NULL) + if (userdir == NULL) { + vshError(ctl, "%s", _("Could not determine home directory")); return -1; + } if (virAsprintf(&ctl->historydir, "%s/.virsh", userdir) < 0) { vshError(ctl, "%s", _("Out of memory")); -- 1.7.0.4

On 05/15/2011 01:31 AM, Matthias Bolte wrote:
Otherwise virsh shows the interactive greeting and the silently exists instead of enterting interactive mode. --- tools/virsh.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c index 3baa015..356e0ae 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -12495,8 +12495,10 @@ vshReadlineInit(vshControl *ctl) /* Prepare to read/write history from/to the ~/.virsh/history file */ userdir = virGetUserDirectory(getuid());
- if (userdir == NULL) + if (userdir == NULL) { + vshError(ctl, "%s", _("Could not determine home directory")); return -1; + }
if (virAsprintf(&ctl->historydir, "%s/.virsh", userdir)< 0) { vshError(ctl, "%s", _("Out of memory"));
ACK.

2011/5/16 Laine Stump <laine@laine.org>:
On 05/15/2011 01:31 AM, Matthias Bolte wrote:
Otherwise virsh shows the interactive greeting and the silently exists instead of enterting interactive mode. --- tools/virsh.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c index 3baa015..356e0ae 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -12495,8 +12495,10 @@ vshReadlineInit(vshControl *ctl) /* Prepare to read/write history from/to the ~/.virsh/history file */ userdir = virGetUserDirectory(getuid());
- if (userdir == NULL) + if (userdir == NULL) { + vshError(ctl, "%s", _("Could not determine home directory")); return -1; + }
if (virAsprintf(&ctl->historydir, "%s/.virsh", userdir)< 0) { vshError(ctl, "%s", _("Out of memory"));
ACK.
Thanks, I fixed two typos in the commit message and pushed the result. Matthias
participants (2)
-
Laine Stump
-
Matthias Bolte