Make rpm_execcon failure non-fatal in permissive mode.
Changelog: Makes failure in rpm_execcon non-fatal in permissive mode.
See: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=173094
P.S. I'm not sure why an rpm-specific function is in the shared library - seems strange to me.
libselinux/src/rpm.c +5 -2
@@ -11,7 +11,7 @@ int rpm_execcon(unsigned int verified __ {security_context_t mycon =NULL , fcon =NULL , newcon =NULL ;context_t con =NULL ; -int rc; +int rc =0 ;if (is_selinux_enabled () <1 )return execve (filename, argv, envp);
@@ -44,8 +44,11 @@ int rpm_execcon(unsigned int verified __ rc =setexeccon (newcon);if (rc <0 ) goto out; - rc =execve (filename, argv, envp); out: + +if (rc >=0 || !security_getenforce ()) + rc =execve (filename, argv, envp); +context_free (con);freecon (newcon);freecon (fcon);
Quoted 5 lines · Ivan Gyurdiev
Changelog: Makes failure in
rpm_execconnon-fatal in permissive mode.
See: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=173094
P.S. I'm not sure why an rpm-specific function is in the shared library
- seems strange to me.
It is unusual, but allows us to evolve that logic without having to re-patch rpm (which has been very difficult in the past to get updated for changes in SELinux). Same issue applies for /sbin/init and selinux_init_load_policy(), and for various programs and checkPasswdAccess().
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 5 lines · Ivan Gyurdiev
Changelog: Makes failure in
rpm_execconnon-fatal in permissive mode.
See: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=173094
P.S. I'm not sure why an rpm-specific function is in the shared library
- seems strange to me.
Needs the following diff on top of your diff in order to correctly handle failures while setting up the context. Second hunk isn't strictly needed but seems desirable for cleanliness.
Index: libselinux/src/rpm.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/rpm.c,v retrieving revision 1.7
src/rpm.c +2 -0
@@ -30,6 +30,7 @@ int rpm_execcon(unsigned int verified __if (!strcmp (mycon, newcon)) {/* No default transition, use rpm_script_t for now. */ + rc =-1 ; con =context_new (mycon);if (!con) goto out;
@@ -39,6 +40,7 @@ int rpm_execcon(unsigned int verified __ newcon =strdup (context_str (con));if (!newcon) goto out; + rc =0 ; } rc =setexeccon (newcon);
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 27 lines · Stephen Smalley
Quoted 5 lines · Ivan Gyurdiev
Changelog: Makes failure in
rpm_execconnon-fatal in permissive mode.
See: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=173094
P.S. I'm not sure why an rpm-specific function is in the shared library
- seems strange to me.Needs the following diff on top of your diff in order to correctly handle failures while setting up the context. Second hunk isn't strictly needed but seems desirable for cleanliness.
Index:
libselinux/src/rpm.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/rpm.c,v retrieving revision 1.7
diff -u -p -r1.7rpm.csrc/rpm.c +1
-0@@ -30,6 +30,7 @@ int rpm_execcon(unsigned int verified __if (!strcmp (mycon, newcon)) {/* No default transition, use rpm_script_t for now. */ + rc =-1 ; con =context_new (mycon);if (!con) goto out;
src/rpm.c int rpm_execcon(unsigned int verified __ · line 46
Quoted 7 lines
src/rpm.c +1
-0@@ -39,6 +40,7 @@ int rpm_execcon(unsigned int verified __ newcon =strdup (context_str (con));if (!newcon) goto out; + rc =0 ; } rc =setexeccon (newcon);
Both diffs merged as of libselinux 1.27.22.
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.