* lib/commonio.c: Added splint annotations.
* lib/commonio.c: old_context should be local to commonio_close(), not global.
This commit is contained in:
parent
fca3b5cdc9
commit
4fd672c5b9
@ -1,3 +1,9 @@
|
|||||||
|
2009-04-26 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* lib/commonio.c: Added splint annotations.
|
||||||
|
* lib/commonio.c: old_context should be local to commonio_close(),
|
||||||
|
not global.
|
||||||
|
|
||||||
2009-04-26 Nicolas François <nicolas.francois@centraliens.net>
|
2009-04-26 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* src/passwd.c: Do not freecon strings duplicated with strdup.
|
* src/passwd.c: Do not freecon strings duplicated with strdup.
|
||||||
|
@ -46,7 +46,6 @@
|
|||||||
#include "nscd.h"
|
#include "nscd.h"
|
||||||
#ifdef WITH_SELINUX
|
#ifdef WITH_SELINUX
|
||||||
#include <selinux/selinux.h>
|
#include <selinux/selinux.h>
|
||||||
static /*@null@*/security_context_t old_context = NULL;
|
|
||||||
#endif
|
#endif
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
#include "commonio.h"
|
#include "commonio.h"
|
||||||
@ -63,8 +62,7 @@ static int create_backup (const char *, FILE *);
|
|||||||
static void free_linked_list (struct commonio_db *);
|
static void free_linked_list (struct commonio_db *);
|
||||||
static void add_one_entry (
|
static void add_one_entry (
|
||||||
struct commonio_db *db,
|
struct commonio_db *db,
|
||||||
/*@owned@*/struct commonio_entry *p)
|
/*@owned@*/struct commonio_entry *p);
|
||||||
/*@requires isnull p->next, p->prev@*/;
|
|
||||||
static bool name_is_nis (const char *name);
|
static bool name_is_nis (const char *name);
|
||||||
static int write_all (const struct commonio_db *);
|
static int write_all (const struct commonio_db *);
|
||||||
static /*@dependent@*/ /*@null@*/struct commonio_entry *find_entry_by_name (
|
static /*@dependent@*/ /*@null@*/struct commonio_entry *find_entry_by_name (
|
||||||
@ -431,12 +429,19 @@ int commonio_unlock (struct commonio_db *db)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add an entry at the end.
|
||||||
|
*
|
||||||
|
* defines p->next, p->prev
|
||||||
|
* (unfortunately, owned special are not supported)
|
||||||
|
*/
|
||||||
static void add_one_entry (struct commonio_db *db,
|
static void add_one_entry (struct commonio_db *db,
|
||||||
/*@owned@*/struct commonio_entry *p)
|
/*@owned@*/struct commonio_entry *p)
|
||||||
/*@requires isnull p->next, p->prev@*/
|
|
||||||
{
|
{
|
||||||
|
/*@-mustfreeonly@*/
|
||||||
p->next = NULL;
|
p->next = NULL;
|
||||||
p->prev = db->tail;
|
p->prev = db->tail;
|
||||||
|
/*@=mustfreeonly@*/
|
||||||
if (NULL == db->head) {
|
if (NULL == db->head) {
|
||||||
db->head = p;
|
db->head = p;
|
||||||
}
|
}
|
||||||
@ -463,23 +468,26 @@ static bool name_is_nis (const char *name)
|
|||||||
|
|
||||||
#if KEEP_NIS_AT_END
|
#if KEEP_NIS_AT_END
|
||||||
static void add_one_entry_nis (struct commonio_db *db,
|
static void add_one_entry_nis (struct commonio_db *db,
|
||||||
/*@owned@*/struct commonio_entry *newp)
|
/*@owned@*/struct commonio_entry *newp);
|
||||||
/*@requires isnull newp->next, newp->prev@*/;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Insert an entry between the regular entries, and the NIS entries.
|
* Insert an entry between the regular entries, and the NIS entries.
|
||||||
|
*
|
||||||
|
* defines newp->next, newp->prev
|
||||||
|
* (unfortunately, owned special are not supported)
|
||||||
*/
|
*/
|
||||||
static void add_one_entry_nis (struct commonio_db *db,
|
static void add_one_entry_nis (struct commonio_db *db,
|
||||||
/*@owned@*/struct commonio_entry *newp)
|
/*@owned@*/struct commonio_entry *newp)
|
||||||
/*@requires isnull newp->next, newp->prev@*/
|
|
||||||
{
|
{
|
||||||
struct commonio_entry *p;
|
struct commonio_entry *p;
|
||||||
|
|
||||||
for (p = db->head; NULL != p; p = p->next) {
|
for (p = db->head; NULL != p; p = p->next) {
|
||||||
if (name_is_nis (p->eptr ? db->ops->getname (p->eptr)
|
if (name_is_nis (p->eptr ? db->ops->getname (p->eptr)
|
||||||
: p->line)) {
|
: p->line)) {
|
||||||
|
/*@-mustfreeonly@*/
|
||||||
newp->next = p;
|
newp->next = p;
|
||||||
newp->prev = p->prev;
|
newp->prev = p->prev;
|
||||||
|
/*@=mustfreeonly@*/
|
||||||
if (NULL != p->prev) {
|
if (NULL != p->prev) {
|
||||||
p->prev->next = newp;
|
p->prev->next = newp;
|
||||||
} else {
|
} else {
|
||||||
@ -784,6 +792,10 @@ int commonio_close (struct commonio_db *db)
|
|||||||
int errors = 0;
|
int errors = 0;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
|
#ifdef WITH_SELINUX
|
||||||
|
/*@null@*/security_context_t old_context = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!db->isopen) {
|
if (!db->isopen) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return 0;
|
return 0;
|
||||||
@ -890,10 +902,10 @@ int commonio_close (struct commonio_db *db)
|
|||||||
|
|
||||||
#ifdef WITH_SELINUX
|
#ifdef WITH_SELINUX
|
||||||
if (db->scontext != NULL) {
|
if (db->scontext != NULL) {
|
||||||
|
if (NULL != old_context) {
|
||||||
if (setfscreatecon (old_context) < 0) {
|
if (setfscreatecon (old_context) < 0) {
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
if (NULL != old_context) {
|
|
||||||
freecon (old_context);
|
freecon (old_context);
|
||||||
old_context = NULL;
|
old_context = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user