| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #ifndef COMMONIO_H |
| #define COMMONIO_H |
| |
| #ifdef WITH_SELINUX |
| #include <selinux/selinux.h> |
| #endif |
| |
| #include "defines.h" /* bool */ |
| |
| |
| |
| |
| struct commonio_entry { |
| char *line; |
| void *eptr; |
| struct commonio_entry *prev; |
| struct commonio_entry *next; |
| bool changed:1; |
| }; |
| |
| |
| |
| |
| struct commonio_ops { |
| |
| |
| |
| |
| void *(*dup) (const void *); |
| |
| |
| |
| |
| void (*free) ( void *); |
| |
| |
| |
| |
| |
| const char *(*getname) (const void *); |
| |
| |
| |
| |
| |
| void *(*parse) (const char *); |
| |
| |
| |
| |
| |
| int (*put) (const void *, FILE *); |
| |
| |
| |
| |
| |
| char *(*fgets) ( char *s, int n, FILE *stream); |
| int (*fputs) (const char *, FILE *); |
| |
| |
| |
| |
| |
| |
| |
| int (*open_hook) (void); |
| int (*close_hook) (void); |
| }; |
| |
| |
| |
| |
| struct commonio_db { |
| |
| |
| |
| char filename[1024]; |
| |
| |
| |
| |
| const struct commonio_ops *ops; |
| |
| |
| |
| |
| FILE *fp; |
| |
| #ifdef WITH_SELINUX |
| security_context_t scontext; |
| #endif |
| |
| |
| |
| mode_t st_mode; |
| uid_t st_uid; |
| gid_t st_gid; |
| |
| |
| |
| struct commonio_entry *head; |
| struct commonio_entry *tail; |
| struct commonio_entry *cursor; |
| |
| |
| |
| |
| bool changed:1; |
| bool isopen:1; |
| bool locked:1; |
| bool readonly:1; |
| }; |
| |
| extern int commonio_setname (struct commonio_db *, const char *); |
| extern bool commonio_present (const struct commonio_db *db); |
| extern int commonio_lock (struct commonio_db *); |
| extern int commonio_lock_nowait (struct commonio_db *, bool log); |
| extern int commonio_open (struct commonio_db *, int); |
| extern const void *commonio_locate (struct commonio_db *, const char *); |
| extern int commonio_update (struct commonio_db *, const void *); |
| #ifdef ENABLE_SUBIDS |
| extern int commonio_append (struct commonio_db *, const void *); |
| #endif /* ENABLE_SUBIDS */ |
| extern int commonio_remove (struct commonio_db *, const char *); |
| extern int commonio_rewind (struct commonio_db *); |
| extern const void *commonio_next (struct commonio_db *); |
| extern int commonio_close (struct commonio_db *); |
| extern int commonio_unlock (struct commonio_db *); |
| extern void commonio_del_entry (struct commonio_db *, |
| const struct commonio_entry *); |
| extern int commonio_sort_wrt (struct commonio_db *shadow, |
| const struct commonio_db *passwd); |
| extern int commonio_sort (struct commonio_db *db, |
| int (*cmp) (const void *, const void *)); |
| |
| #endif |