Hi Ricardo,

Thanks for your quick response.

For clarification, lcx_all_users_aliases.sh, is a custom file we use and not associated with any package.

The contents of the file are two aliases and one function:

# Drupal root
alias drush7='sudo -u drupal drush --root=/var/www/drupal/drupal7'
alias drush8='sudo -u drupal drush --root=/var/www/drupal/drupal8'

# create backup of file with timestamp
# usage: bkup filename
function bkup ()
  {
    DATE_STAMP=$(date +%Y%m%d-%H%M%S)
    cp -i ${1}{,.bak.${DATE_STAMP}}
  }

I've done a bit more research and testing by altering the contents of the /etc/profile.d file and installing tuptime with each alteration. I installed with:

1. Empty lcx_all_users_aliases.sh - no problem
2. Only the aliases in lcx_all_users_aliases.sh - no problem
3. Only the bash function in lcx_all_users_aliases.sh - ERROR

The installation fails only when the bash function is in the file, so the presence of a function seems to be the issue. I then tried it with several different functions we routinely use to make sure there was nothing specific to the function which caused the problem. The error occurred with each function.

I do not believe it is /bin/sh causing the problem for two reasons. First, I and others have experienced this exact problem with the package sa-compile[1]. In that instance, changing

su - $OWNER -c "sa-compile --quiet"

to

su $OWNER -c "sa-compile --quiet"

and reinstalling fixed the problem. $OWNER is debian-spamd which has a /bin/sh shell.

The "-" or --login option calls a login shell which in turn causes the files in /etc/profile.d to be read. Using su alone does not call an interactive shell and therefore the /etc/profile.d files do not load. You should be able to use the -s option and achieve the intended effect - use of /bin/sh - by changing the line in postinst to:

su -s /bin/sh tuptime -c "tuptime -x"

See, for example, the postgresql-common.postinst file which contains this:
    su -s /bin/sh postgres -c "test -O /var/lib/postgresql &&
            test -G /var/lib/postgresql" || \
        chown postgres:postgres /var/lib/postgresql

There are no issues with postgresql-common installation.

I hope this clarifies the issue.

--
Terry

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=875958

On 23/12/2017 05:23, Ricardo Fraile wrote:
Hi Terry,


I think that the problem is because the user tuptime have the shell "/bin/sh" and the script spect an execution from "/bin/bash". Using "su -" prevent any herietage from the execution user, in this case "root", and normally, this user have the bash shell assigned.

I tried to find the "lcx_all_users_aliases.sh" script but I didn't found anything from the offical repos. Please, can you pass me the content of if? (maybe directly to my address if you have sensitive information).


Thanks,

Reply via email to