* lib/shadowio.c: Re-indent.

* lib/shadowio.c: Added brackets and parenthesis.
	* lib/shadowio.c: Document the sections closed by #endif
	* lib/shadowio.c: Avoid negation of comparisons.
	* lib/shadowio.c: Avoid implicit conversion of integer to booleans
	and booleans to integers.
This commit is contained in:
nekral-guest 2010-03-11 22:03:57 +00:00
parent ad6730687f
commit 69798dde65
2 changed files with 46 additions and 26 deletions

View File

@ -1,3 +1,12 @@
2010-03-11 Nicolas François <nicolas.francois@centraliens.net>
* lib/shadowio.c: Re-indent.
* lib/shadowio.c: Added brackets and parenthesis.
* lib/shadowio.c: Document the sections closed by #endif
* lib/shadowio.c: Avoid negation of comparisons.
* lib/shadowio.c: Avoid implicit conversion of integer to booleans
and booleans to integers.
2010-03-11 Nicolas François <nicolas.francois@centraliens.net> 2010-03-11 Nicolas François <nicolas.francois@centraliens.net>
* src/useradd.c: Re-indent. * src/useradd.c: Re-indent.

View File

@ -44,7 +44,7 @@
#ifdef WITH_TCB #ifdef WITH_TCB
#include <tcb.h> #include <tcb.h>
#include "tcbfuncs.h" #include "tcbfuncs.h"
#endif #endif /* WITH_TCB */
static /*@null@*/ /*@only@*/void *shadow_dup (const void *ent) static /*@null@*/ /*@only@*/void *shadow_dup (const void *ent)
{ {
@ -97,7 +97,7 @@ static struct commonio_db shadow_db = {
NULL, /* fp */ NULL, /* fp */
#ifdef WITH_SELINUX #ifdef WITH_SELINUX
NULL, /* scontext */ NULL, /* scontext */
#endif #endif /* WITH_SELINUX */
NULL, /* head */ NULL, /* head */
NULL, /* tail */ NULL, /* tail */
NULL, /* cursor */ NULL, /* cursor */
@ -127,36 +127,41 @@ int spw_lock (void)
#ifdef WITH_TCB #ifdef WITH_TCB
int retval = 0; int retval = 0;
if (!getdef_bool("USE_TCB")) if (!getdef_bool ("USE_TCB")) {
#endif #endif /* WITH_TCB */
return commonio_lock (&shadow_db); return commonio_lock (&shadow_db);
#ifdef WITH_TCB #ifdef WITH_TCB
if (!shadowtcb_drop_priv()) }
if (shadowtcb_drop_priv () == 0) {
return 0; return 0;
if (lckpwdf_tcb(shadow_db.filename) == 0) { }
if (lckpwdf_tcb (shadow_db.filename) == 0) {
shadow_db.locked = 1; shadow_db.locked = 1;
retval = 1; retval = 1;
} }
if (!shadowtcb_gain_priv()) if (shadowtcb_gain_priv () == 0) {
return 0; return 0;
}
return retval; return retval;
#endif #endif /* WITH_TCB */
} }
int spw_open (int mode) int spw_open (int mode)
{ {
int retval = 0; int retval = 0;
#ifdef WITH_TCB #ifdef WITH_TCB
int use_tcb = getdef_bool("USE_TCB"); bool use_tcb = getdef_bool ("USE_TCB");
if (use_tcb && !shadowtcb_drop_priv() != 0) if (use_tcb && (shadowtcb_drop_priv () == 0)) {
return 0; return 0;
#endif }
#endif /* WITH_TCB */
retval = commonio_open (&shadow_db, mode); retval = commonio_open (&shadow_db, mode);
#ifdef WITH_TCB #ifdef WITH_TCB
if (use_tcb && !shadowtcb_gain_priv() != 0) if (use_tcb && (shadowtcb_gain_priv () == 0)) {
return 0; return 0;
#endif }
#endif /* WITH_TCB */
return retval; return retval;
} }
@ -189,16 +194,18 @@ int spw_close (void)
{ {
int retval = 0; int retval = 0;
#ifdef WITH_TCB #ifdef WITH_TCB
int use_tcb = getdef_bool("USE_TCB"); bool use_tcb = getdef_bool ("USE_TCB");
if (use_tcb && !shadowtcb_drop_priv() != 0) if (use_tcb && (shadowtcb_drop_priv () == 0)) {
return 0; return 0;
#endif }
#endif /* WITH_TCB */
retval = commonio_close (&shadow_db); retval = commonio_close (&shadow_db);
#ifdef WITH_TCB #ifdef WITH_TCB
if (use_tcb && !shadowtcb_gain_priv() != 0) if (use_tcb && (shadowtcb_gain_priv () == 0)) {
return 0; return 0;
#endif }
#endif /* WITH_TCB */
return retval; return retval;
} }
@ -207,20 +214,23 @@ int spw_unlock (void)
#ifdef WITH_TCB #ifdef WITH_TCB
int retval = 0; int retval = 0;
if (!getdef_bool("USE_TCB")) if (!getdef_bool ("USE_TCB")) {
#endif #endif /* WITH_TCB */
return commonio_unlock (&shadow_db); return commonio_unlock (&shadow_db);
#ifdef WITH_TCB #ifdef WITH_TCB
if (!shadowtcb_drop_priv()) }
if (shadowtcb_drop_priv () == 0) {
return 0; return 0;
if (ulckpwdf_tcb() == 0) { }
if (ulckpwdf_tcb () == 0) {
shadow_db.locked = 0; shadow_db.locked = 0;
retval = 1; retval = 1;
} }
if (!shadowtcb_gain_priv()) if (shadowtcb_gain_priv () == 0) {
return 0; return 0;
}
return retval; return retval;
#endif #endif /* WITH_TCB */
} }
struct commonio_entry *__spw_get_head (void) struct commonio_entry *__spw_get_head (void)
@ -237,8 +247,9 @@ void __spw_del_entry (const struct commonio_entry *ent)
int spw_sort () int spw_sort ()
{ {
#ifdef WITH_TCB #ifdef WITH_TCB
if (getdef_bool("USE_TCB")) if (getdef_bool ("USE_TCB")) {
return 0; return 0;
#endif }
#endif /* WITH_TCB */
return commonio_sort_wrt (&shadow_db, __pw_get_db ()); return commonio_sort_wrt (&shadow_db, __pw_get_db ());
} }