* lib/commonio.c: Re-indent.
* lib/commonio.c: Document the sections closed by #endif * lib/commonio.c: Added brackets. * lib/commonio.c: Avoid implicit conversion of integer to booleans.
This commit is contained in:
parent
33d3e28a7f
commit
f13f60504a
@ -1,3 +1,11 @@
|
|||||||
|
2010-03-11 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* lib/commonio.c: Re-indent.
|
||||||
|
* lib/commonio.c: Document the sections closed by #endif
|
||||||
|
* lib/commonio.c: Added brackets.
|
||||||
|
* lib/commonio.c: Avoid implicit conversion of integer to
|
||||||
|
booleans.
|
||||||
|
|
||||||
2010-03-11 Nicolas François <nicolas.francois@centraliens.net>
|
2010-03-11 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* src/userdel.c: Re-indent.
|
* src/userdel.c: Re-indent.
|
||||||
|
@ -47,10 +47,10 @@
|
|||||||
#include "nscd.h"
|
#include "nscd.h"
|
||||||
#ifdef WITH_SELINUX
|
#ifdef WITH_SELINUX
|
||||||
#include <selinux/selinux.h>
|
#include <selinux/selinux.h>
|
||||||
#endif
|
#endif /* WITH_SELINUX */
|
||||||
#ifdef WITH_TCB
|
#ifdef WITH_TCB
|
||||||
#include <tcb.h>
|
#include <tcb.h>
|
||||||
#endif
|
#endif /* WITH_TCB */
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
#include "commonio.h"
|
#include "commonio.h"
|
||||||
|
|
||||||
@ -222,21 +222,21 @@ static /*@null@*/ /*@dependent@*/FILE *fopen_set_perms (
|
|||||||
if (fchown (fileno (fp), sb->st_uid, sb->st_gid) != 0) {
|
if (fchown (fileno (fp), sb->st_uid, sb->st_gid) != 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
#else
|
#else /* !HAVE_FCHOWN */
|
||||||
if (chown (name, sb->st_mode) != 0) {
|
if (chown (name, sb->st_mode) != 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !HAVE_FCHOWN */
|
||||||
|
|
||||||
#ifdef HAVE_FCHMOD
|
#ifdef HAVE_FCHMOD
|
||||||
if (fchmod (fileno (fp), sb->st_mode & 0664) != 0) {
|
if (fchmod (fileno (fp), sb->st_mode & 0664) != 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
#else
|
#else /* !HAVE_FCHMOD */
|
||||||
if (chmod (name, sb->st_mode & 0664) != 0) {
|
if (chmod (name, sb->st_mode & 0664) != 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !HAVE_FCHMOD */
|
||||||
return fp;
|
return fp;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
@ -374,7 +374,7 @@ int commonio_lock (struct commonio_db *db)
|
|||||||
|
|
||||||
ulckpwdf ();
|
ulckpwdf ();
|
||||||
return 0; /* failure */
|
return 0; /* failure */
|
||||||
#else
|
#else /* !HAVE_LCKPWDF */
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -400,7 +400,7 @@ int commonio_lock (struct commonio_db *db)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0; /* failure */
|
return 0; /* failure */
|
||||||
#endif
|
#endif /* !HAVE_LCKPWDF */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dec_lock_count (void)
|
static void dec_lock_count (void)
|
||||||
@ -417,7 +417,7 @@ static void dec_lock_count (void)
|
|||||||
}
|
}
|
||||||
#ifdef HAVE_LCKPWDF
|
#ifdef HAVE_LCKPWDF
|
||||||
ulckpwdf ();
|
ulckpwdf ();
|
||||||
#endif
|
#endif /* HAVE_LCKPWDF */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -557,22 +557,24 @@ int commonio_open (struct commonio_db *db, int mode)
|
|||||||
db->cursor = NULL;
|
db->cursor = NULL;
|
||||||
db->changed = false;
|
db->changed = false;
|
||||||
|
|
||||||
fd = open(db->filename, (db->readonly ? O_RDONLY : O_RDWR) |
|
fd = open (db->filename,
|
||||||
O_NOCTTY | O_NONBLOCK | O_NOFOLLOW);
|
(db->readonly ? O_RDONLY : O_RDWR)
|
||||||
|
| O_NOCTTY | O_NONBLOCK | O_NOFOLLOW);
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
db->fp = NULL;
|
db->fp = NULL;
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
#ifdef WITH_TCB
|
#ifdef WITH_TCB
|
||||||
if (tcb_is_suspect(fd)) {
|
if (tcb_is_suspect (fd) != 0) {
|
||||||
close(fd);
|
close (fd);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* WITH_TCB */
|
||||||
db->fp = fdopen(fd, db->readonly ? "r" : "r+");
|
db->fp = fdopen (fd, db->readonly ? "r" : "r+");
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
if (!db->fp)
|
if (!db->fp) {
|
||||||
close(fd);
|
close (fd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
errno = saved_errno;
|
errno = saved_errno;
|
||||||
|
|
||||||
@ -589,7 +591,7 @@ int commonio_open (struct commonio_db *db, int mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Do not inherit fd in spawned processes (e.g. nscd) */
|
/* Do not inherit fd in spawned processes (e.g. nscd) */
|
||||||
fcntl(fileno(db->fp), F_SETFD, FD_CLOEXEC);
|
fcntl (fileno (db->fp), F_SETFD, FD_CLOEXEC);
|
||||||
|
|
||||||
#ifdef WITH_SELINUX
|
#ifdef WITH_SELINUX
|
||||||
db->scontext = NULL;
|
db->scontext = NULL;
|
||||||
@ -598,7 +600,7 @@ int commonio_open (struct commonio_db *db, int mode)
|
|||||||
goto cleanup_errno;
|
goto cleanup_errno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* WITH_SELINUX */
|
||||||
|
|
||||||
buflen = BUFLEN;
|
buflen = BUFLEN;
|
||||||
buf = (char *) malloc (buflen);
|
buf = (char *) malloc (buflen);
|
||||||
@ -689,7 +691,7 @@ int commonio_open (struct commonio_db *db, int mode)
|
|||||||
freecon (db->scontext);
|
freecon (db->scontext);
|
||||||
db->scontext = NULL;
|
db->scontext = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* WITH_SELINUX */
|
||||||
fclose (db->fp);
|
fclose (db->fp);
|
||||||
db->fp = NULL;
|
db->fp = NULL;
|
||||||
errno = saved_errno;
|
errno = saved_errno;
|
||||||
@ -837,7 +839,7 @@ int commonio_close (struct commonio_db *db)
|
|||||||
|
|
||||||
#ifdef WITH_SELINUX
|
#ifdef WITH_SELINUX
|
||||||
/*@null@*/security_context_t old_context = NULL;
|
/*@null@*/security_context_t old_context = NULL;
|
||||||
#endif
|
#endif /* WITH_SELINUX */
|
||||||
|
|
||||||
if (!db->isopen) {
|
if (!db->isopen) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
@ -873,7 +875,7 @@ int commonio_close (struct commonio_db *db)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* WITH_SELINUX */
|
||||||
/*
|
/*
|
||||||
* Create backup file.
|
* Create backup file.
|
||||||
*/
|
*/
|
||||||
@ -919,9 +921,9 @@ int commonio_close (struct commonio_db *db)
|
|||||||
if (fsync (fileno (db->fp)) != 0) {
|
if (fsync (fileno (db->fp)) != 0) {
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
#else
|
#else /* !HAVE_FSYNC */
|
||||||
sync ();
|
sync ();
|
||||||
#endif
|
#endif /* !HAVE_FSYNC */
|
||||||
if (fclose (db->fp) != 0) {
|
if (fclose (db->fp) != 0) {
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
@ -955,7 +957,7 @@ int commonio_close (struct commonio_db *db)
|
|||||||
freecon (db->scontext);
|
freecon (db->scontext);
|
||||||
db->scontext = NULL;
|
db->scontext = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* WITH_SELINUX */
|
||||||
free_linked_list (db);
|
free_linked_list (db);
|
||||||
return errors == 0;
|
return errors == 0;
|
||||||
}
|
}
|
||||||
@ -986,7 +988,7 @@ static /*@dependent@*/ /*@null@*/struct commonio_entry *find_entry_by_name (
|
|||||||
struct commonio_db *db,
|
struct commonio_db *db,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
return next_entry_by_name(db, db->head, name);
|
return next_entry_by_name (db, db->head, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1032,9 +1034,9 @@ int commonio_update (struct commonio_db *db, const void *eptr)
|
|||||||
|
|
||||||
#if KEEP_NIS_AT_END
|
#if KEEP_NIS_AT_END
|
||||||
add_one_entry_nis (db, p);
|
add_one_entry_nis (db, p);
|
||||||
#else
|
#else /* !KEEP_NIS_AT_END */
|
||||||
add_one_entry (db, p);
|
add_one_entry (db, p);
|
||||||
#endif
|
#endif /* !KEEP_NIS_AT_END */
|
||||||
|
|
||||||
db->changed = true;
|
db->changed = true;
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user