[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#133640: A fix



severity 133640 important
thanks

This bug would be 'grave' if hurd-i386 was a released architecture.
Basically, it makes every init-script running S-S-D segfault when called
as 'stop' or 'restart'. This completely breaks package updates of
daemons.

I've tested the below patch now for a couple of weeks and it works well.
The patch still applies cleanly, albeit with a bit of fuzz.

See http://lists.debian.org/debian-hurd/2004/04/msg00037.html and
http://lists.debian.org/debian-hurd/2004/05/index.html as well as their
follow-ups for some feedback. I've also built dpkg on GNU/Linux with
this patch and I did not experience a regression there.

I've just talked to Neal again and he still thinks the patch is good.
So, could you please apply it for your next upload? This is really a
nasty showstopper for the Hurd port right now.


Thanks,

Michael

On Sat, Feb 23, 2002 at 05:00:07PM -0500, Neal H Walfield wrote:
> Here is a patch to fix the problem.  I am not sure that it is the best
> fix as I do not completely understand the internal interfaces.
> 
> What I have gathered is that do_procinit is a misnomer.  From
> examining the other implementations (for OpenBSD, Linux and SunOS
> based systems), I conclude that it is only used to verify that the
> /proc filesystem is mounted and is not in fact an initialization
> routine.  I reach this later conclusion based on the fact that it is
> not consistently called.
> 
> My solution is to empty do_procinit (the Hurd implementation does not
> depend on it) and introduce a new constructor (do_libpsinit) to
> initialize some structures that we use for libps.  This fixes the
> reported segmentation fault.
> 
> In fixing the segmentation fault, I ran across two other bugs in the
> Hurd implementation: pid_is_user throws a fatal error if the pid does
> not exist as does pid_is_cmd.  Instead, they should just return
> failure.  The attached patch also fixes this.
> 
> Thanks.
> 
> --- start-stop-daemon.c.orig	Sat Feb 23 16:18:02 2002
> +++ start-stop-daemon.c	Sat Feb 23 16:45:46 2002
> @@ -628,9 +628,10 @@ pid_is_user(pid_t pid, uid_t uid)
>  		return 0;
>  	return (sb.st_uid == uid);
>  	pstat = proc_stat_list_pid_proc_stat (procset, pid);
> -	if (pstat == NULL)
> -		fatal ("Error getting process information: NULL proc_stat struct");
> -	proc_stat_set_flags (pstat, PSTAT_PID | PSTAT_OWNER_UID);
> +	if (pstat)
> +		proc_stat_set_flags (pstat, PSTAT_PID | PSTAT_OWNER_UID);
> +	else
> +		return 1;
>  	return (pstat->owner_uid == uid);
>  }
>  
> @@ -639,9 +640,10 @@ pid_is_cmd(pid_t pid, const char *name)
>  {
>  	struct proc_stat *pstat;
>  	pstat = proc_stat_list_pid_proc_stat (procset, pid);
> -	if (pstat == NULL)
> -		fatal ("Error getting process information: NULL proc_stat struct");
> -	proc_stat_set_flags (pstat, PSTAT_PID | PSTAT_ARGS);
> +	if (pstat)
> +		proc_stat_set_flags (pstat, PSTAT_PID | PSTAT_ARGS);
> +	else
> +		return 1;
>  	return (!strcmp (name, pstat->args));
>  }
>  #endif /* OSHURD */
> @@ -722,6 +724,14 @@ check_all (void *ptr)
>  
>  static void
>  do_procinit(void)
> +{
> +        /* Nothing to do. */
> +}
> +
> +static void do_libpsinit(void)  __attribute__ ((constructor));
> +
> +static void
> +do_libpsinit(void)
>  {
>  	struct ps_context *context;
>  	error_t err;
> 
> 
> 



Reply to: