Bug #79608 mysqld_safe mishandles UMASK
Submitted: 11 Dec 2015 18:36 Modified: 13 Dec 2015 14:27
Reporter: Paul Dubois Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: Options Severity:S3 (Non-critical)
Version:5.1+, 5.7.10 OS:Any
Assigned to: CPU Architecture:Any

[11 Dec 2015 18:36] Paul Dubois
I discovered this problem while investigating Bug#78808.

The reference manual says that UMASK (and UMASK_DIR) can be given in octal if the value starts with a zero. (Which implies that without a zero the value is in decimal.) And the examples at
show the use of decimal values (no leading zero).

However, mysqld_safe contains code that examines UMASK and seems to require octal?

How to repeat:
Following the example at

$ UMASK=384
$ export UMASK
$ ./mysqld_safe&
UMASK must be a 3-digit mode with an additional leading 0 to indicate octal.
The first digit will be corrected to 6, the others may be 0, 2, 4, or 6.
UMASK corrected from 384 to 0640 ...

The error message is confusing.

Does it mean that UMASK can be
* 3 digits in decimal
* 4 digits in octal

Or does it mean that UMASK *must* be a 4-digit octal value where the first digit is 0?

In any case, it doesn't accept a value as shown in the manual.

The example *does work* in MySQL 5.0, by the way. The addition UMASK code seems to have been added to mysqld_safe sometime during the MySQL 5.1 series. (Perhaps as a result of Bug#57406?)

Suggested fix:
Either handle UMASK as the manual says it should be handled (decimal unless a leading zero is given to indicate octal),
- or -
Require UMASK to be octal whether or not specified with a leading zero.

The second alternative is probably wrong, because you can start the server without using mysqld_safe (e.g., on systemd systems) and the code in the server itself interprets UMASK as decimal or octal depending on whether there is a leading digit. (See atoi_octal() in mysys/my_init.c.) That's consistent with the manual.

mysqld_multi has code to produce a similar UMASK message, by the way. It may be broken the same way as mysqld_safe.
[13 Dec 2015 14:27] Umesh Shastry
Hello Paul,

Thank you for the report.
Verified as described with 5.7.10 build.