2010-01-30 Paweł Hajdan, Jr. <phajdan.jr@gentoo.org>

* NEWS: Add support for TCB.
	* lib/tcbfuncs.h, lib/tcbfuncs.c, lib/Makefile.am: New library to
	support TCB.
	* lib/prototypes, libmisc/copydir.c (remove_tree): Add boolean
	parameter remove_root.
	* configure.in: Add conditional WITH_TCB.
	* src/userdel.c, src/usermod.c: Add support for TCB. Update call to
	remove_tree().
	* src/pwconv.c, src/pwunconv.c: Should not be used with TCB enabled.
	* src/vipw.c: Add support for TCB. Update call to remove_tree().
	* src/useradd.c: Add support for TCB. Open the shadow file outside
	of open_files().
	* src/chage.c: Add support for TCB.
	* src/Makefile.am: Install passwd sgid shadow when TCB is enabled.
	* lib/getdefs.c, man/vipw.8.xml, man/login.defs.5.xml,
	man/login.defs/TCB_AUTH_GROUP.xml, man/login.defs/USE_TCB.xml,
	man/login.defs/TCB_SYMLINKS.xml, man/generate_mans.mak,
	man/generate_mans.deps, man/Makefile.am: New configuration
	parameters: TCB_AUTH_GROUP, TCB_SYMLINKS, USE_TCB.
	* lib/shadowio.c, lib/commonio.c: Add support for TCB.
This commit is contained in:
nekral-guest
2010-03-04 18:11:13 +00:00
parent 5ba95d4c53
commit 391a384715
27 changed files with 1067 additions and 44 deletions

View File

@@ -41,6 +41,10 @@
#include <stdio.h>
#include "commonio.h"
#include "shadowio.h"
#ifdef WITH_TCB
#include <tcb.h>
#include "tcbfuncs.h"
#endif
static /*@null@*/ /*@only@*/void *shadow_dup (const void *ent)
{
@@ -120,12 +124,40 @@ bool spw_file_present (void)
int spw_lock (void)
{
return commonio_lock (&shadow_db);
#ifdef WITH_TCB
int retval = 0;
if (!getdef_bool("USE_TCB"))
#endif
return commonio_lock (&shadow_db);
#ifdef WITH_TCB
if (!shadowtcb_drop_priv())
return 0;
if (lckpwdf_tcb(shadow_db.filename) == 0) {
shadow_db.locked = 1;
retval = 1;
}
if (!shadowtcb_gain_priv())
return 0;
return retval;
#endif
}
int spw_open (int mode)
{
return commonio_open (&shadow_db, mode);
int retval = 0;
#ifdef WITH_TCB
int use_tcb = getdef_bool("USE_TCB");
if (use_tcb && !shadowtcb_drop_priv() != 0)
return 0;
#endif
retval = commonio_open (&shadow_db, mode);
#ifdef WITH_TCB
if (use_tcb && !shadowtcb_gain_priv() != 0)
return 0;
#endif
return retval;
}
/*@observer@*/ /*@null@*/const struct spwd *spw_locate (const char *name)
@@ -155,12 +187,40 @@ int spw_rewind (void)
int spw_close (void)
{
return commonio_close (&shadow_db);
int retval = 0;
#ifdef WITH_TCB
int use_tcb = getdef_bool("USE_TCB");
if (use_tcb && !shadowtcb_drop_priv() != 0)
return 0;
#endif
retval = commonio_close (&shadow_db);
#ifdef WITH_TCB
if (use_tcb && !shadowtcb_gain_priv() != 0)
return 0;
#endif
return retval;
}
int spw_unlock (void)
{
return commonio_unlock (&shadow_db);
#ifdef WITH_TCB
int retval = 0;
if (!getdef_bool("USE_TCB"))
#endif
return commonio_unlock (&shadow_db);
#ifdef WITH_TCB
if (!shadowtcb_drop_priv())
return 0;
if (ulckpwdf_tcb() == 0) {
shadow_db.locked = 0;
retval = 1;
}
if (!shadowtcb_gain_priv())
return 0;
return retval;
#endif
}
struct commonio_entry *__spw_get_head (void)
@@ -176,5 +236,9 @@ void __spw_del_entry (const struct commonio_entry *ent)
/* Sort with respect to passwd ordering. */
int spw_sort ()
{
#ifdef WITH_TCB
if (getdef_bool("USE_TCB"))
return 0;
#endif
return commonio_sort_wrt (&shadow_db, __pw_get_db ());
}