Skip to contentSkip to conversation

Useradd patchset - seeking comments..

DISCUSSION Ivan Gyurdiev 5 participants 11 messages Jul 6, 2005 – Jul 12, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

Here [ http://ivan.ivg2.net/selinux/patches/ ]
is an updated patchset that attempts to
accomplish the following:

- provide library routines to easily edit and modify the various selinux data files (users file, file contexts, template file, map file... ) through libselinux, and make some changes to allow alternative backends in the future.

- integrate the utilities useradd/usermod/userdel
with libselinux interface for manipulating users
(currently useradd/userdel...still have to work
on usermod).

- alter the 1:1 user-to-seluser map scheme to
what was discussed per Karl's proposal. Groups
are disallowed. Syntax is subject to change.

- simplify the code necessary to work with and load policy in libsepol - this involves changing policydb to an opaque data structure, and deprecating functions that manipulate the policy (data, len) image. Also, there is a convenient create_policydb function in libselinux.

Patchset is not finished, but I want to see if you have any comments...

--
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

Here's what the patches do in summary:

Fixes headers and a memory leak:
libsepol-0-fix.diff

Debugging enhancements, that I'm still
not happy with:
libselinux-1-debug.diff
libsepol-1-debug.diff

Make policydb an opaque data structure:

checkpolicy-policydb_opaque.diff
policycoreutils-audit2why-policydb_opaque.diff
libsepol-3-policydb_opaque.diff

Introduce functions to easily convert
between (data,len) pair and policydb.

libsepol-4-policydb_convert.diff

User and boolean support, rewritten
to work with policydb, and with
user parsing removed (focusing on
adding sel user into policy):

libsepol-5-users.diff
libsepol-6-bools.diff

Mark things extern:
libsepol-10-extern.diff

Library routines for manipulating files,
that everything else uses:
libselinux-3-records_file.diff

Support for manipulating file contexts, ports,
sel_users, and map entries (in the
user->sel_user map file). Ports are
not implemented yet, just a record.

libselinux-4-context_record.diff
libselinux-5-sel_users.diff
libselinux-5-fscon.diff
libselinux-5-ports.diff
libselinux-6-map.diff

Higher-level interface that works with
the patches above to provide functionality
to add/delete/remap users:

libselinux-7-users.diff

Remove backup files from tarball:
policycoreutils-cleanup.diff

Utility for getting valid roles
from policydb (not sure if it's
needed):
policycoreutils-getroles.diff

Load policy, rewritten to use
libselinux helper routines:
policycoreutils-load_policy.diff

Changes to various utilities to
deal with the new way to map users
to sel users:
policycoreutils-map2.diff

Changes to matchpathcon and genhomedircon
to handle per user file contexts files
(due to lack of a better solution). This
has been hacked a bit to not generate
a file if the sel_user's primary role
matches the default user's primary role. policycoreutils-genhomedircon-move_user_contexts.diff libselinux-8-move_user_contexts.diff

Shadow-utils integration:
shadow-selinux.diff

--
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 11 lines

-----Original Message-----
From: Ivan Gyurdiev [mailto:[email protected]]
Sent: Wednesday, July 06, 2005 5:44 PM
To: Daniel J Walsh
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: Useradd patchset - seeking comments..

Here's what the patches do in summary:

<snip>

Quoted 5 lines

libsepol-6-bools.diff

Mark things extern:
libsepol-10-extern.diff

I'll try to look at these - are they against the latest CVS with the module infrastructure? Quick comment is that I don't think that the extern patch is useful and worth the trouble. Things in headers are, by definition, exported. Extern has no effect and does not add clarity IMHO.
http://www.eskimo.com/~scs/C-faq/q1.11.html

Karl

---
Karl MacMillan
Tresys Technology
http://www.tresys.com
(410) 290-1411 ext 134

Quoted 48 lines

Library routines for manipulating files, that everything else uses:
libselinux-3-records_file.diff

Support for manipulating file contexts, ports, sel_users, and map entries (in the user->sel_user map file). Ports are
not implemented yet, just a record.

libselinux-4-context_record.diff
libselinux-5-sel_users.diff
libselinux-5-fscon.diff
libselinux-5-ports.diff
libselinux-6-map.diff

Higher-level interface that works with the patches above to provide functionality to add/delete/remap users:

libselinux-7-users.diff

Remove backup files from tarball:
policycoreutils-cleanup.diff

Utility for getting valid roles
from policydb (not sure if it's
needed):
policycoreutils-getroles.diff

Load policy, rewritten to use
libselinux helper routines:
policycoreutils-load_policy.diff

Changes to various utilities to
deal with the new way to map users
to sel users:
policycoreutils-map2.diff

Changes to matchpathcon and genhomedircon
to handle per user file contexts files
(due to lack of a better solution). This
has been hacked a bit to not generate
a file if the sel_user's primary role
matches the default user's primary role. policycoreutils-genhomedircon-move_user_contexts.diff libselinux-8-move_user_contexts.diff

Quoted 2 lines

Shadow-utils integration:
shadow-selinux.diff

--
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 3 lines

I'll try to look at these - are they against the latest CVS with the module infrastructure?

No... I need to resync against that.

They're against the patched (rpm -bp):

libsepol-1.6-1
policycoreutils-1.24-1
checkpolicy-1.23.4-1
libselinux-1.24-1
shadow-utils-4.0.7-9

In other words you can't really test them out - just look at code. There's also some evil bugs which I just fixed today
(I got usermod working, and fixed userdel), but I haven't updated patches - most of it should stay the same though.

Quoted 4 lines

Quick comment is that I don't think that the extern patch is
useful and worth the trouble. Things in headers are, by definition, exported. Extern has no effect and does not add clarity IMHO.
http://www.eskimo.com/~scs/C-faq/q1.11.html

Noted, but I don't see why you're complaining, since your patch is already merged, isn't it? - shouldn't create problems for you.

--
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.

#4 lore raw
Quoted 28 lines

-----Original Message-----
From: Ivan Gyurdiev [mailto:[email protected]]
Sent: Thursday, July 07, 2005 2:23 PM
To: Karl MacMillan
Cc: 'Daniel J Walsh'; [email protected]; [email protected]
Subject: RE: Useradd patchset - seeking comments..

Quoted 2 lines

I'll try to look at these - are they against the latest CVS with the module infrastructure?

No... I need to resync against that.

They're against the patched (rpm -bp):

libsepol-1.6-1
policycoreutils-1.24-1
checkpolicy-1.23.4-1
libselinux-1.24-1
shadow-utils-4.0.7-9

In other words you can't really test them out - just look at code. There's also some evil bugs which I just fixed today
(I got usermod working, and fixed userdel), but I haven't updated patches - most of it should stay the same though.

Quoted 2 lines

Quick comment is that I don't think that the extern patch is
useful and worth the trouble. Things in headers are, by definition,

Quoted 7 lines

exported.

Quoted 2 lines

Extern has no effect and does not add clarity IMHO.
http://www.eskimo.com/~scs/C-faq/q1.11.html

Noted, but I don't see why you're complaining, since your patch is already merged, isn't it? - shouldn't create problems for you.

Long term maintenance is everyone's concern and that will not be the last piece of code that we contribute. Also, I don't like the style - I think that people start worrying about the keyword even though it is useless. Verbosity is only useful if it communicates something not already stated.

Karl

---
Karl MacMillan
Tresys Technology
http://www.tresys.com
(410) 290-1411 ext 134

--
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.

#5 lore raw
Quoted 2 lines

Long term maintenance is everyone's concern

Which is why this patch should be merged for clarity.

Quoted 3 lines

Also, I don't like the style - I think that people
start worrying about the keyword even though it is useless. Verbosity is only useful if it communicates something not already stated.

It communicates the storage class of the function, which I believe is not explicitly stated anywhere. It only stated implicitly, and programmers such as myself get confused by the lack of keyword - there's several storage classes to choose from, and this makes it clear. It also allows you to grep the file for extern, which you may want to do for some reason.

You can disagree, but /usr/include/* speaks for itself - the vast majority of headers are explicitly marked extern, which establishes the dominant style.

===============

Also, we should move all headers describing functions not exported by the shared library into a subfolder...

--
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.

#6 lore raw
Quoted 15 lines

-----Original Message-----
From: Ivan Gyurdiev [mailto:[email protected]]
Sent: Thursday, July 07, 2005 4:27 PM
To: Karl MacMillan
Cc: 'Daniel J Walsh'; [email protected]; [email protected]
Subject: RE: Useradd patchset - seeking comments..

Quoted 1 line

Long term maintenance is everyone's concern

Which is why this patch should be merged for clarity.

Quoted 2 lines

Also, I don't like the style - I think that people
start worrying about the keyword even though it is useless. Verbosity is

only

Quoted 9 lines
Quoted 1 line

useful if it communicates something not already stated.

It communicates the storage class of the function, which I believe is not explicitly stated anywhere. It only stated implicitly, and programmers such as myself get confused by the lack of keyword - there's several storage classes to choose from, and this makes it clear. It also allows you to grep the file for extern, which you may want to do for some reason.

There are only 3 options for libraries that I am aware of: static, non-exported, and exported. Having non-exported prototypes in public headers is, to me, very confusing. Most of the confusion about what is exported / not exported in libsepol comes from the fact that it was the bulk of checkpolicy before it became a library. Ideally the confusion would be fixed by other means.

Quoted 4 lines

You can disagree, but /usr/include/* speaks for itself - the vast majority of headers are explicitly marked extern, which establishes the dominant style.

Maybe . . .

Quoted 4 lines

===============

Also, we should move all headers describing functions not exported by the shared library into a subfolder...

Agreed - though that would only support my argument. Anyway - I've stated my opinion and won't argue about this anymore. It is not important enough and Steve will do what he wants anyway :)

Karl

---
Karl MacMillan
Tresys Technology
http://www.tresys.com
(410) 290-1411 ext 134

--
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.

#7 lore raw
In reply to Ivan Gyurdiev
Quoted 15 lines · Ivan Gyurdiev
Quoted 1 line

Long term maintenance is everyone's concern

Which is why this patch should be merged for clarity.

Quoted 3 lines

Also, I don't like the style - I think that people
start worrying about the keyword even though it is useless. Verbosity is only useful if it communicates something not already stated.

It communicates the storage class of the function, which I believe is not explicitly stated anywhere. It only stated implicitly, and programmers such as myself get confused by the lack of keyword - there's several storage classes to choose from, and this makes it clear. It also allows you to grep the file for extern, which you may want to do for some reason.

Quoted 8 lines

You can disagree, but /usr/include/* speaks for itself - the vast majority of headers are explicitly marked extern, which establishes the dominant style.

===============

Also, we should move all headers describing functions not exported by the shared library into a subfolder...

Yes, creating a include/sepol/private or similar and moving the headers associated only with the static library into it would make sense. Not sure if there are any other libraries that have a similar issue with exporting a much wider interface via the static library than the shared library.

As for extern, I don't care either way, just need to be consistent.

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.
#8 lore raw
In reply to Ivan Gyurdiev
Quoted 10 lines · --- Ivan Gyurdiev

Here [ http://ivan.ivg2.net/selinux/patches/ ]
is an updated patchset that attempts to
accomplish the following:

- provide library routines to easily edit and modify the various selinux data files (users file, file contexts, template file, map file... ) through libselinux, and make some changes to allow alternative backends in the future.

Quoted 4 lines

- integrate the utilities useradd/usermod/userdel
with libselinux interface for manipulating users
(currently useradd/userdel...still have to work
on usermod).

Please be sure that anything in libselinux is general enough to work in ALL
the distros. Currently each new Debian user has to figure out what /etc/default/useradd is; why it would be there; and what format it needs to have. That is a RHism. As a script, at least, each Debian explorer can track down the script, and have a chance of figuring it out.

But if you put the dependancy in 'compiled code', (and leave it all
undocumented (man libselinux = nada)) then you are excluding all other systems that don't operate in just that one way. You will have created a linkage or dependancy between what selinux provides and what it extects the user's system to supply.

Not a good idea for something that wants to be a solution for the community
in general, rather than a single vendor. If you look back at the development of Xwindows, you see that it's behavior can be controlled by environment variables, as well as multiple optional file names and paths.

And just as a simple question, what if there are multiple storage loactions
for home directories? /u1/home;/u2/home/;/staff/private/home; What then? How about:

setenv SE_USER_HOMES /u1/home;/u2/home/;/staff/private/home;

or better; a /etc/selinux/config line

  SE_USER_HOMES=/u1/home;/u2/home/;staff/private/home;

and then document selinux configuration options ( man 5 selinux ).

Quoted 12 lines

- alter the 1:1 user-to-seluser map scheme to
what was discussed per Karl's proposal. Groups
are disallowed. Syntax is subject to change.

- simplify the code necessary to work with and load policy in libsepol - this involves changing policydb to an opaque data structure, and deprecating functions that manipulate the policy (data, len) image. Also, there is a convenient create_policydb function in libselinux.

Quoted 9 lines

Patchset is not finished, but I want to see if you have any comments...

--
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.

Roger Brunell

Infosec Engineer (retired)
"Born 20 years too early"

__________________________________
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html

--
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.

#9 lore raw
Quoted 6 lines

Please be sure that anything in libselinux is general enough to work in ALL
the distros. Currently each new Debian user has to figure out what /etc/default/useradd is; why it would be there; and what format it needs to have. That is a RHism. As a script, at least, each Debian explorer can track down the script, and have a chance of figuring it out.

Changes in libselinux provide the functionality necessary to integrate useradd with libselinux, not the other way around. They allow manipulation of the selinux data files.

Quoted 2 lines

And just as a simple question, what if there are multiple storage loactions
for home directories? /u1/home;/u2/home/;/staff/private/home; What then?

My changes don't handle HOME_ROOT expansion - that's done by genhomedircon. Looking at what the script currently does, yes it is RedHat specific, and does read the file that you argue about. However, that's not the result of my changes.

Quoted 8 lines

How
about:

setenv SE_USER_HOMES /u1/home;/u2/home/;/staff/private/home;

or better; a /etc/selinux/config line

  SE_USER_HOMES=/u1/home;/u2/home/;staff/private/home;

I believe genhomedircon parses the passwd file to get those.

--
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.

#10 lore raw
In reply to Roger Brunell
Quoted 5 lines · Roger Brunell

Please be sure that anything in libselinux is general enough to work in
ALL the distros. Currently each new Debian user has to figure out what /etc/default/useradd is; why it would be there; and what format it needs to have. That is a RHism. As a script, at least, each Debian explorer can track down the script, and have a chance of figuring it out.

That's because Manoj missed one of my patches when taking over the Debian package in question. It should be fixed now.

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.