Re: [PATCH] login: fix signal race

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

 



On Mon, Sep 25, 2017 at 09:54:11PM +0200, Tobias Stoeckmann wrote:
> The functions warnx(3) and gettext(3) are not safe to use within signal
> handlers and should be avoided. Preparing the message beforehand and
> calling write(2) as well as calling _exit(2) solves the problem.

Applied with small changes:

>  po/ca.po            |  6 +++---
>  po/cs.po            |  6 +++---
>  po/da.po            |  6 +++---
>  po/de.po            |  6 +++---
>  po/es.po            |  6 +++---
>  po/et.po            |  6 +++---
>  po/eu.po            |  4 ++--
>  po/fi.po            |  6 +++---
>  po/fr.po            |  6 +++---
>  po/gl.po            |  4 ++--
>  po/hr.po            |  4 ++--
>  po/hu.po            |  6 +++---
>  po/id.po            |  6 +++---
>  po/it.po            |  6 +++---
>  po/ja.po            |  6 +++---
>  po/nl.po            |  6 +++---
>  po/pl.po            |  6 +++---
>  po/pt_BR.po         |  6 +++---
>  po/ru.po            |  6 +++---
>  po/sl.po            |  6 +++---
>  po/sv.po            |  6 +++---
>  po/tr.po            |  6 +++---
>  po/uk.po            |  6 +++---
>  po/util-linux.pot   |  4 ++--
>  po/vi.po            |  6 +++---
>  po/zh_CN.po         |  6 +++---
>  po/zh_TW.po         |  6 +++---

Please, don't send patches with po/ stuff ("git checkout -f po/" is fine), it's
updated before release by maintainer.

>  static void timedout(int sig __attribute__ ((__unused__)))
>  {
>  	signal(SIGALRM, timedout2);
>  	alarm(10);
> -	/* TRANSLATORS: The standard value for %u is 60. */
> -	warnx(_("timed out after %u seconds"), timeout);
> +	write(STDERR_FILENO, timeout_msg, strlen(timeout_msg));

It seems we need our ignore_result() here to keep compiler happy, because
write() is marked as warn_unused_result in glibc header files...

>  	signal(SIGALRM, SIG_IGN);
>  	alarm(0);
>  	timedout2(0);
> @@ -1134,6 +1134,13 @@ int main(int argc, char **argv)
>  
>  	timeout = (unsigned int)getlogindefs_num("LOGIN_TIMEOUT", LOGIN_TIMEOUT);
>  
> +	setlocale(LC_ALL, "");
> +	bindtextdomain(PACKAGE, LOCALEDIR);
> +	textdomain(PACKAGE);
> +
> +	/* TRANSLATORS: The standard value for %u is 60. */
> +	snprintf(timeout_msg, sizeof(timeout_msg),
> +	    _("%s: timed out after %u seconds"), argv[0], timeout);

I've replaced argv[0] with program_invocation_short_name.

Thanks, good catch!

	Karel
-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux