Skip to contentSkip to conversation

[patch]

PATCH In review Luke Kenneth Casson Leighton 2 participants 4 messages Jun 5, 2004 – Jun 6, 2004 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 [patch]

patch to exim4 to get it to change its name when it execve's on:

- transport (-MC)
- smtp in
- alias (-bi)
- initial daemon startup

you have to start exim4 in /etc/init.d/exim4 as exim4-daemon not exim4.

you'll need to symlink exim4 to exim4-MC, exim4-bi and exim4-in for "non-selinux" and other testing purposes.

i don't know if it's possible to create domain auto transitions on a symlink, but if it _was_ then the policy files could, i imagine, have file_contexts for exim4_mc_exec_t etc just on the symlinks.

*shrug*.

l.

Signature · 9 lines
-- 
expecting email to be received and understood is a bit like
picking up the telephone and immediately dialing without
checking for a dial-tone; speaking immediately without listening
for either an answer or ring-tone; hanging up immediately and
believing that you have actually started a conversation.
--
<a href="http://lkcl.net">      lkcl.net      </a> <br />
<a href="mailto:[email protected]"> [email protected] </a> <br />
src/exim.c renamed from exim-4.34/src/exim.c +6 -0
diff -ru orig/exim-4.34/src/exim.c exim4-4.34/src/exim.c
@@ -3002,6 +3002,12 @@
     DEBUG(D_exec) debug_printf("exec %.256s %.256s\n", argv[0],
       (argv[1] == NULL)? US"" : argv[1]);
 
+    /* for SE/Linux to write a tiny program to change security domain
+     * specifically to deal with -bi, we change the name to exim-bi.
+     * non-SELinux systems can symbolic link exim-bi to exim.
+     */
+    argv[0] = string_sprintf("%s-bi", argv[0]);
+
     execv(CS argv[0], (char *const *)argv);
     fprintf(stderr, "exim: exec failed: %s\n", strerror(errno));
     exit(EXIT_FAILURE);
src/smtp_in.c renamed from exim-4.34/src/smtp_in.c +8 -0
diff -ru orig/exim-4.34/src/smtp_in.c exim4-4.34/src/smtp_in.c
@@ -3372,6 +3372,14 @@
 
       if (!smtp_etrn_serialize || (pid = fork()) == 0)
         {
+	 /* change the name of the daemon to exec to an exim-in instead
+	  * this is so that SE/Linux can create a tiny program that
+	  * sets up a separate security domain for incoming SMTP,
+	  * and of course non-SE/Linux systems can symbolic link exim-in
+	  * to exim.
+	  */
+	 argv[0] = string_sprintf("%s-in", argv[0]);
+
         DEBUG(D_exec) debug_print_argv(argv);
         exim_nullstd();                   /* Ensure std{in,out,err} exist */
         execv(CS argv[0], (char *const *)argv);

Only in exim4-4.34/src: tags

src/transport.c renamed from exim-4.34/src/transport.c +6 -0
diff -ru orig/exim-4.34/src/transport.c exim4-4.34/src/transport.c
@@ -1585,6 +1585,12 @@
     close(socket_fd);
     }
 
+  /* for SE/Linux systems we run a tiny program that changes security
+   * domain to deal with transports (exim-MC).
+   * non-SELinux systems can always symbolic link exim-MC to exim
+   */
+  argv[0] = string_sprintf("%s-MC", argv[0]);
+
   DEBUG(D_exec) debug_print_argv(argv);
   exim_nullstd();                          /* Ensure std{out,err} exist */
   execv(CS argv[0], (char *const *)argv);
src/exim.c renamed from exim-4.34/src/exim.c +6 -0
diff -ru orig/exim-4.34/src/exim.c exim4-4.34/src/exim.c
@@ -3002,6 +3002,12 @@
     DEBUG(D_exec) debug_printf("exec %.256s %.256s\n", argv[0],
       (argv[1] == NULL)? US"" : argv[1]);
 
+    /* for SE/Linux to write a tiny program to change security domain
+     * specifically to deal with -bi, we change the name to exim-bi.
+     * non-SELinux systems can symbolic link exim-bi to exim.
+     */
+    argv[0] = string_sprintf("%s-bi", argv[0]);
+
     execv(CS argv[0], (char *const *)argv);
     fprintf(stderr, "exim: exec failed: %s\n", strerror(errno));
     exit(EXIT_FAILURE);
src/smtp_in.c renamed from exim-4.34/src/smtp_in.c +8 -0
diff -ru orig/exim-4.34/src/smtp_in.c exim4-4.34/src/smtp_in.c
@@ -3372,6 +3372,14 @@
 
       if (!smtp_etrn_serialize || (pid = fork()) == 0)
         {
+	 /* change the name of the daemon to exec to an exim-in instead
+	  * this is so that SE/Linux can create a tiny program that
+	  * sets up a separate security domain for incoming SMTP,
+	  * and of course non-SE/Linux systems can symbolic link exim-in
+	  * to exim.
+	  */
+	 argv[0] = string_sprintf("%s-in", argv[0]);
+
         DEBUG(D_exec) debug_print_argv(argv);
         exim_nullstd();                   /* Ensure std{in,out,err} exist */
         execv(CS argv[0], (char *const *)argv);

Only in exim4-4.34/src: tags

src/transport.c renamed from exim-4.34/src/transport.c +6 -0
diff -ru orig/exim-4.34/src/transport.c exim4-4.34/src/transport.c
@@ -1585,6 +1585,12 @@
     close(socket_fd);
     }
 
+  /* for SE/Linux systems we run a tiny program that changes security
+   * domain to deal with transports (exim-MC).
+   * non-SELinux systems can always symbolic link exim-MC to exim
+   */
+  argv[0] = string_sprintf("%s-MC", argv[0]);
+
   DEBUG(D_exec) debug_print_argv(argv);
   exim_nullstd();                          /* Ensure std{out,err} exist */
   execv(CS argv[0], (char *const *)argv);

Only in exim4-4.34/: unpack-configs-stamp

#1 lore raw
Quoted 8 lines · Luke Kenneth Casson Leighton

patch to exim4 to get it to change its name when it execve's on:

- transport (-MC)
- smtp in
- alias (-bi)
- initial daemon startup

From a quick inspection it appears that you missed some calls to

child_exec_exim(), for example the "exim -q" operation when starting exim.

Quoted 4 lines

i don't know if it's possible to create domain auto transitions on a symlink, but if it _was_ then the policy files could, i imagine, have file_contexts for exim4_mc_exec_t etc just on the symlinks.

No, domain_auto_trans() rules only apply to the executables and to script files (but generally don't do transitions on scripts).

For SE Linux we need small executables that will exec exim4 with the same parameters to give the domain transition.

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.
#2 lore raw
Quoted 10 lines · Russell Coker
Quoted 6 lines · Luke Kenneth Casson Leighton

patch to exim4 to get it to change its name when it execve's on:

- transport (-MC)
- smtp in
- alias (-bi)
- initial daemon startup

From a quick inspection it appears that you missed some calls to child_exec_exim(), for example the "exim -q" operation when starting exim.

oh, drat :)

thanks - that's the sort of thing i needed to know.

... ah, yes, you're right! _sometimes_ it does an execv inside child_exec_exim and sometimes it doesn't. *sigh*.

Quoted 10 lines
Quoted 4 lines

i don't know if it's possible to create domain auto transitions on a symlink, but if it _was_ then the policy files could, i imagine, have file_contexts for exim4_mc_exec_t etc just on the symlinks.

No, domain_auto_trans() rules only apply to the executables and to script files (but generally don't do transitions on scripts).

For SE Linux we need small executables that will exec exim4 with the same parameters to give the domain transition.

ack.

i haven't changed any of the parameters, so you'd still get exim-bi -bi ... and exim-MC -MC .... etc.

l.

--
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
Quoted 9 lines · Luke Kenneth Casson Leighton
Quoted 8 lines
Quoted 4 lines

- transport (-MC)
- smtp in
- alias (-bi)
- initial daemon startup

From a quick inspection it appears that you missed some calls to child_exec_exim(), for example the "exim -q" operation when starting exim.

Quoted 6 lines

oh, drat :)

thanks - that's the sort of thing i needed to know.

... ah, yes, you're right! _sometimes_ it does an execv inside child_exec_exim and sometimes it doesn't. *sigh*.

Well child_exec_exim() has code to check the main parameter for the purpose of error logging. It shouldn't be difficult to add some code in that checks the parameter against a table to determine what (if anything) to append to the command name.

Quoted 7 lines
Quoted 2 lines

For SE Linux we need small executables that will exec exim4 with the same parameters to give the domain transition.

ack.

i haven't changed any of the parameters, so you'd still get exim-bi -bi ... and exim-MC -MC .... etc.

Yes, so the following code should be all that's needed for a minimal implementation. It may be necessary to have the code check that argv[1] is appropriate for the domain that the new instance of exim4 is to be run in, but I'm not certain about that (we can do it later if necessary). Also we need something similar for runq etc.

int main(int argc, char **argv, char **envp)
{
return execve("/usr/sbin/exim4", argv, envp);
}

Signature · 9 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.