user guide drafts: Maintaining SELinux Labels
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 41 lines · Mike R (US SSA)
Quoted 3 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]On
Quoted 6 lines
Behalf Of Glenn Faden
Sent: Wednesday, October 08, 2008 8:46 AM
To: Daniel J Walsh
Cc: Murray McAllister; SE Linux
Subject: Re: user guide drafts: Maintaining SELinux LabelsQuoted 16 lines
Quoted 15 lines · Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 10 lines · Murray McAllister
Hi,
The following are the first few drafts of the "Maintaining SELinux Labels" sections. Any comments and corrections are appreciated.
Cheers.
Copying Files and Directories
When files and directories are copied, they inherit the SELinux
context
Quoted 1 line
Quoted 1 line
Quoted 1 line
of the parent directory they are copied to. This helps ensure files
and
Quoted 1 line
Quoted 1 line
Quoted 1 line
directories are labeled with the correct SELinux context after
being
Quoted 1 line
Quoted 1 line
Quoted 1 line
moved. The following example demonstrates copying a file from a
user's
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
home directory to
/var/www/html/, which is used by the Apache HTTP Server. Since the file is copied, it inherits the correct SELinuxcontext:
Is this true when using MLS policy? Assuming the policy allows asubject
Quoted 2 lines
to create a file in a directory, shouldn't the newly created file's SELinux context have the same sensitivity as the subject who wrote it?
Quoted 10 lines
Quoted 1 line
Or is the new file's type copied from the directory and the
sensitivity
Quoted 1 line
copied from the subject?
You are correct, the type is copied from the directory and the level is copied from the subject. It might also be worth mentioning that the type is copied from the directory as default behavior, which can be overridden with
type_transitionstatements.Quoted 1 line
--Glenn
I've changed the first paragraph. How about:
When files and directories are copied, they inherit the SELinux context of the parent directory they are copied to[1]. This helps ensure files and directories are labeled with the correct SELinux context after being copied. Also, when a file is copied over an existing file, the existing file's context is maintained. On systems running the MLS policy, when files are copied, they inherit the type from the parent directory they are being copied to, and the level from the process that copied them.
Is the last sentence, is "the level from the process that copied them" correct? Should it be "from the process or user that..."?
[1] By default, the type is copied from the parent directory. This behavior can be overridden by using type_transition statements in custom SELinux policies.
I've included an example at the end of the section to show copying a file over an existing one.
Thanks for your feedback.
--
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.
Quoted 51 lines · Murray McAllister
Quoted 50 lines · Mike R (US SSA)
Quoted 3 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]On
Quoted 6 lines
Behalf Of Glenn Faden
Sent: Wednesday, October 08, 2008 8:46 AM
To: Daniel J Walsh
Cc: Murray McAllister; SE Linux
Subject: Re: user guide drafts: Maintaining SELinux LabelsQuoted 16 lines
Quoted 15 lines · Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 10 lines · Murray McAllister
Hi,
The following are the first few drafts of the "Maintaining SELinux Labels" sections. Any comments and corrections are appreciated.
Cheers.
Copying Files and Directories
When files and directories are copied, they inherit the SELinux
context
Quoted 1 line
Quoted 1 line
Quoted 1 line
of the parent directory they are copied to. This helps ensure files
and
Quoted 1 line
Quoted 1 line
Quoted 1 line
directories are labeled with the correct SELinux context after
being
Quoted 1 line
Quoted 1 line
Quoted 1 line
moved. The following example demonstrates copying a file from a
user's
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
home directory to
/var/www/html/, which is used by the Apache HTTP Server. Since the file is copied, it inherits the correct SELinuxcontext:
Is this true when using MLS policy? Assuming the policy allows asubject
Quoted 4 lines
to create a file in a directory, shouldn't the newly created file's SELinux context have the same sensitivity as the subject who wrote it?
Or is the new file's type copied from the directory and the
sensitivity
Quoted 1 line
copied from the subject?
You are correct, the type is copied from the directory and the level is copied from the subject. It might also be worth mentioning that the type is copied from the directory as default behavior, which can be overridden with
type_transitionstatements.
Quoted 5 lines
Quoted 1 line
Quoted 1 line
--Glenn
I've changed the first paragraph. How about:
When files and directories are copied, they inherit the SELinux context of the parent directory they are copied to[1].
Not exactly, no. The security context of a new file is computed from a combination of the security context of the creating process and the security context of the parent directory, and may further be adjusted by policy rules. The user identity and level are inherited from the creating process. The role is always object_r presently. The type is inherited from the parent directory unless there is a type transition rule in the policy for the (creating process domain, parent directory type, file object class) triple. For example, when a process creates a file in /tmp, there is usually a type transition rule defined such that each domain gets its own private temporary file type.
Quoted 4 lines
This helps ensure files
and directories are labeled with the correct SELinux context after being copied. Also, when a file is copied over an existing file, the existing file's context is maintained.
Unless the user specified options to cp to preserve the context of the original on the copy.
Quoted 20 lines
On systems running the MLS policy, when
files are copied, they inherit the type from the parent directory they are being copied to, and the level from the process that copied them.Is the last sentence, is "the level from the process that copied them" correct? Should it be "from the process or user that..."?
[1] By default, the type is copied from the parent directory. This behavior can be overridden by using
type_transitionstatements in custom SELinux policies.I've included an example at the end of the section to show copying a file over an existing one.
Thanks for your feedback.
--
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.
Signature · 8 lines
Stephen Smalley National Security Agency -- 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.
Quoted 65 lines · Stephen Smalley
Quoted 48 lines · Murray McAllister
Quoted 47 lines · Mike R (US SSA)
Quoted 2 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]On
Quoted 6 lines
Behalf Of Glenn Faden
Sent: Wednesday, October 08, 2008 8:46 AM
To: Daniel J Walsh
Cc: Murray McAllister; SE Linux
Subject: Re: user guide drafts: Maintaining SELinux LabelsQuoted 16 lines
Quoted 15 lines · Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 10 lines · Murray McAllister
Hi,
The following are the first few drafts of the "Maintaining SELinux Labels" sections. Any comments and corrections are appreciated.
Cheers.
Copying Files and Directories
When files and directories are copied, they inherit the SELinux
context
Quoted 1 line
Quoted 1 line
Quoted 1 line
of the parent directory they are copied to. This helps ensure files
and
Quoted 1 line
Quoted 1 line
Quoted 1 line
directories are labeled with the correct SELinux context after
being
Quoted 1 line
Quoted 1 line
Quoted 1 line
moved. The following example demonstrates copying a file from a
user's
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
home directory to
/var/www/html/, which is used by the Apache HTTP Server. Since the file is copied, it inherits the correct SELinuxcontext:
Is this true when using MLS policy? Assuming the policy allows asubject
Quoted 3 lines
to create a file in a directory, shouldn't the newly created file's SELinux context have the same sensitivity as the subject who wrote it? Or is the new file's type copied from the directory and the
sensitivity
Quoted 1 line
copied from the subject?
You are correct, the type is copied from the directory and the level is copied from the subject. It might also be worth mentioning that the type is copied from the directory as default behavior, which can be overridden with
type_transitionstatements.Quoted 4 lines
Quoted 1 line
Quoted 1 line
--Glenn
I've changed the first paragraph. How about:
When files and directories are copied, they inherit the SELinux context of the parent directory they are copied to[1].
Not exactly, no. The security context of a new file is computed from a combination of the security context of the creating process and the security context of the parent directory, and may further be adjusted by policy rules. The user identity and level are inherited from the creating process. The role is always
object_rpresently. The type is inherited from the parent directory unless there is a type transition rule in the policy for the (creating process domain, parent directory type, file object class) triple. For example, when a process creates a file in /tmp, there is usually a type transition rule defined such that each domain gets its own private temporary file type.
Quoted 5 lines
Quoted 2 lines
This helps ensure files
and directories are labeled with the correct SELinux context after being copied. Also, when a file is copied over an existing file, the existing file's context is maintained.Unless the user specified options to cp to preserve the context of the original on the copy.
Thanks. How about:
When files and directories are copied, the SELinux context of the new file or directory depends on the context of the creating process, and the context of the target, parent directory: the type is inherited from the target, parent directory (unless a type transition rule exists[1]); the SELinux user identity and level are inherited from the creating process; and the role is always object_r, which is a generic role for files. This helps ensure files and directories are labeled with the correct SELinux context after being copied.
Also, when a file is copied over an existing file, the existing file's context is maintained, unless the user specified cp options to preserve the context of the original file, such as --preserve=context.
#Is the following required, or is it covered by the above:
On systems running the MLS policy, when files and directories are copied, they inherit the type from the parent directory they are being copied to, and the level from the process that copied them.
[1] By default, the type is copied from the parent directory. This behavior can be overridden by using type_transition statements in custom SELinux policies. Type transition rules are for a creating process domain, parent directory type, and file object class triple. For example, when a process creates a file in /tmp/, a type transition rule is usually defined so that each domain gets its own private, temporary file type.
Quoted 7 lines
Quoted 7 lines
On systems running the MLS policy, when
files are copied, they inherit the type from the parent directory they are being copied to, and the level from the process that copied them.Is the last sentence, is "the level from the process that copied them" correct? Should it be "from the process or user that..."?
[1] By default, the type is copied from the parent directory. This behavior can be overridden by using
type_transitionstatements in custom SELinux policies.
Quoted 8 lines
Quoted 8 lines
I've included an example at the end of the section to show copying a file over an existing one.
Thanks for your feedback.
--
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.
--
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.
Quoted 8 lines · Murray McAllister
When files and directories are copied, the SELinux context of the new file or directory depends on the context of the creating process, and the context of the target, parent directory: the type is inherited from the target, parent directory (unless a type transition rule exists[1]); the SELinux user identity and level are inherited from the creating process; and the role is always
object_r, which is a generic role for files. This helps ensure files and directories are labeled with the correct SELinux context after being copied.
I'm not sure how the last sentence is supposed to link with the rest - it certainly doesn't correspond to the second-last sentence.
object_r is for future support and also to give a regular format of the context for all operations. Note that files under /proc that relate to processes have different roles.
Quoted 3 lines
Also, when a file is copied over an existing file, the existing file's context is maintained, unless the user specified cp options to preserve the context of the original file, such as --preserve=context.
Also the -Z option to cp deserves a mention.
Quoted 5 lines
#Is the following required, or is it covered by the above:
On systems running the MLS policy, when files and directories are copied, they inherit the type from the parent directory they are being copied to, and the level from the process that copied them.
Probably.
Signature · 9 lines
[email protected] http://etbe.coker.com.au/ My Blog http://www.coker.com.au/sponsorship.html Sponsoring Free Software development -- 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.
Quoted 11 lines · Russell Coker
Quoted 8 lines · Murray McAllister
When files and directories are copied, the SELinux context of the new file or directory depends on the context of the creating process, and the context of the target, parent directory: the type is inherited from the target, parent directory (unless a type transition rule exists[1]); the SELinux user identity and level are inherited from the creating process; and the role is always
object_r, which is a generic role for files. This helps ensure files and directories are labeled with the correct SELinux context after being copied.I'm not sure how the last sentence is supposed to link with the rest - it certainly doesn't correspond to the second-last sentence.
That was from the old, wrong text. I moved it around a little:
When files and directories are copied, the SELinux context of the new file or directory depends on the context of the creating process, and the context of the target, parent directory. This helps ensure files and directories are labeled with the correct SELinux context after being copied. When files and directories are copied, the type is inherited...
Quoted 2 lines
object_ris for future support and also to give a regular format of the context for all operations. Note that files under /proc that relate to processes have different roles.
I could only find the system_r and object_r roles in /proc/. Are there any others? /proc/pid/* seem to only use system_r (I did not check everything).
How about:
object_r is a generic role for used most files. Under the /proc/ directory, files relating to processes may use the system_r role.
Thanks again for your help.
Quoted 7 lines
Quoted 4 lines
Also, when a file is copied over an existing file, the existing file's context is maintained, unless the user specified cp options to preserve the context of the original file, such as --preserve=context.
Also the -Z option to cp deserves a mention.
Quoted 8 lines
Quoted 5 lines
#Is the following required, or is it covered by the above:
On systems running the MLS policy, when files and directories are copied, they inherit the type from the parent directory they are being copied to, and the level from the process that copied them.
Probably.
--
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.
Quoted 7 lines · Murray McAllister
Quoted 3 lines
object_ris for future support and also to give a regular format of the context for all operations. Note that files under /proc that relate to processes have different roles.I could only find the
system_randobject_rroles in/proc/. Are there any others?/proc/pid/*seem to only usesystem_r(I did not check everything).
Run in a "strict" configuration and you will see staff_r, user_r, and sysadm_r, with MLS you will see secadm_r.
Quoted 3 lines
How about:
object_ris a generic role for used most files.
All filesystem objects on persistent storage or network filesystems.
Quoted 2 lines
Under the
/proc/
directory, files relating to processes may use thesystem_rrole.
Or the other four roles I listed, and maybe others with customised policy.
Back in 2002 I had machines running with 16 roles and I had the policy working well for creating arbitrary roles with minimal effort.
Signature · 9 lines
[email protected] http://etbe.coker.com.au/ My Blog http://www.coker.com.au/sponsorship.html Sponsoring Free Software development -- 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.
Quoted 4 lines · Murray McAllister
How about:
object_ris a generic role for used most files. Under the/proc/directory, files relating to processes may use thesystem_rrole.
/proc is a pseudo filesystem generated by the kernel and the security contexts of /proc/pid nodes are identical to the security context of the associated process. Thus, any process role can be found in /proc. But processes cannot create files there.
Quoted 22 lines
Thanks again for your help.
Quoted 7 lines
Quoted 4 lines
Also, when a file is copied over an existing file, the existing file's context is maintained, unless the user specified cp options to preserve the context of the original file, such as --preserve=context.
Also the -Z option to cp deserves a mention.
Quoted 8 lines
Quoted 5 lines
#Is the following required, or is it covered by the above:
On systems running the MLS policy, when files and directories are copied, they inherit the type from the parent directory they are being copied to, and the level from the process that copied them.
Probably.
--
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.
Signature · 8 lines
Stephen Smalley National Security Agency -- 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.
Quoted 4 lines · Stephen Smalley
/proc is a pseudo filesystem generated by the kernel and the security contexts of
/proc/pidnodes are identical to the security context of the associated process. Thus, any process role can be found in /proc. But processes cannot create files there.
Except by calling fork().
Sorry, I felt the need to be pedantic. ;)
Signature · 10 lines
[email protected] http://etbe.coker.com.au/ My Blog http://www.coker.com.au/sponsorship.html Sponsoring Free Software development -- 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.
Quoted 9 lines · Russell Coker
Quoted 4 lines · Stephen Smalley
/proc is a pseudo filesystem generated by the kernel and the security contexts of
/proc/pidnodes are identical to the security context of the associated process. Thus, any process role can be found in /proc. But processes cannot create files there.Except by calling
fork().Sorry, I felt the need to be pedantic. ;)
Next you'll be arguing that processes can delete files in proc by calling exit()...
Signature · 8 lines
Stephen Smalley National Security Agency -- 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.
Quoted 12 lines · Russell Coker
Quoted 8 lines · Murray McAllister
When files and directories are copied, the SELinux context of the new file or directory depends on the context of the creating process, and the context of the target, parent directory: the type is inherited from the target, parent directory (unless a type transition rule exists[1]); the SELinux user identity and level are inherited from the creating process; and the role is always
object_r, which is a generic role for files. This helps ensure files and directories are labeled with the correct SELinux context after being copied.I'm not sure how the last sentence is supposed to link with the rest - it certainly doesn't correspond to the second-last sentence.
Quoted 7 lines
object_ris for future support and also to give a regular format of the context for all operations. Note that files under /proc that relate to processes have different roles.Quoted 3 lines
Also, when a file is copied over an existing file, the existing file's context is maintained, unless the user specified cp options to preserve the context of the original file, such as --preserve=context.
Also the -Z option to cp deserves a mention.
I started changing the examples to show cp, cp --preserve=context, and cp -Z. I had problems with cp -Z on rawhide and fedora 9[1], so I will leave that out for now.
Cheers.
[1] <https://bugzilla.redhat.com/show_bug.cgi?id=466653>
--
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.
Quoted 10 lines · Murray McAllister
Thanks. How about:
When files and directories are copied, the SELinux context of the new file or directory depends on the context of the creating process, and the context of the target, parent directory: the type is inherited from the target, parent directory (unless a type transition rule exists[1]); the SELinux user identity and level are inherited from the creating process; and the role is always
object_r, which is a generic role for files. This helps ensure files and directories are labeled with the correct SELinux context after being copied.
It still seems a bit confusing to read. Part of the issue is that you are confusing two things above:
- file copying,
- new file creation
The default labeling rules apply whenever a new file is created at runtime. File copying is a particular case where a new file is created, and there are two situations for it:
- (default) New file is created in accordance with the usual default labeling rules, thereby _not_ necessarily preserving the context of the original file but rather reflecting the runtime properties of the new file. Example: When a top secret process copies an unclassified file, the new file is necessarily top secret, not unclassified.
- (when using options to preserve context of the original file) New file is created with the context of the original file, thereby preserving the context of the original and _not_ reflecting the runtime properties of the new file. The ability to do this is limited by policy and may fail for a variety of reasons, e.g.:
1) the process may not be authorized to create files with the original file label (e.g. top secret process may not create unclassified file, user_t process may not create an etc_t file),
2) the file security context may not be allowed to exist within the target file system (e.g. top secret file may not be created within a filesystem capped at secret, passwd_exec_t file may not be created on removable media).
Quoted 37 lines
Also, when a file is copied over an existing file, the existing file's context is maintained, unless the user specified cp options to preserve the context of the original file, such as --preserve=context.
#Is the following required, or is it covered by the above:
On systems running the MLS policy, when files and directories are copied, they inherit the type from the parent directory they are being copied to, and the level from the process that copied them.
[1] By default, the type is copied from the parent directory. This behavior can be overridden by using
type_transitionstatements in custom SELinux policies. Type transition rules are for a creating process domain, parent directory type, and file object class triple. For example, when a process creates a file in/tmp/, a type transition rule is usually defined so that each domain gets its own private, temporary file type.Quoted 20 lines
Quoted 20 lines
On systems running the MLS policy, when
files are copied, they inherit the type from the parent directory they are being copied to, and the level from the process that copied them.Is the last sentence, is "the level from the process that copied them" correct? Should it be "from the process or user that..."?
[1] By default, the type is copied from the parent directory. This behavior can be overridden by using
type_transitionstatements in custom SELinux policies.I've included an example at the end of the section to show copying a file over an existing one.
Thanks for your feedback.
--
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.
Signature · 8 lines
Stephen Smalley National Security Agency -- 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.
Quoted 22 lines · Stephen Smalley
Quoted 3 lines · Murray McAllister
Thanks. How about:
When files and directories are copied, the SELinux context of the new file or directory depends on the context of the creating process, and the context of the target, parent directory: the type is inherited from the target, parent directory (unless a type transition rule exists[1]); the SELinux user identity and level are inherited from the creating process; and the role is always
object_r, which is a generic role for files. This helps ensure files and directories are labeled with the correct SELinux context after being copied.It still seems a bit confusing to read. Part of the issue is that you are confusing two things above:
- file copying,
- new file creationThe default labeling rules apply whenever a new file is created at runtime. File copying is a particular case where a new file is created, and there are two situations for it:
- (default) New file is created in accordance with the usual default labeling rules, thereby _not_ necessarily preserving the context of the original file but rather reflecting the runtime properties of the new file. Example: When a top secret process copies an unclassified file, the new file is necessarily top secret, not unclassified.
- (when using options to preserve context of the original file) New file is created with the context of the original file, thereby preserving the context of the original and _not_ reflecting the runtime properties of the new file. The ability to do this is limited by policy and may fail
Quoted 8 lines
for a variety of reasons, e.g.:
1) the process may not be authorized to create files with the original file label (e.g. top secret process may not create unclassified file,user_tprocess may not create anetc_tfile),
2) the file security context may not be allowed to exist within the target file system (e.g. top secret file may not be created within a filesystem capped at secret,passwd_exec_tfile may not be created on removable media).
Is that because of the file systems on most removable media, or something else?
I made an ext3 file system on an USB drive, and "cp --preserve=context /usr/bin/passwd /removable/media" preserved the passwd_exect_t type. I tested this on Red Hat Enterprise Linux 5.2 and Fedora Rawhide.
I started the section again. Hopefully it is almost right now :(
Copying Files and Directories
When a file or directory is copied, a new file or directory is created if it does not exist. That new file or directory's context is based on default-labeling rules, not the original file or directory's context (unless options were used to preserve the original context). For example, files created in user home directories are labeled with the user_home_t type:
$ touch file1 $ ls -Z file1 -rw-rw-r-- user1 group1 unconfined_u:object_r:user_home_t:s0 file1
If such a file is copied to another directory, such as /etc/, the new file is created in accordance to default-labeling rules for the /etc/ directory. Copying a file (without additional options) may not preserve the original context:
$ ls -Z file1 -rw-rw-r-- user1 group1 unconfined_u:object_r:user_home_t:s0 file1 # cp file1 /etc/ $ ls -Z /etc/file1 -rw-r--r-- root root unconfined_u:object_r:etc_t:s0 /etc/file1
When file1 is copied to /etc/, if /etc/file1 does not exist, /etc/file1 is created as a new file. As shown in the example above, /etc/file1 is labeled with the etc_t type, in accordance to default-labeling rules.
When a file is copied over an existing file, the existing file's context is preserved, unless the user specified cp options to preserve the context of the original file, such as --preserve=context. SELinux policy may prevent contexts from being preserved during copies.
Quoted 15 lines
Quoted 15 lines
Also, when a file is copied over an existing file, the existing file's context is maintained, unless the user specified cp options to preserve the context of the original file, such as --preserve=context.
#Is the following required, or is it covered by the above:
On systems running the MLS policy, when files and directories are copied, they inherit the type from the parent directory they are being copied to, and the level from the process that copied them.
[1] By default, the type is copied from the parent directory. This behavior can be overridden by using
type_transitionstatements in custom SELinux policies. Type transition rules are for a creating process domain, parent directory type, and file object class triple. For example, when a process creates a file in/tmp/, a type transition rule is usually defined so that each domain gets its own private, temporary file type.Quoted 7 lines
Quoted 7 lines
On systems running the MLS policy, when
files are copied, they inherit the type from the parent directory they are being copied to, and the level from the process that copied them.Is the last sentence, is "the level from the process that copied them" correct? Should it be "from the process or user that..."?
[1] By default, the type is copied from the parent directory. This behavior can be overridden by using
type_transitionstatements in custom SELinux policies.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
I've included an example at the end of the section to show copying a file over an existing one.
Thanks for your feedback.
--
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.
--
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.
Quoted 11 lines · Murray McAllister
Quoted 4 lines · Stephen Smalley
2) the file security context may not be allowed to exist within the target file system (e.g. top secret file may not be created within a filesystem capped at secret,
passwd_exec_tfile may not be created on removable media).Is that because of the file systems on most removable media, or something else?
I made an ext3 file system on an USB drive, and "cp --preserve=context
/usr/bin/passwd/removable/media" preserved thepasswd_exect_ttype. I tested this on Red Hat Enterprise Linux 5.2 and Fedora Rawhide.
That's because you didn't mount that filesystem with a context= mount option. Which hald and friends ought to do for removable media by default. There are two situations:
- the filesystem on the removable media may not support extended attributes at all, or
- the filesystem on the removable media may support them but we may not want to trust removable media in the same way we apply nosuid nodev typically when mounting it.
Quoted 26 lines
I started the section again. Hopefully it is almost right now :(
Copying Files and Directories
When a file or directory is copied, a new file or directory is created if it does not exist. That new file or directory's context is based on default-labeling rules, not the original file or directory's context (unless options were used to preserve the original context). For example, files created in user home directories are labeled with the
user_home_ttype:$ touch file1 $ ls -Z file1 -rw-rw-r-- user1 group1 unconfined_u:object_r:user_home_t:s0 file1If such a file is copied to another directory, such as
/etc/, the new file is created in accordance to default-labeling rules for the/etc/directory. Copying a file (without additional options) may not preserve the original context:$ ls -Z file1 -rw-rw-r-- user1 group1 unconfined_u:object_r:user_home_t:s0 file1 # cp file1 /etc/ $ ls -Z /etc/file1 -rw-r--r-- root root unconfined_u:object_r:etc_t:s0 /etc/file1
Quoted 8 lines
When file1 is copied to
/etc/, if/etc/file1does not exist,/etc/file1is created as a new file. As shown in the example above,/etc/file1is labeled with theetc_ttype, in accordance to default-labeling rules.When a file is copied over an existing file, the existing file's context is preserved, unless the user specified cp options to preserve the context of the original file, such as --preserve=context. SELinux policy may prevent contexts from being preserved during copies.
Sounds better.
Signature · 8 lines
Stephen Smalley National Security Agency -- 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.