Bug 1173321 - Move /etc/skel/* files to /usr/etc/skel ?
Summary: Move /etc/skel/* files to /usr/etc/skel ?
Status: RESOLVED FIXED
Alias: None
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Basesystem (show other bugs)
Version: Current
Hardware: Other Other
: P5 - None : Normal (vote)
Target Milestone: ---
Assignee: Michael Vetter
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 1176431
  Show dependency treegraph
 
Reported: 2020-06-24 14:59 UTC by Stefan Dirsch
Modified: 2023-07-04 07:16 UTC (History)
7 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
useradd.local.patch (724 bytes, patch)
2020-09-15 11:38 UTC, Stefan Dirsch
Details | Diff
An other approach (1.16 KB, patch)
2020-10-09 11:51 UTC, Dr. Werner Fink
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Dirsch 2020-06-24 14:59:23 UTC
I'm currently working on the config file switch /etc --> /usr/etc (find Details on https://en.opensuse.org/openSUSE:Packaging_UsrEtc) and now I'm wondering what should be done with files in /etc/skel/* 

Thorten Kukuk:
Hard to change, as the admin should be able to change them...

Me:
Hm. Maybe move the distributed ones to /usr/etc/skel and adjust everything needed to priotarize the ones in /etc/skel, i.e. use any file in /etc/skel but also any file, which exists in /usr/etc/skel, but not in /etc/skel?
Comment 1 Stefan Dirsch 2020-06-24 15:01:17 UTC
Adding maintainer of filesystem.
Comment 2 Ludwig Nussel 2020-06-24 15:14:35 UTC
the solution here is to simply not ship any skel files and not clutter new users's homes. What we do need to keep is the bin directory though. That is important for 3rd party installers.
Comment 3 Ruediger Oertel 2020-09-11 09:10:00 UTC
in aaa_base we only have
/etc/skel/.emacs
/etc/skel/.inputrc

werner can we move these last two to the respective packages ?
readline for the .inputrc and some common package for the .emacs
base stub ?
Comment 4 Ludwig Nussel 2020-09-11 09:18:16 UTC
or rather drop them without replacement. They are just cluttering new users homes.
Comment 5 Stefan Dirsch 2020-09-11 10:35:30 UTC
I don't buy this argument. I meanwhile have about 400 dotfiles/dotdirs in my SUSE"s  $HOME (exists since 1999) and 8 are coming
from /etc/skel. So I would say using a $HOME for a longer time dotfiles coming from /etc/skel would be not more than 5%-10%. The remaining dotfiles/dotdirs are coming from program creating them on demand.
Comment 6 Stefan Dirsch 2020-09-11 10:40:25 UTC
I think best would be to work with /usr/etc/skel and /etc/skel as it's proposed in 

  https://en.opensuse.org/openSUSE:Packaging_UsrEtc#Variant_3

For this we would need a patch for useradd at least (shadow package). I don't know whether there are other programs/scripts
on our distribution adding users and the initial $HOME for them. Is YaST using useradd? I have no idea ...
Comment 7 Dr. Werner Fink 2020-09-15 06:44:49 UTC
(In reply to Ruediger Oertel from comment #3)
> in aaa_base we only have
> /etc/skel/.emacs
> /etc/skel/.inputrc
> 
> werner can we move these last two to the respective packages ?
> readline for the .inputrc and some common package for the .emacs
> base stub ?

The .emacs belongs to GNU Emacs as well as to X Emacs ... the .inputrc to every progrqm using libreadline (not only bash does this).  Not sure if X Emacs should require GNU Emacs or e.g. gnuplot require the bash:

 rpm -q --whatrequires 'libreadline.so.7()(64bit)' | wc -l
 42

(In reply to Ludwig Nussel from comment #4)
> or rather drop them without replacement. They are just cluttering new users
> homes.

Why do we drop all possible user based configurations?  This is how users can do this and without such templates the skeleton feature of useradd becomes rather useless.

(In reply to Stefan Dirsch from comment #6)
> I think best would be to work with /usr/etc/skel and /etc/skel as it's
> proposed in 
> 
>   https://en.opensuse.org/openSUSE:Packaging_UsrEtc#Variant_3
> 
> For this we would need a patch for useradd at least (shadow package). I
> don't know whether there are other programs/scripts
> on our distribution adding users and the initial $HOME for them. Is YaST
> using useradd? I have no idea ...

YaST does make use of the skeleton ... if it happesn by using useradd (what is very likly) I have not tested, but a test user foobar shows after leaving with OK the user/group menue shows a valid user home with all templates from the skeleton package.
Comment 8 Ruediger Oertel 2020-09-15 08:23:24 UTC
I don't have a good idea for emacs.

for the readline config I thought about having a "readline-config" subpackage
of the readline package to be required by the libreadline binary packages.
wrong approach ? on the other hand this is extremely esoteric since I can
not envision any system without a libreadline installed, such the file would
be more often forced into the system than with the current location in
aaa_base-extras ...

summary: for the aaa_base side I'd just move the two files from etc/skel
to usr/etc/skel if useradd can deal with that.
Comment 9 Stefan Dirsch 2020-09-15 09:22:45 UTC
Werner, didn't you want to drop xemacs anyway? ;-) So just move /etc/skel/.emacs to GNU emacs package ...

useradd would need a patch to handle both - /etc/skel and /usr/etc/skel - in this order. It would be easy to switch skel dir for useradd to /usr/etc/skel, but this would be a loss in functionality as the sysadmin no longer can adjust the skeleton settings ...
Comment 10 Dr. Werner Fink 2020-09-15 10:08:31 UTC
(In reply to Stefan Dirsch from comment #9)
> Werner, didn't you want to drop xemacs anyway? ;-) So just move
> /etc/skel/.emacs to GNU emacs package ...

That would be a possiblity which will bounce any X Emacs user on his/her nose ;)

> 
> useradd would need a patch to handle both - /etc/skel and /usr/etc/skel - in
> this order. It would be easy to switch skel dir for useradd to
> /usr/etc/skel, but this would be a loss in functionality as the sysadmin no
> longer can adjust the skeleton settings ...

Isn't that a decision of the maintainers of package shadow?  Indeed it is a feature to give the system admin the possiblity to decide which templates from /usr/etc/skel will be part of /etc/skel and which not. Nevertheless a README which has to be ignored by useradd would be an option.
Comment 11 Stefan Dirsch 2020-09-15 11:38:00 UTC
Created attachment 841688 [details]
useradd.local.patch

This patch for useradd.local implements copying of skel files from /usr/etc/skel, which don't exist in /etc/skel.
Comment 12 Stefan Dirsch 2020-09-15 11:39:36 UTC
That would be the only needed change for shadow package. Feel free to review the patch.
Comment 13 Ruediger Oertel 2020-09-15 12:47:03 UTC
adding mvetter as shadow package maintainer
Comment 14 Ludwig Nussel 2020-09-21 08:13:21 UTC
(In reply to Dr. Werner Fink from comment #7)
> (In reply to Ludwig Nussel from comment #4)
> > or rather drop them without replacement. They are just cluttering new users
> > homes.
> 
> Why do we drop all possible user based configurations?  This is how users
> can do this and without such templates the skeleton feature of useradd
> becomes rather useless.

Maybe I was misleading. Of course useradd needs to support /usr/etc/skel and /etc/skel. The point for aaa_base is that the files we ship there so far have very little value. Ie the inputrc is just comments and the code in the emacs file should be in the global emacs config if it's useful. That way even existing users would benefit from that code and we can even fix/extend it in the future. There's no need to copy templates/boiler plates into user homes.
Comment 15 Ruediger Oertel 2020-09-21 09:04:51 UTC
I can not answer that question, the files are in aaa_base only due to the lack
of another "common" package to hold them.

werner ?
Comment 16 Stefan Dirsch 2020-09-23 11:30:16 UTC
Let's reassing to shadow package maintainer.
Comment 17 Stefan Dirsch 2020-10-02 20:46:30 UTC
Werner? Michael, could you have a look at my patch? (comment #11)
Comment 18 Dr. Werner Fink 2020-10-05 07:10:03 UTC
(In reply to Stefan Dirsch from comment #11)
> Created attachment 841688 [details]
> useradd.local.patch
> 
> This patch for useradd.local implements copying of skel files from
> /usr/etc/skel, which don't exist in /etc/skel.

With

  shopt -s dotglob

it would be possible to use

  shopt -s dotglob
  for file in ${USRSKELDIR}/*; do
      file=${file##*/}
      # Only copy if not exist yet, i.e. does *not* exist in /etc/skel, which is still
      # being preferred ...
      test -e $HOMEDIR/$file && continue
      cp -a $USRSKELDIR/$file $HOMEDIR
      chown -R $USER.$GID $HOMEDIR/$file
  done
