Help - Search - Members - Calendar
Full Version: Securing /tmp but allowing innodb
The Planet Forums > Security > General Security > UNIX Security
OllieMaitland
I use have used the ELS script in setting up quite a few machines now as it offers such a quick and easy way of doing the simple configuration tasks at the beginning. On webservers i use the secure /tmp option which remounts /tmp (and other tmp directories) however once I have done this I have issues with mysql accessing the directory for its innodb access.

Is there a way to allow MySQL innodb access to the /tmp directory without undoing the securing. The errors i'm getting (when I try to get MySQL to access the /tmp directory) are:

mysql.log
CODE
060408 22:14:50  mysqld started

/usr/libexec/mysqld: Can't read dir of '/tmp/' (Errcode: 13)

/usr/libexec/mysqld: Can't create/write to file '/tmp/ibUl3jqS' (Errcode: 13)

060408 22:14:50  InnoDB: Error: unable to create temporary file; errno: 13

060408 22:14:50 [ERROR] Can't init databases

060408 22:14:50 [ERROR] Aborting


messages:

CODE
Apr  8 22:14:50 rasgas01 kernel: audit(1144530890.738:17): avc:  denied  { read } for  pid=24125 comm="mysqld" name="/" dev=loop0 ino=2 scontext=root:system_r:mysqld_t tcontext=system_u:object_r:file_t tclass=dir

Apr  8 22:14:50 rasgas01 kernel: audit(1144530890.775:18): avc:  denied  { search } for  pid=24125 comm="mysqld" name="/" dev=loop0 ino=2 scontext=root:system_r:mysqld_t tcontext=system_u:object_r:file_t tclass=dir


CODE
drwxrwxrwt    5 root root  1024 Apr  8 10:24 tmp


CODE
/usr/tmpDSK           496M   11M  460M   3% /tmp


CODE
[root@rasgas01 ~]# ls -l /usr/tmpDSK

-rw-r--r--  1 root root 536870912 Apr  7 21:26 /usr/tmpDSK


I suppose my question boils down to can you set the mysql tmp directory (I couldn't find a config directive) or is there "trick" that I don't know icon_biggrin.gif

Any pointers would be great!
OllieMaitland
Ok, i found the tmpdir directive icon_redface.gif

Where would be the "best" place to put these tmp files if not /tmp? If I try to put it in other directories (/var/mysql_tmp for example) then there is still a problem creating the temporary file.

Should I create a separate partition in the future for mysql temporary file?
Blue|Fusion
Did you have ELS change the MySQL config? If so, be sure that you comment out the skip-innodb line and restart MySQL. As far as /tmp files go with MySQL, it should work even with this security in-place as the changes only prevent binary files from being executed, not from access.

If you do change the tmpdir, I would change it to /var/lib/mysql/tmp. When you do that, you'll have to setup permissions, correctly, too.
OllieMaitland
QUOTE (Blue|Fusion)
Did you have ELS change the MySQL config?


Nope, but i got mysql to run with the skip-innodb directive in place.

QUOTE (Blue|Fusion)
If you do change the tmpdir, I would change it to /var/lib/mysql/tmp.


Cool, I thought about this but wasn't sure because the databases are there but I tried this and it works fine - just guess you don't add a database with the name "tmp" icon_biggrin.gif

Thanks v much for the prompt response icon_smile.gif
Blue|Fusion
That's just what I read after Googling a bit, so yeah, if you need a 'tmp' database, you're SOL until you change that.

And how did you get innodb with skip-innodb in the config? That sort of negates the whole point of the option, lol.
OllieMaitland
QUOTE (Blue|Fusion)
And how did you get innodb with skip-innodb in the config?


hehe, i meant I got mysql to run (i.e. with ISAM databases) rather that MySQL with InnoDB tables too - that would be wierd!
Blue|Fusion
Gotcha, that makes more sense. icon_smile.gif
gbock
[gbock gbock]$ perror 13
OS error code 13: Permission denied
[gbock gbock]$


chown mysql: /var/mysql_tmp/

This would be safer than a 1777 dir and mysql should be the only thing using it.
gbock
I also just noticed your log entries from messages. You are running selinux and will need to add that directory to the security context for mysql.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.