All of lore.kernel.org
 help / color / mirror / Atom feed
* getfilecon() and friends in libselinux
@ 2004-12-08 17:13 Joshua Brindle
  2004-12-08 17:20 ` Stephen Smalley
  0 siblings, 1 reply; 4+ messages in thread
From: Joshua Brindle @ 2004-12-08 17:13 UTC (permalink / raw)
  To: selinux

Some applications in setools, namely findcon, replcon and indexcon walk 
the filesystem and get the file context off files. Previously it was 
fairly known what filesystems supported labeling so they were defined 
during the build process but now that other filesystems (reiser, jfs and 
tmpfs) support labeling but aren't necessarilly widespread we can't 
reliably define the supported filesystems during the build process and 
expect it to work across systems.

The idea is to iterate the filesystem mount points and do a getfilecon() 
or similar on a file in it, then examine the error code returned to 
decide if the filesystem supports xattr and also supports the security 
namespace. Is this a stable API to rely on for this? Will the error 
codes remain stable?

Further, if there is ever support for contexts via psids or something 
that isn't xattr will getfilecon() also be a supported method for 
accessing those?

Joshua Brindle
Tresys Technology

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: getfilecon() and friends in libselinux
  2004-12-08 17:13 getfilecon() and friends in libselinux Joshua Brindle
@ 2004-12-08 17:20 ` Stephen Smalley
  2004-12-08 19:36   ` Casey Schaufler
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Smalley @ 2004-12-08 17:20 UTC (permalink / raw)
  To: Joshua Brindle; +Cc: selinux

On Wed, 2004-12-08 at 12:13, Joshua Brindle wrote:
> The idea is to iterate the filesystem mount points and do a getfilecon() 
> or similar on a file in it, then examine the error code returned to 
> decide if the filesystem supports xattr and also supports the security 
> namespace. Is this a stable API to rely on for this? Will the error 
> codes remain stable?

Yes, getfilecon() should return -1 with errno EOPNOTSUPP if the
filesystem does not support xattrs at all or if the filesystem does not
support the security namespace.

> Further, if there is ever support for contexts via psids or something 
> that isn't xattr will getfilecon() also be a supported method for 
> accessing those?

Yes - even if we were to implement a persistent label mapping (or
something similar to what was done for reiserfs) for a given filesystem,
we would still export it via the xattr API, and thus getfilecon() (or
lgetfilecon or fgetfilecon) would still be the preferred interface for
getting the file context.

-- 
Stephen Smalley <sds@epoch.ncsc.mil>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: getfilecon() and friends in libselinux
  2004-12-08 17:20 ` Stephen Smalley
@ 2004-12-08 19:36   ` Casey Schaufler
  2004-12-08 20:17     ` Stephen Smalley
  0 siblings, 1 reply; 4+ messages in thread
From: Casey Schaufler @ 2004-12-08 19:36 UTC (permalink / raw)
  To: Stephen Smalley, Joshua Brindle; +Cc: selinux



Be careful of virtual file systems (e.g. autofs,
automount) as some implementations have semantics
that differ between the mount point and contained
objects. I have seen device file system
implementations that claimed to implement extended
attributes but that had enormously odd behaviors.


=====
Casey Schaufler
casey@schaufler-ca.com


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: getfilecon() and friends in libselinux
  2004-12-08 19:36   ` Casey Schaufler
@ 2004-12-08 20:17     ` Stephen Smalley
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Smalley @ 2004-12-08 20:17 UTC (permalink / raw)
  To: Casey Schaufler; +Cc: Joshua Brindle, selinux, James Morris, Darrel Goeddel

On Wed, 2004-12-08 at 14:36, Casey Schaufler wrote:
> Be careful of virtual file systems (e.g. autofs,
> automount) as some implementations have semantics
> that differ between the mount point and contained
> objects. I have seen device file system
> implementations that claimed to implement extended
> attributes but that had enormously odd behaviors.

Good point.  A specific example that exists today is devpts; we only
implemented fake xattr handlers for the pty nodes themselves, not for
the root directory, so getfilecon /dev/pts will fail while getfilecon
/dev/pts/0 will succeed.  Darrel Goeddel posted a patch earlier to add
support for the /dev/pts root as well, and there was some discussion of
the need for wider support for getting file contexts without needing to
patch every pseudo filesystem to export xattr handlers.  That latter
should be much easier due to the xattr code consolidation and generic
code created by James Morris, but it would still be nice to have a
fallback in the VFS for the security namespace that would just get the
security attribute from the security module.  That discussion started at
http://marc.theaimsgroup.com/?l=selinux&m=109880845227851&w=2.

-- 
Stephen Smalley <sds@epoch.ncsc.mil>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-12-08 20:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-08 17:13 getfilecon() and friends in libselinux Joshua Brindle
2004-12-08 17:20 ` Stephen Smalley
2004-12-08 19:36   ` Casey Schaufler
2004-12-08 20:17     ` Stephen Smalley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.