From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::6]) by metis.ext.pengutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1bSKsS-0001vr-Ns for ptxdist@pengutronix.de; Wed, 27 Jul 2016 11:11:44 +0200 Received: from [192.168.2.50] (dslb-094-218-020-069.094.218.pools.vodafone-ip.de [94.218.20.69]) by smtp.strato.de (RZmta 38.13 DYNA|AUTH) with ESMTPSA id z08429s6R9BgZB9 (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate) for ; Wed, 27 Jul 2016 11:11:42 +0200 (CEST) References: <20160726140925.16dc99e7@erd980> <20160726160034.40ee8b05@erd980> <20160727065513.GL13559@pengutronix.de> <20160727105514.29ae34e4@erd980> From: Artur Wiebe Message-ID: Date: Wed, 27 Jul 2016 11:11:21 +0200 MIME-Version: 1.0 In-Reply-To: <20160727105514.29ae34e4@erd980> Subject: Re: [ptxdist] Resend: Home dir fixup for root in systemd List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Content-Type: multipart/mixed; boundary="===============1466993739==" Errors-To: ptxdist-bounces@pengutronix.de Sender: "ptxdist" To: ptxdist@pengutronix.de This is a multi-part message in MIME format. --===============1466993739== Content-Type: multipart/alternative; boundary="------------85A7EABB56CD1C372E3A5D61" This is a multi-part message in MIME format. --------------85A7EABB56CD1C372E3A5D61 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi all, to patch systemd to fit some "mistake" in ptxdist seems quite disproportionately. It is much simpler to change home of root to /root by providing own /projectroot/etc/passwd then undoing a patch. Oh, it was just a typo of Michael! Great! Ialsovote for solution 1: set home for root to /root Change PTXdist and all places in it that assume the $HOME=/home for root. Best Regards, Artur Am 27.07.2016 um 10:55 schrieb David Jander: > Dear Michael, > > On Wed, 27 Jul 2016 08:55:13 +0200 > Michael Olbrich wrote: > >> Hi, >> >> On Tue, Jul 26, 2016 at 04:00:34PM +0200, David Jander wrote: >>> On Tue, 26 Jul 2016 15:19:59 +0200 >>> Guillermo Rodriguez Garcia wrote: >>> >>>> Wouldn't it be easier to either use a custom /etc/passwd, or create a /root >>>> dir in the filesystem ? That sounds better than patching systemd. >>> Maybe it would be better to change the default /etc/passwd (and everywhere >>> else) in ptxdist then... >>> >>> The problem is that what /etc/passwd says is mandatory. The home directory has >>> a special meaning to the user. You can get to the home directory via $HOME >>> passed in the environment, or via the NS-switch (getent) lookup. They are >>> supposed to be the same. >>> systemd has hardcoded defaults in source-code, which by definition is ugly as >>> hell, but the reason is clearly to avoid potentially expensive, blocking >>> NSS-lookups in the early boot stages, so it is understandable. It would be a >>> lot better if there was some configuration setting read from a file I guess, >>> but alas. >>> On PTXdist now (with the default, shipped /etc/passwd), a user logging in as >>> "root" via, say a serial console getty, will have a different $HOME than a >>> systemd service started with User=root. This is bad, and can potentially do >>> funny things people will not like. >>> To solve the problem, there are really only two options AFAICS: >>> >>> 1.- Change PTXdist and all places in it that assume the $HOME=/home for root. >>> No idea how many places that are, nor how many users already depend on this >>> historic assumption. >>> >>> or >>> >>> 2.- Patch systemd to adapt to the reality of PTXdist. >>> >>> I agree that option 1 is probably better if PTXdist is more or less the only >>> place on earth left where $HOME != /root for uid=0. Historically on Unix it >>> used to be "/", but that is just way too ugly (guess where the name "root" >>> came from?). >>> >>> Using a custom /etc/passwd is not an option, because the default PTXdist stays >>> broken this way. >>> >>> Creating a /root dir is also broken, because like I explained above, the root >>> user will become schizophrenic when logging in and running services from >>> systemd alternately. Think about a user logging in, starting a tool that >>> writes a config files to ~/.bla, and then configuring the same tool to run as a >>> system service. I would (did!) get slightly mad when finding the tool to run >>> with a totally different configuration in the latter case. >> Unless someone comes up with a really good reason, then I think we should go >> with option 2. I have actually considered making the change in the past >> just to be consistent. But I never got around to do it. >> I didn't notice this problem, probably because my rootfs is usually >> read-only, and /root and /home are both empty. >> >> It would be great if some more people would speak up. Such a change can >> potentially break things, so I'd like to know what others are thinking. > Ok, just so we understand each other, you propose to go with my original patch > in this case (i.e. patch systemd to assume $HOME=/home), right? > In case nobody speaks up against it, will you pick it up as-is, or should I > make a correct patch (i.e. learn how to properly use git-ptxdist-patch to > generate a correct series file) and post it here? > > Best regards, > --------------85A7EABB56CD1C372E3A5D61 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit

