Skip to contentSkip to conversation

Red Hat's passwd

PATCH Joshua Brindle 4 participants 11 messages Aug 5, 2005 – Aug 13, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

The attached patch removes the selinux code from Red Hat's passwd.c and uses the libselinux function checkPasswdAccess. Aside from eliminating some duplication this will make it easier for passwd to use the userspace security server with dynamic object classes since it will only require a libselinux change and both shadows passwd and Red Hats passwd will benefit.

Let me know if there are problems merging this into mainline.

Joshua

passwd.c +2 -2
diff -purN passwd-0.70/passwd.c passwd-0.70-new/passwd.c
@@ -54,7 +54,6 @@
 #include <selinux/selinux.h>
 #include <selinux/context.h>
 #include <selinux/av_permissions.h>
-#include "selinux_utils.h"
 #endif
 
 #ifdef WITH_AUDIT
@@ -366,7 +365,8 @@ main(int argc, const char **argv)
 #ifdef WITH_SELINUX
 	if ((is_selinux_enabled() > 0) &&
 	    (getuid() == 0) &&
-	    (check_selinux_access(username, pwd->pw_uid, PASSWD__PASSWD) != 0)) {
+	    (pwd->pw_uid != getuid ()) &&
+	    (checkPasswdAccess(PASSWD__PASSWD) != 0)) {
 		security_context_t user_context;
 		if (getprevcon(&user_context) < 0) {
 			user_context = strdup(_("Unknown user context"));
selinux_utils.c +0 -82

82 lines not on this page · raw message

selinux_utils.h +0 -4
diff -purN passwd-0.70/selinux_utils.h passwd-0.70-new/selinux_utils.h
@@ -1,4 +0,0 @@
-#ifndef __RH_SELINUX_UTILS_H
-#define __RH_SELINUX_UTILS_H
-int check_selinux_access(const char *change_user, int change_uid, unsigned int access);
-#endif
#1 lore raw
Quoted 2 lines · Joshua Brindle

The attached patch removes the selinux code from Red Hat's passwd.c and uses the libselinux function checkPasswdAccess.

This reminds me...there was some griping from people maintaining modules which use libselinux about the name "checkPasswdAccess" in a shared library targeted for wide use; could we get some namespacing here? This is a good thing for preventing symbol collisions and also for aesthetic and consistency reasons. Perhaps avc_check_passwd_permission or security_check_passwd_permission or something?

Renaming the function would be an API/ABI break, but it doesn't seem like a function that could be applicable for more than a few programs at most.

#2 lore raw
Quoted 7 lines · Colin Walters
Quoted 3 lines · Joshua Brindle

The attached patch removes the selinux code from Red Hat's passwd.c and uses the libselinux function checkPasswdAccess.

Quoted 9 lines

This reminds me...there was some griping from people maintaining modules which use libselinux about the name "checkPasswdAccess" in a shared library targeted for wide use; could we get some namespacing here? This is a good thing for preventing symbol collisions and also for aesthetic and consistency reasons. Perhaps avc_check_passwd_permission or security_check_passwd_permission or something?

yea, thats a bad name, and it has caps!@

Quoted 5 lines

Renaming the function would be an API/ABI break, but it doesn't seem like a function that could be applicable for more than a few programs at most.

yea, the problem is really upstreaming the change in whatever packages use it (shadow, and hopefully RH passwd) and some of Red Hats patches for things like vixie cron will also need to be fixed.

Personally I'd rather not deal with a major version change needed for an api change. Granted it shouldn't be named that but it isn't crucial to fix it. We probably need to be more careful about what functions are exported in the future.

Also, util-linux needs to be patched to use checkPasswdAccess (or whatever) rather than internally (which looks surprisingly similar to checkPasswdAccess) and there are probably more apps I'm missing.

--
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 24 lines · Joshua Brindle
Quoted 6 lines · Colin Walters
Quoted 1 line · Joshua Brindle

The attached patch removes the selinux code from Red Hat's passwd.c and uses the libselinux function checkPasswdAccess.

Quoted 9 lines

This reminds me...there was some griping from people maintaining modules which use libselinux about the name "checkPasswdAccess" in a shared library targeted for wide use; could we get some namespacing here? This is a good thing for preventing symbol collisions and also for aesthetic and consistency reasons. Perhaps avc_check_passwd_permission or security_check_passwd_permission or something?

yea, thats a bad name, and it has caps!@

Quoted 5 lines

Renaming the function would be an API/ABI break, but it doesn't seem like a function that could be applicable for more than a few programs at most.

Quoted 7 lines

yea, the problem is really upstreaming the change in whatever packages use it (shadow, and hopefully RH passwd) and some of Red Hats patches for things like vixie cron will also need to be fixed.

Personally I'd rather not deal with a major version change needed for an api change. Granted it shouldn't be named that but it isn't crucial to fix it. We probably need to be more careful about what functions are exported in the future.

Also, util-linux needs to be patched to use checkPasswdAccess (or whatever) rather than internally (which looks surprisingly similar to checkPasswdAccess) and there are probably more apps I'm missing.

Lets add Colins' name and then just leave checkPasswdAccess to call it. Then remove any reference to the function.

Quoted 7 lines
Signature · 4 lines
-- 
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 · 4 lines
--
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 27 lines · Daniel J Walsh
Quoted 25 lines · Joshua Brindle
Quoted 7 lines · Colin Walters
Quoted 1 line · Joshua Brindle

The attached patch removes the selinux code from Red Hat's passwd.c and uses the libselinux function checkPasswdAccess.

Quoted 9 lines

This reminds me...there was some griping from people maintaining modules which use libselinux about the name "checkPasswdAccess" in a shared library targeted for wide use; could we get some namespacing here? This is a good thing for preventing symbol collisions and also for aesthetic and consistency reasons. Perhaps avc_check_passwd_permission or security_check_passwd_permission or something?

yea, thats a bad name, and it has caps!@

Quoted 5 lines

Renaming the function would be an API/ABI break, but it doesn't seem like a function that could be applicable for more than a few programs at most.

Quoted 9 lines
Quoted 7 lines

yea, the problem is really upstreaming the change in whatever packages use it (shadow, and hopefully RH passwd) and some of Red Hats patches for things like vixie cron will also need to be fixed.

Personally I'd rather not deal with a major version change needed for an api change. Granted it shouldn't be named that but it isn't crucial to fix it. We probably need to be more careful about what functions are exported in the future.

Also, util-linux needs to be patched to use checkPasswdAccess (or whatever) rather than internally (which looks surprisingly similar to checkPasswdAccess) and there are probably more apps I'm missing.

Lets add Colins' name and then just leave checkPasswdAccess to call it. Then remove any reference to the function.

Sounds good to me, trivial patch to do this.. Also, I assume you will change the previous patch for passwd.c to the new function.

checkAccess.c (working copy) renamed from checkAccess.c (revision 920) +0 -0
Index: checkAccess.c
===================================================================
@@ -6,7 +6,7 @@

#include <selinux/flask.h>
#include <selinux/av_permissions.h>

-int checkPasswdAccess(access_vector_t requested) {

+int selinux_check_passwd_access(access_vector_t requested) {
        int status=-1;
        security_context_t user_context;
        if (is_selinux_enabled() == 0)

@@ -31,3 +31,7 @@

        return status;
}

+
+int checkPasswdAccess(access_vector_t requested) {
+ return selinux_check_passwd_access(requested);
+}

--
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 · Joshua Brindle

Sounds good to me, trivial patch to do this.. Also, I assume you will change the previous patch for passwd.c to the new function.

Shouldn't we also remove checkPasswdAccess from the header? Otherwise what's the point?

I should note this approach addresses the consistency and namespacing from the developer point of view, but doesn't address possible symbol collisions. Possibly that could wait until a soname bump, just thought I'd point it out.

#6 lore raw
Quoted 4 lines · Colin Walters

On Fri, 2005-08-05 at 15:07 -0400, Joshua Brindle wrote:

Quoted 9 lines
Quoted 3 lines

Sounds good to me, trivial patch to do this.. Also, I assume you will change the previous patch for passwd.c to the new function.

Shouldn't we also remove checkPasswdAccess from the header? Otherwise what's the point?

no but we need to add the other..

The point is to allow some transition time so that both are available until everything is fixed, then we can remove the other without having any problems.

selinux.h (working copy) renamed from selinux.h (revision 920) +0 -0
@@ -290,6 +290,7 @@
 

/* Check a permission in the passwd class.
Return 0 if granted or -1 otherwise. */
+extern int selinux_check_passwd_access(access_vector_t requested); extern int checkPasswdAccess(access_vector_t requested);

/* Set the path to the selinuxfs mount point explicitly.

Quoted 6 lines

I should note this approach addresses the consistency and namespacing from the developer point of view, but doesn't address possible symbol collisions. Possibly that could wait until a soname bump, just thought I'd point it out.

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

The patches to rename checkPasswdAccess (while temporarily retaining the old symbol for compatibility) were merged as of libselinux 1.25.1. So if/when people convert all users of it over to the new name, we can wait a bit and then drop the old symbol altogether.

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
Quoted 6 lines · Stephen Smalley

The patches to rename checkPasswdAccess (while temporarily retaining the old symbol for compatibility) were merged as of libselinux 1.25.1. So if/when people convert all users of it over to the new name, we can wait a bit and then drop the old symbol altogether.

Dan, are you going to be able to merge those changes into passwd?

We need to eliminate as many hard coded class references as possible to make transitioning to the userspace security server easier.

--
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 11 lines · Joshua Brindle
Quoted 6 lines · Stephen Smalley

The patches to rename checkPasswdAccess (while temporarily retaining the old symbol for compatibility) were merged as of libselinux 1.25.1. So if/when people convert all users of it over to the new name, we can wait a bit and then drop the old symbol altogether.

Dan, are you going to be able to merge those changes into passwd?

We need to eliminate as many hard coded class references as possible to make transitioning to the userspace security server easier.

yes

Signature · 4 lines
--
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 Joshua Brindle
Quoted 5 lines · Joshua Brindle

yea, the problem is really upstreaming the change in whatever packages use it (shadow, and hopefully RH passwd)

and some of Red Hats patches for things like vixie cron will also need to be fixed.

Ah, hm. I can see how that is potentially harder. Are those patches already really upstreamed (i.e. in their tarballs) though? Looking in Fedora it looks like the vixie-cron SELinux support is still a separate patch for example.

Quoted 2 lines

Personally I'd rather not deal with a major version change needed for an api change.

Well I guess I was arguing that we should be evil and not bump the soname for it and just fix the few apps that are using it :) We know what they are and are in control of the code.

If we are talking about bumping soname, there are other changes we should probably make too.

Quoted 2 lines

We probably need to be more careful about what functions are exported in the future.

Yes.