if (db->isopen) {
db->readonly = true;
- if (commonio_close (db) == 0) {
+ if (commonio_close (db, true) == 0) {
if (db->locked) {
dec_lock_count ();
}
}
-int commonio_close (struct commonio_db *db)
+int commonio_close (struct commonio_db *db, bool process_selinux)
{
bool errors = false;
char buf[1024];
}
#ifdef WITH_SELINUX
- if (set_selinux_file_context (db->filename, S_IFREG) != 0) {
+ if (process_selinux
+ && set_selinux_file_context (db->filename, S_IFREG) != 0) {
errors = true;
}
#endif
db->fp = NULL;
#ifdef WITH_SELINUX
- if (reset_selinux_file_context () != 0) {
+ if (process_selinux
+ && reset_selinux_file_context () != 0) {
errors = true;
}
#endif
goto fail;
#ifdef WITH_SELINUX
- if (set_selinux_file_context (db->filename, S_IFREG) != 0) {
+ if (process_selinux
+ && set_selinux_file_context (db->filename, S_IFREG) != 0) {
errors = true;
}
#endif
}
#ifdef WITH_SELINUX
- if (reset_selinux_file_context () != 0) {
+ if (process_selinux
+ && reset_selinux_file_context () != 0) {
goto fail;
}
#endif
extern int commonio_remove (struct commonio_db *, const char *);
extern int commonio_rewind (struct commonio_db *);
extern /*@observer@*/ /*@null@*/const void *commonio_next (struct commonio_db *);
-extern int commonio_close (struct commonio_db *);
+extern int commonio_close (struct commonio_db *, bool);
extern int commonio_unlock (struct commonio_db *);
extern void commonio_del_entry (struct commonio_db *,
const struct commonio_entry *);
int gr_close (void)
{
- return commonio_close (&group_db);
+ return commonio_close (&group_db, true);
}
int gr_unlock (void)
int pw_close (void)
{
- return commonio_close (&passwd_db);
+ return commonio_close (&passwd_db, true);
}
int pw_unlock (void)
int sgr_close (void)
{
- return commonio_close (&gshadow_db);
+ return commonio_close (&gshadow_db, true);
}
int sgr_unlock (void)
return 0;
}
#endif /* WITH_TCB */
- retval = commonio_close (&shadow_db);
+ retval = commonio_close (&shadow_db, true);
#ifdef WITH_TCB
if (use_tcb && (shadowtcb_gain_priv () == SHADOWTCB_FAILURE)) {
return 0;
int sub_uid_close (void)
{
- return commonio_close (&subordinate_uid_db);
+ return commonio_close (&subordinate_uid_db, true);
}
int sub_uid_unlock (void)
int sub_gid_close (void)
{
- return commonio_close (&subordinate_gid_db);
+ return commonio_close (&subordinate_gid_db, true);
}
int sub_gid_unlock (void)