Bug#855912: db_purge: exits with error code 8 when using deluser in the same postinst

2017-05-21 Thread Colin Watson
Control: severity -1 normal
Control: merge 782463 -1

On Tue, Apr 11, 2017 at 03:53:00PM +, Niels Thykier wrote:
> Have you had a chance to review this bug?  AFAICT, it got
> clone+reassigned without you explicitly being CC'ed, so I am leaving the
> full mail quoted below for your sake.

Sorry, yes.  This is basically the same as #782463, and it doesn't need
to be RC since it's been the case forever.  For that matter it's more or
less the same as the gotcha documented in debconf-devel(7), albeit for
the postinst rather than the postrm (but the considerations are
basically the same):

   *  Avoid outputting anything to stdout in your postinst,
  since that can confuse debconf, and postinst should not
  be verbose anyway. Output to stderr is ok, if you must.

Another good workaround for this type of problem, and Maximiliano, this
is something you should do anyway in sddm, is to put:

  . /usr/share/debconf/confmodule

... at the *top* of your postrm, just below the #! line and any "set -e"
or similar command, even if dh_installdebconf also inserts a fragment
later that includes that line.  That way, the confmodule's redirection
of stdout to stderr will take effect early enough to be useful.  Often
more importantly, this avoids problems caused by the fact that sourcing
the confmodule re-execs the calling script, which can cause weird
problems if you weren't expecting all the code before the confmodule is
sourced to be called twice, which you probably weren't.  This is
documented under HACKS in debconf-devel(7).

Thanks,

-- 
Colin Watson   [cjwat...@debian.org]



Bug#855912: db_purge: exits with error code 8 when using deluser in the same postinst

2017-04-11 Thread Niels Thykier
Hi Debconf maintainers,

Have you had a chance to review this bug?  AFAICT, it got
clone+reassigned without you explicitly being CC'ed, so I am leaving the
full mail quoted below for your sake.

~Niels

On Thu, 23 Feb 2017 11:39:08 +0100 Maximiliano Curia 
wrote:
> Control: clone -1 -2
> Control: reassign -2 debconf 1.5.60
> Control: retitle -2 db_purge: exits with error code 8 when using deluser in 
> the same postinst
> 
> ¡Hola Laurent!
> 
> El 2017-02-01 a las 13:31 +0100, Laurent Bonnaud escribió:
> > Package: sddm 
> > Version: 0.14.0-1 
> > Severity: serious
> 
> > here is the problem:
> 
> > # apt purge sddm   sddm-theme-breeze 
> > Reading package lists... Done 
> > Building dependency tree 
> > Reading state information... Done 
> > The following packages will be REMOVED:
> >  sddm* sddm-theme-breeze* 
> > 0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded. 
> > After this operation, 2 595 kB disk space will be freed. 
> > Do you want to continue? [Y/n]
> > (Reading database ... 261837 files and directories currently installed.) 
> > Removing sddm (0.14.0-1) 
> > .]
> > Please be sure to run "dpkg-reconfigure gdm3". 
> > Removing sddm-theme-breeze (4:5.8.5-1) ... 
> > Processing triggers for man-db (2.7.6.1-2) ... 
> > (Reading database ... 261663 files and directories currently installed.) 
> > Purging configuration files for sddm (0.14.0-1) ... 
> > Removing user `sddm' ... 
> > Warning: group `sddm' has no more members. 
> > userdel: user sddm is currently used by process 658 
> > /usr/sbin/deluser: `/usr/sbin/userdel sddm' returned error code 8. Exiting. 
> > Could not remove sddm user. 
> > /usr/sbin/delgroup: `sddm' still has `sddm' as their primary group! 
> > Could not remove sddm group.
> 
> > Stopping the service before the purge fixes the problem.
> 
> This is the expected output when sddm is still running. We don't want to stop 
> the running display manager as it will kill the graphical user session.
> 
> > userdel: user sddm is currently used by process 658 
> > /usr/sbin/deluser: `/usr/sbin/userdel sddm' returned error code 8. Exiting. 
> > /usr/sbin/delgroup: `sddm' still has `sddm' as their primary group!
> 
> This part is not caused by us. Mmh, after a closer inspection this is caused 
> by the debconf purge, which get's confused with any message written to stdout.
> 
> I'm cloning the issue to debconf, as it would be better if db_purge wouldn't 
> be 
> trying to parse whatever was printed to the stdout.
> 
> On the sddm usecase, I'll add the deluser and echo redirections (>&2).
> 
> Happy hacking,
> -- 
> A computer scientist is someone who, when told to "Go to Hell,"
> sees the "go to," rather than the destination, as harmful.
>  Saludos /\/\ /\ >< `/