Hi all,

to patch systemd to fit some "mistake" in ptxdist seems quite disproportionately.

It is much simpler to change home of root to /root by providing own /projectroot/etc/passwd then undoing a patch.

Oh, it was just a typo of Michael! Great!

I also vote for solution 1: set home for root to /root

Change PTXdist and all places in it that assume the $HOME=/home for root.

Best Regards,
Artur


    
Am 27.07.2016 um 10:55 schrieb David Jander:
Dear Michael,

On Wed, 27 Jul 2016 08:55:13 +0200
Michael Olbrich <m.olbrich@pengutronix.de> wrote:

Hi,

On Tue, Jul 26, 2016 at 04:00:34PM +0200, David Jander wrote:
On Tue, 26 Jul 2016 15:19:59 +0200
Guillermo Rodriguez Garcia <guille.rodriguez@gmail.com> wrote:
  
Wouldn't it be easier to either use a custom /etc/passwd, or create a /root
dir in the filesystem ? That sounds better than patching systemd.  
Maybe it would be better to change the default /etc/passwd (and everywhere
else) in ptxdist then...

The problem is that what /etc/passwd says is mandatory. The home directory has
a special meaning to the user. You can get to the home directory via $HOME
passed in the environment, or via the NS-switch (getent) lookup. They are
supposed to be the same.
systemd has hardcoded defaults in source-code, which by definition is ugly as
hell, but the reason is clearly to avoid potentially expensive, blocking
NSS-lookups in the early boot stages, so it is understandable. It would be a
lot better if there was some configuration setting read from a file I guess,
but alas.
On PTXdist now (with the default, shipped /etc/passwd), a user logging in as
"root" via, say a serial console getty, will have a different $HOME than a
systemd service started with User=root. This is bad, and can potentially do
funny things people will not like.
To solve the problem, there are really only two options AFAICS:

 1.- Change PTXdist and all places in it that assume the $HOME=/home for root.
 No idea how many places that are, nor how many users already depend on this
 historic assumption.

or

 2.- Patch systemd to adapt to the reality of PTXdist.

I agree that option 1 is probably better if PTXdist is more or less the only
place on earth left where $HOME != /root for uid=0. Historically on Unix it
used to be "/", but that is just way too ugly (guess where the name "root"
came from?).

Using a custom /etc/passwd is not an option, because the default PTXdist stays
broken this way.

Creating a /root dir is also broken, because like I explained above, the root
user will become schizophrenic when logging in and running services from
systemd alternately. Think about a user logging in, starting a tool that
writes a config files to ~/.bla, and then configuring the same tool to run as a
system service. I would (did!) get slightly mad when finding the tool to run
with a totally different configuration in the latter case.  
Unless someone comes up with a really good reason, then I think we should go
with option 2. I have actually considered making the change in the past
just to be consistent. But I never got around to do it.
I didn't notice this problem, probably because my rootfs is usually
read-only, and /root and /home are both empty.

It would be great if some more people would speak up. Such a change can
potentially break things, so I'd like to know what others are thinking.
Ok, just so we understand each other, you propose to go with my original patch
in this case (i.e. patch systemd to assume $HOME=/home), right?
In case nobody speaks up against it, will you pick it up as-is, or should I
make a correct patch (i.e. learn how to properly use git-ptxdist-patch to
generate a correct series file) and post it here?

Best regards,


--------------85A7EABB56CD1C372E3A5D61-- --===============1466993739== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KcHR4ZGlzdCBt YWlsaW5nIGxpc3QKcHR4ZGlzdEBwZW5ndXRyb25peC5kZQ== --===============1466993739==--