Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 428686 - mail-mta/postfix-2.8.9 with sec-policy/selinux-postfix-2.20120215-r15 doesn't allow sysadm_r to run 'postqueue' command
Summary: mail-mta/postfix-2.8.9 with sec-policy/selinux-postfix-2.20120215-r15 doesn't...
Status: VERIFIED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: SELinux (show other bugs)
Hardware: AMD64 Linux
: Normal minor (vote)
Assignee: Sven Vermeulen (RETIRED)
URL:
Whiteboard: sec-policy r7
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-30 17:39 UTC by Vincent Brillault
Modified: 2012-12-13 10:14 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Brillault 2012-07-30 17:39:23 UTC
When trying to use the "postqueue" command with the latest SELinux policy results in the following errors (blocking the execution):

zsh: permission denied: /usr/sbin/postqueue

avc:  denied  { execute } for  pid=9300 comm="zsh" name="postqueue" dev="sda1" ino=579951 scontext=staff_u:sysadm_r:sysadm_t tcontext=system_u:object_r:postfix_postqueue_exec_t tclass=file

Reproducible: Always

Steps to Reproduce:
1. Install postfix with its SELinux policy on a SELinux aware gentoo
2. Launch postfix daemon in enforcing mode
3. Run /usr/sbin/postqueue -p while in sysadm role
Actual Results:  
zsh: permission denied: /usr/sbin/postqueue
avc:  denied  { execute } for  pid=9325 comm="zsh" name="postqueue" dev="sda1" ino=579951 scontext=staff_u:sysadm_r:sysadm_t tcontext=system_u:object_r:postfix_postqueue_exec_t tclass=file

Expected Results:  
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
 .... (list of ids) ...
-- .... Kbytes in ... Requests.
Comment 1 Sven Vermeulen (RETIRED) gentoo-dev 2012-08-11 19:02:06 UTC
Will be in rev2
Comment 2 Sven Vermeulen (RETIRED) gentoo-dev 2012-08-14 18:58:03 UTC
r2 is now in hardened-dev overlay
Comment 3 Vincent Brillault 2012-08-14 23:15:14 UTC
Great !

I've just test the 'postqueue' command and it seems to work (I've tested the basic commands of postqueue, with no errors so far).

There is still one little problem: Postqueue have a failback mechanism if it is run when postfix is down. It directly access the files to obtain information on the messages. It's a less important feature so I don't know if we really want to support it.

Examples:

*Postfix up:
#postqueue -p
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
.....
-- 2 Kbytes in 1 Request.

*Postfix down, enforce:
#postqueue -p
postqueue: warning: Mail system is down -- accessing queue directly
postqueue: fatal: execv /usr/libexec/postfix/showq: Permission denied

*postfix down, permissive:
postqueue -p
postqueue: warning: Mail system is down -- accessing queue directly
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
...
-- 2 Kbytes in 1 Request.

I can reproduce it with more information (avcs) if you need.
Comment 4 Sven Vermeulen (RETIRED) gentoo-dev 2012-11-10 17:34:23 UTC
I haven't done a thorough investigation of all features, just ran "postqueue -p" to see if I can reproduce (which was indeed the case) and then added in a "can_exec(sysadm_t, postfix_showq_exec_t)" and I didn't get an error anymore.

However, I don't have much postfix experience - is this fallback only to view the queue, or should other operations also work?
Comment 5 Sven Vermeulen (RETIRED) gentoo-dev 2012-11-14 19:35:18 UTC
Ok, can_exec added to repo and will be in r7
Comment 6 Sven Vermeulen (RETIRED) gentoo-dev 2012-11-14 21:11:47 UTC
r7 is now in hardened-dev
Comment 7 Vincent Brillault 2012-11-16 01:17:32 UTC
Sorry for the late answer.

I'm not an expert on postfix but I think that in offline mode, you can theoretically call postqueue or postsuper on non-SELinux system. Nevertheless, for me, listing with postqueue is enough (Last time I tried to use postsuper without postfix running (without SELinux), it didn't work well).


In sysadm.te (in r7) there are only the following rules:
optional_policy(`
        postfix_exec_master(sysadm_t)
        postfix_exec_postqueue(sysadm_t)
        postfix_stream_connect_master(sysadm_t)
')

Shouldn't the can_exec(sysadm_t, postfix_showq_exec_t) be added here (or those rules replaced by postfix_admin(sysadm_t,sysadm_r)) ?
Comment 8 Sven Vermeulen (RETIRED) gentoo-dev 2012-11-16 14:13:09 UTC
I added it in the postfix_admin() interface, as it seems logical that only those domains with postfix_admin() rights should be able to do this.
Comment 9 Sven Vermeulen (RETIRED) gentoo-dev 2012-11-18 15:28:22 UTC
In main tree, ~arch'ed
Comment 10 Sven Vermeulen (RETIRED) gentoo-dev 2012-12-13 10:14:38 UTC
r8 is now stable