Skip to contentSkip to conversation

Problems with SElinux and MySQL accessing file on /tmp

DISCUSSION Jason 3 participants 4 messages Apr 19, 2005 – Apr 20, 2005 SELinux security module

lore
Share & tools
lore

Jason

author
#0 lore raw

I am having an error with selinux that I can't seem to fix.

avc: denied { getattr } for pid=123 exe=/usr/libexec/mysqld

I get that when I try to use a mysql query "load data concurrent infile '/tmp/filename' etc"

allow mysqld_t tmp_t:dir { getattr }; doesn't help. I need a way to give mysql getattr globally, or at least in the tmp folder. in filecontexts, /tmp/.* is listed as <<none>>

the file it's accessing in /tmp is user_u:object_r:tmp_t

audit2allow doesn't display anything since it's a denied { getattr } without any other info.

Does anyone have an idea what can be done?

TIA,

Jason

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 8 lines · Jason

I get that when I try to use a mysql query "load data concurrent infile
'/tmp/filename' etc"

allow mysqld_t tmp_t:dir { getattr }; doesn't help. I need a way to give mysql getattr globally, or at least in the tmp folder. in filecontexts, /tmp/.* is listed as <<none>>

the file it's accessing in /tmp is user_u:object_r:tmp_t

The following policy should allow what you want:
allow mysqld_t tmp_t:file r_file_perms;

However this might not be ideal for security reasons, there may be data in files labeled as tmp_t.

Maybe a better option would be to create a directory named /var/lib/mysql/tmp for temporary files related to mysql (it will have type mysqld_db_t which grants full access to mysqld_t). Then you won't be granting any extra access to mysqld_t and you won't need to change your policy.

Signature · 10 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
author
#2 lore raw

Russell,

You are my hero :)

I decided to go with your advice - simple and effective. I have my sql files written in the /var/lib/mysql/tmp directory. Now mysql has access, and selinux doesn't complain. Woo!

Thanks,

Jason

Quoted 9 lines · Russell Coker

The following policy should allow what you want:
allow mysqld_t tmp_t:file r_file_perms;

However this might not be ideal for security reasons, there may be data in files labeled as tmp_t.

Maybe a better option would be to create a directory named /var/lib/mysql/tmp for temporary files related to mysql (it will have type mysqld_db_t which grants full access to mysqld_t). Then you won't be granting any extra access to mysqld_t and you won't need to change your policy.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#3 lore raw
In reply to Jason
Quoted 10 lines · Jason

I am having an error with selinux that I can't seem to fix.

avc: denied { getattr } for pid=123 exe=/usr/libexec/mysqld

I get that when I try to use a mysql query "load data concurrent infile '/tmp/filename' etc"

allow mysqld_t tmp_t:dir { getattr }; doesn't help. I need a way to give mysql getattr globally, or at least in the tmp folder. in filecontexts, /tmp/.* is listed as <<none>>

the file it's accessing in /tmp is user_u:object_r:tmp_t

Quoted 12 lines

audit2allow doesn't display anything since it's a denied { getattr } without any other info.

Does anyone have an idea what can be done?

TIA,

Jason

Signature · 3 lines
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.

What AVC messages are you seeing in /var/log/messages or /var/log/audit/audit.log?

Dan

Signature · 4 lines
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.