Mailinglist Archive: vhostmd (42 mails)

< Previous Next >
Re: [vhostmd] [PATCH 5/7] Add '-u user' command line option to drop root privs.
  • From: "Richard W.M. Jones" <rjones@xxxxxxxxxx>
  • Date: Thu, 15 Oct 2009 16:55:53 +0100
  • Message-id: <20091015155553.GE31010@xxxxxxxxxxxxxxxxxxxx>
On Thu, Oct 15, 2009 at 09:36:34AM -0600, Jim Fehlig wrote:
Richard W.M. Jones wrote:
From 29d73f4e62c0cd9ed6a7616f4a82d6fdf0421c06 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones@xxxxxxxxxx>
Date: Thu, 15 Oct 2009 12:10:15 +0100
Subject: [PATCH 5/8] Add '-u user' command line option to drop root privs.

If vhostmd is run as root, you can now use the '-u user'
command line option to drop root privs and run as 'user'
instead.
---
docs/man/vhostmd.8 | 3 +++
vhostmd/vhostmd.c | 51
+++++++++++++++++++++++++++++++++++++++++++++------
2 files changed, 48 insertions(+), 6 deletions(-)

Nice addition! ACK.

Thanks. I've pushed up to this point now. However I changed:

+ errno = 0;
+ pw = getpwnam (user);
+ if (!pw) {
+ perror (user);
+ goto out;
+ }

to:

+ errno = 0;
+ pw = getpwnam (user);
+ if (!pw) {
+ vu_log (VHOSTMD_ERR, "No entry in password file for user %s: %m",
+ user);
+ goto out;
+ }

This is because the 'perror' would be sent to stderr (not to syslog),
and thus the error message would most likely be lost.

Rich.

--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://et.redhat.com/~rjones/libguestfs/
See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
--
To unsubscribe, e-mail: vhostmd+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: vhostmd+help@xxxxxxxxxxxx

< Previous Next >