Comment 19 Stefan Dirsch 2020-10-05 08:53:07 UTC
That's magic to me, but if it works and has been tested. Wonderful! :-)
Comment 20 Stefan Dirsch 2020-10-09 10:12:47 UTC
Werner, could you submit a shadow package with your useradd patch, please? You could even accept it then yourself, since you're maintainer of Base:System.
Comment 21 Dr. Werner Fink 2020-10-09 10:44:26 UTC
(In reply to Stefan Dirsch from comment #20)
> Werner, could you submit a shadow package with your useradd patch, please?
> You could even accept it then yourself, since you're maintainer of
> Base:System.

Hmmm ... it looks like there is a change

--- /usr/sbin/useradd.local     2020-06-08 22:12:52.000000000 +0200
+++ tmp/useradd.local   2020-10-09 12:28:23.143661000 +0200
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh

... which leads to the fact that ``shopt -s dotglob`` might not work with /bin/sh not linked to bash


Fri May 22 11:21:15 UTC 2020 - Fabian Vogt <fvogt@suse.com>

- Use pure #!/bin/sh in:
  * useradd.local
  * userdel-post.local
  * userdel-pre.local
Comment 22 Stefan Dirsch 2020-10-09 10:47:17 UTC
So revert this for useradd.local. ;-)
Comment 23 Dr. Werner Fink 2020-10-09 11:03:40 UTC
Fabian? What is the rational for this switch from bash to sh?
Comment 24 Michael Vetter 2020-10-09 11:15:59 UTC
(In reply to Stefan Dirsch from comment #20)
> Werner, could you submit a shadow package with your useradd patch, please?
> You could even accept it then yourself, since you're maintainer of
> Base:System.

Hi! Sorry for the long delay. I was on vacation. Being back now I can accept the SR once it's ready.
Comment 25 Fabian Vogt 2020-10-09 11:20:53 UTC
(In reply to Dr. Werner Fink from comment #23)
> Fabian? What is the rational for this switch from bash to sh?

That shadow can be used without bash, for instance with busybox sh or dash. That was a requirement for carwos and can be useful outside of that as well, especially because it didn't need any changes beyond that.
Comment 26 Dr. Werner Fink 2020-10-09 11:26:19 UTC
(In reply to Fabian Vogt from comment #25)
> (In reply to Dr. Werner Fink from comment #23)
> > Fabian? What is the rational for this switch from bash to sh?
> 
> That shadow can be used without bash, for instance with busybox sh or dash.
> That was a requirement for carwos and can be useful outside of that as well,
> especially because it didn't need any changes beyond that.

Hmm ... then there is no way that the ``sh'' is able to list hidden files anymore.
Comment 27 Dr. Werner Fink 2020-10-09 11:33:41 UTC
 > busybox-static sh
 $ for f in /etc/skel/*; do echo $f ; done
 /etc/skel/bin
 $ 

...

 > dash
 $ for f in /etc/skel/*; do echo $f ; done
 /etc/skel/bin
 $ 

now this requires the usage e.g. of `-A` option of the `ls` command/builtin

 > busybox-static sh
 $ ls -A /etc/skel    
 .bash_history  .claws-mail  .dvipsrc  .fonts      .i18n     .local   .profile   .xim.template      bin
 .bashrc        .config      .emacs    .gnu-emacs  .inputrc  .muttrc  .urlview  .xinitrc.template

 > dash
 $ ls -A /etc/skel
 .bash_history  .claws-mail  .dvipsrc  .fonts      .i18n     .local   .profile   .xim.template     bin
 .bashrc        .config      .emacs    .gnu-emacs  .inputrc  .muttrc  .urlview  .xinitrc.template
Comment 28 Dr. Werner Fink 2020-10-09 11:43:10 UTC
Also there is code above in useradd.local which looks like this


# If SELinux is enabled, we have to run restorecon to assign
# appropriate fcontexts to the respective $HOME and files under it
if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled ; then
  test -x /sbin/restorecon || exit 2

  if [ $# -lt 4 ]; then
    home_dir=/home/$1
  else
    home_dir=$4
  fi

  if [ -d $home_dir ]; then
      /sbin/restorecon -R $home_dir
  fi
fi

... therefore the HOME dsetting in Stefan approach might be wrong
(e.g. if useradd has seen four arguments with an other HOME dir)
Comment 29 Dr. Werner Fink 2020-10-09 11:51:28 UTC
Created attachment 842468 [details]
An other approach

any comments and/or suggestions?
Comment 30 OBSbugzilla Bot 2020-10-09 13:50:13 UTC
This is an autogenerated message for OBS integration:
This bug (1173321) was mentioned in
https://build.opensuse.org/request/show/840431 Factory / shadow
Comment 31 Stefan Dirsch 2020-10-09 14:09:39 UTC
(In reply to Dr. Werner Fink from comment #29)
> Created attachment 842468 [details]
> An other approach
> 
> any comments and/or suggestions?

The first 

  HOMEDIR=$HOME/$USER

is not needed, but I think it doesn't hurt either. Thanks for submitting the patch!
Comment 32 Dr. Werner Fink 2020-10-09 14:26:03 UTC
(In reply to Stefan Dirsch from comment #31)
> (In reply to Dr. Werner Fink from comment #29)
> > Created attachment 842468 [details]
> > An other approach
> > 
> > any comments and/or suggestions?
> 
> The first 
> 
>   HOMEDIR=$HOME/$USER
> 
> is not needed, but I think it doesn't hurt either. Thanks for submitting the
> patch!

Indeed doppelt gemoppelt ... done twice
Comment 33 Stefan Dirsch 2020-10-19 02:15:28 UTC
(In reply to OBSbugzilla Bot from comment #30)
> This is an autogenerated message for OBS integration:
> This bug (1173321) was mentioned in
> https://build.opensuse.org/request/show/840431 Factory / shadow

Yeah. It has been accepted. Bug can be closed, i.e. packages now can move their skel files to /usr/etc/skel. But this doesn't need to be tracked here.
Comment 34 OBSbugzilla Bot 2020-10-20 10:50:07 UTC
This is an autogenerated message for OBS integration:
This bug (1173321) was mentioned in
https://build.opensuse.org/request/show/842793 Factory / filesystem
Comment 35 OBSbugzilla Bot 2020-11-11 12:20:07 UTC
This is an autogenerated message for OBS integration:
This bug (1173321) was mentioned in
https://build.opensuse.org/request/show/847777 Factory / shadow
Comment 40 Michael Vetter 2023-01-13 08:12:52 UTC
This has now been upstreamed: https://github.com/shadow-maint/shadow/pull/591