List:Commits« Previous MessageNext Message »
From:Tatjana Azundris Nuernberg Date:October 17 2012 6:59am
Subject:bzr push into mysql-5.6 branch (tatjana.nuernberg:4486 to 4487) Bug#11764559
View as plain text  
 4487 Tatjana Azundris Nuernberg	2012-10-17 [merge]
      Bug#11764559: UMASK IS IGNORED BY ERROR LOG
      
      mysqld_safe script did not heed MySQL specific environment variable
      $UMASK, leading to divergent behavior between mysqld and mysqld_safe.
      
      Patch adds an approximation of mysqld's behavior to mysqld_safe,
      within the bounds dictated by attempt to have mysqld_safe run on
      even the most basic of shells (proper '70s sh, not just bash
      with a fancy symlink).
      
      Patch also adds approximation of said behavior to mysqld_multi
      (in perl).
      
      (backport)
      
      auto-merge

    modified:
      scripts/mysqld_multi.sh
      scripts/mysqld_safe.sh
 4486 Marko Mäkelä	2012-10-17
      dict_set_corrupted(): Initialize the trailing NUL byte of table_name.

    modified:
      storage/innobase/dict/dict0dict.cc
=== modified file 'scripts/mysqld_multi.sh'
--- a/scripts/mysqld_multi.sh	2011-09-20 09:31:05 +0000
+++ b/scripts/mysqld_multi.sh	2012-10-17 06:56:13 +0000
@@ -48,6 +48,28 @@ $homedir = $ENV{HOME};
 $my_progname = $0;
 $my_progname =~ s/.*[\/]//;
 
+
+if (defined($ENV{UMASK})) {
+  my $UMASK = $ENV{UMASK};
+  my $m;
+  my $fmode = "0640";
+
+  if(($UMASK =~ m/[^0246]/) || ($UMASK =~ m/^[^0]/) || (length($UMASK) != 4)) {
+    printf("UMASK must be a 3-digit mode with an additional leading 0 to indicate octal.\n");
+    printf("The first digit will be corrected to 6, the others may be 0, 2, 4, or 6.\n"); }
+  else {
+    $fmode= substr $UMASK, 2, 2;
+    $fmode= "06${fmode}"; }
+
+  if($fmode != $UMASK) {
+    printf("UMASK corrected from $UMASK to $fmode ...\n"); }
+
+  $fmode= oct($fmode);
+
+  umask($fmode);
+}
+
+
 main();
 
 ####

=== modified file 'scripts/mysqld_safe.sh'
--- a/scripts/mysqld_safe.sh	2012-09-11 14:37:44 +0000
+++ b/scripts/mysqld_safe.sh	2012-10-17 06:56:13 +0000
@@ -32,7 +32,28 @@ syslog_tag_mysqld_safe=mysqld_safe
 trap '' 1 2 3 15			# we shouldn't let anyone kill us
 trap '' 13                              # not even SIGPIPE
 
-umask 007
+# MySQL-specific environment variable. First off, it's not really a umask,
+# it's the desired mode. Second, it follows umask(2), not umask(3) in that
+# octal needs to be explicit. Our shell might be a proper sh without printf,
+# multiple-base arithmetic, and binary arithmetic, so this will get ugly.
+# We reject decimal values to keep things at least half-sane.
+umask 007                               # fallback
+UMASK="${UMASK-0640}"
+fmode=`echo "$UMASK" | sed -e 's/[^0246]//g'`
+octalp=`echo "$fmode"|cut -c1`
+fmlen=`echo "$fmode"|wc -c|sed -e 's/ //g'`
+if [ "x$octalp" != "x0" -o "x$UMASK" != "x$fmode" -o "x$fmlen" != "x5" ]
+then
+  fmode=0640
+  echo "UMASK must be a 3-digit mode with an additional leading 0 to indicate octal." >&2
+  echo "The first digit will be corrected to 6, the others may be 0, 2, 4, or 6." >&2
+fi
+fmode=`echo "$fmode"|cut -c3-4`
+fmode="6$fmode"
+if [ "x$UMASK" != "x0$fmode" ]
+then
+  echo "UMASK corrected from $UMASK to 0$fmode ..."
+fi
 
 defaults=
 case "$1" in
@@ -547,6 +568,12 @@ then
   # Log to err_log file
   log_notice "Logging to '$err_log'."
   logging=file
+
+  if [ ! -e "$err_log" ]; then                  # if error log already exists,
+    touch "$err_log"                            # we just append. otherwise,
+    chmod "$fmode" "$err_log"                   # fix the permissions here!
+  fi
+
 else
   if [ -n "$syslog_tag" ]
   then
@@ -758,6 +785,12 @@ do
 
   eval_log_error "$cmd"
 
+  if [ $want_syslog -eq 0 -a ! -e "$err_log" ]; then
+    touch "$err_log"                    # hypothetical: log was renamed but not
+    chown $user "$err_log"              # flushed yet. we'd recreate it with
+    chmod "$fmode" "$err_log"           # wrong owner next time we log, so set
+  fi                                    # it up correctly while we can!
+
   end_time=`date +%M%S`
 
   if test ! -f "$pid_file"		# This is removed if normal shutdown

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.6 branch (tatjana.nuernberg:4486 to 4487) Bug#11764559Tatjana Azundris Nuernberg17 Oct