static void list_fields (void);
static void process_flags (int argc, char **argv, struct option_flags *flags);
static void check_flags (int argc, int opt_index);
-static void check_perms (struct option_flags *flags);
-static void open_files (bool readonly, struct option_flags *flags);
-static void close_files (struct option_flags *flags);
+static void check_perms(const struct option_flags *flags);
+static void open_files(bool readonly, const struct option_flags *flags);
+static void close_files(const struct option_flags *flags);
NORETURN static void fail_exit (int code, bool process_selinux);
/*
*
* It will not return if the user is not allowed.
*/
-static void check_perms (struct option_flags *flags)
+static void check_perms(const struct option_flags *flags)
{
bool process_selinux;
* In read-only mode, the databases are not locked and are opened
* only for reading.
*/
-static void open_files (bool readonly, struct option_flags *flags)
+static void open_files(bool readonly, const struct option_flags *flags)
{
bool process_selinux;
/*
* close_files - close and unlock the password/shadow databases
*/
-static void close_files (struct option_flags *flags)
+static void close_files(const struct option_flags *flags)
{
bool process_selinux;
uid_t ruid;
gid_t rgid;
const struct passwd *pw;
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false, .prefix = false};
bool process_selinux;
sanitize_env ();
static void new_fields (void);
static void process_flags (int argc, char **argv, struct option_flags *flags);
static void check_perms (const struct passwd *pw);
-static void update_gecos (const char *user, char *gecos, struct option_flags *flags);
+static void update_gecos(const char *user, char *gecos, const struct option_flags *flags);
static void get_old_fields (const char *gecos);
/*
*
* Commit the user's entry after changing her gecos field.
*/
-static void update_gecos (const char *user, char *gecos, struct option_flags *flags)
+static void update_gecos(const char *user, char *gecos, const struct option_flags *flags)
{
const struct passwd *pw; /* The user's password file entry */
struct passwd pwent; /* modified password file entry */
char new_gecos[80];
char *user, *p, *e;
const struct passwd *pw;
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false};
bool process_selinux;
sanitize_env ();
static void check_flags (void);
static void check_perms (void);
static void open_files (bool process_selinux);
-static void close_files (struct option_flags *flags);
+static void close_files(const struct option_flags *flags);
/*
* fail_exit - exit with a failure code after unlocking the files
/*
* close_files - close and unlock the group databases
*/
-static void close_files (struct option_flags *flags)
+static void close_files(const struct option_flags *flags)
{
bool process_selinux;
struct group newgr;
bool errors = false;
intmax_t line = 0;
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false};
bool process_selinux;
log_set_progname(Prog);
static void process_flags (int argc, char **argv, struct option_flags *flags);
static void check_flags (void);
static void check_perms (void);
-static void open_files (struct option_flags *flags);
-static void close_files (struct option_flags *flags);
+static void open_files(const struct option_flags *flags);
+static void close_files(const struct option_flags *flags);
/*
* fail_exit - exit with a failure code after unlocking the files
/*
* open_files - lock and open the password databases
*/
-static void open_files (struct option_flags *flags)
+static void open_files(const struct option_flags *flags)
{
bool process_selinux;
/*
* close_files - close and unlock the password databases
*/
-static void close_files (struct option_flags *flags)
+static void close_files(const struct option_flags *flags)
{
bool process_selinux;
bool errors = false;
intmax_t line = 0;
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false, .prefix = false};
bool process_selinux;
log_set_progname(Prog);
static bool shell_is_listed (const char *);
static bool is_restricted_shell (const char *);
static void process_flags (int argc, char **argv, struct option_flags *flags);
-static void check_perms (const struct passwd *pw, struct option_flags *flags);
+static void check_perms(const struct passwd *pw, const struct option_flags *flags);
static void update_shell (const char *user, char *loginsh,
- struct option_flags *flags);
+ const struct option_flags *flags);
/*
* fail_exit - do some cleanup and exit with the given error code
*
* It will not return if the user is not allowed.
*/
-static void check_perms (const struct passwd *pw, struct option_flags *flags)
+static void check_perms(const struct passwd *pw, const struct option_flags *flags)
{
#ifdef USE_PAM
pam_handle_t *pamh = NULL;
*
* It will not return in case of error.
*/
-static void update_shell (const char *user, char *newshell, struct option_flags *flags)
+static void update_shell (const char *user, char *newshell, const struct option_flags *flags)
{
const struct passwd *pw; /* Password entry from /etc/passwd */
struct passwd pwent; /* New password entry */
{
char *user; /* User name */
const struct passwd *pw; /* Password entry from /etc/passwd */
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false};
bool process_selinux;
sanitize_env ();
static void process_flags (int argc, char **argv, struct option_flags *flags);
static void check_flags (int argc, int opt_index);
static void open_files (void);
-static void close_files (struct option_flags *flags);
+static void close_files(const struct option_flags *flags);
#ifdef SHADOWGRP
-static void get_group (struct group *gr, struct sgrp *sg, struct option_flags *flags);
+static void get_group(struct group *gr, struct sgrp *sg, const struct option_flags *flags);
static void check_perms(const struct sgrp *sg);
static void update_group (struct group *gr, struct sgrp *sg);
static void change_passwd (struct group *gr, struct sgrp *sg);
#else
-static void get_group (struct group *gr, struct option_flags *flags);
+static void get_group(struct group *gr, const struct option_flags *flags);
static void check_perms(void);
static void update_group (struct group *gr);
static void change_passwd (struct group *gr);
*
* It will call exit in case of error.
*/
-static void close_files (struct option_flags *flags)
+static void close_files(const struct option_flags *flags)
{
bool process_selinux;
* Note: If !is_shadowgrp, *sg will not be initialized.
*/
#ifdef SHADOWGRP
-static void get_group (struct group *gr, struct sgrp *sg, struct option_flags *flags)
+static void get_group(struct group *gr, struct sgrp *sg, const struct option_flags *flags)
#else
-static void get_group (struct group *gr, struct option_flags *flags)
+static void get_group(struct group *gr, const struct option_flags *flags)
#endif
{
struct group const*tmpgr = NULL;
struct sgrp sgent;
#endif
struct passwd *pw = NULL;
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false};
#ifdef WITH_AUDIT
audit_help_open ();
#endif
static void grp_update (void);
static void check_new_name (void);
-static void close_files (struct option_flags *flags);
-static void open_files (struct option_flags *flags);
+static void close_files(const struct option_flags *flags);
+static void open_files(const struct option_flags *flags);
static void process_flags (int argc, char **argv, struct option_flags *flags);
static void check_flags (void);
static void check_perms (void);
* close_files() closes all of the files that were opened for this new
* group. This causes any modified entries to be written out.
*/
-static void close_files (struct option_flags *flags)
+static void close_files(const struct option_flags *flags)
{
bool process_selinux;
*
* open_files() opens the two group files.
*/
-static void open_files (struct option_flags *flags)
+static void open_files(const struct option_flags *flags)
{
bool process_selinux;
*/
int main (int argc, char **argv)
{
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false, .prefix = false};
log_set_progname(Prog);
log_set_logfd(stderr);
/* local function prototypes */
NORETURN static void usage (int status);
static void grp_update (void);
-static void close_files (struct option_flags *flags);
-static void open_files (struct option_flags *flags);
+static void close_files(const struct option_flags *flags);
+static void open_files(const struct option_flags *flags);
static void group_busy (gid_t gid);
static void process_flags (int argc, char **argv, struct option_flags *flags);
* close_files() closes all of the files that were opened for this
* new group. This causes any modified entries to be written out.
*/
-static void close_files (struct option_flags *flags)
+static void close_files(const struct option_flags *flags)
{
bool process_selinux;
*
* open_files() opens the two group files.
*/
-static void open_files (struct option_flags *flags)
+static void open_files(const struct option_flags *flags)
{
bool process_selinux;
int retval;
#endif /* USE_PAM */
#endif /* ACCT_TOOLS_SETUID */
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false, .prefix = false};
log_set_progname(Prog);
log_set_logfd(stderr);
#endif
}
-static void close_files (struct option_flags *flags)
+static void close_files(const struct option_flags *flags)
{
bool process_selinux;
{
char *name;
const struct group *grp;
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false};
bool process_selinux;
log_set_progname(Prog);
static void check_new_gid (void);
static void check_new_name (void);
static void process_flags (int, char **, struct option_flags *);
-static void lock_files (struct option_flags *flags);
+static void lock_files(const struct option_flags *flags);
static void prepare_failure_reports (void);
static void open_files (void);
-static void close_files (struct option_flags *flags);
+static void close_files(const struct option_flags *flags);
static void update_primary_groups (gid_t ogid, gid_t ngid);
* close_files() closes all of the files that were opened for this new
* group. This causes any modified entries to be written out.
*/
-static void close_files (struct option_flags *flags)
+static void close_files(const struct option_flags *flags)
{
bool process_selinux;
*
* lock_files() locks the group, gshadow, and passwd databases.
*/
-static void lock_files (struct option_flags *flags)
+static void lock_files(const struct option_flags *flags)
{
bool process_selinux;
int retval;
#endif /* USE_PAM */
#endif /* ACCT_TOOLS_SETUID */
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false, .prefix = false};
log_set_progname(Prog);
log_set_logfd(stderr);
static void delete_member (char **, const char *);
static void process_flags (int argc, char **argv, struct option_flags *flags);
static void open_files (bool process_selinux);
-static void close_files (bool changed, struct option_flags *flags);
+static void close_files(bool changed, const struct option_flags *flags);
static int check_members (const char *groupname,
char **members,
const char *fmt_info,
const char *fmt_syslog,
bool *errors);
static void check_grp_file (bool *errors, bool *changed,
- struct option_flags *flags);
+ const struct option_flags *flags);
#ifdef SHADOWGRP
static void compare_members_lists (const char *groupname,
char **members,
* changes are committed in the databases. The databases are
* unlocked anyway.
*/
-static void close_files (bool changed, struct option_flags *flags)
+static void close_files(bool changed, const struct option_flags *flags)
{
bool process_selinux;
/*
* check_grp_file - check the content of the group file
*/
-static void check_grp_file (bool *errors, bool *changed, struct option_flags *flags)
+static void check_grp_file(bool *errors, bool *changed, const struct option_flags *flags)
{
struct commonio_entry *gre, *tgre;
struct group *grp;
{
bool errors = false;
bool changed = false;
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false};
bool process_selinux;
log_set_progname(Prog);
struct group grent;
const struct sgrp *sg;
struct sgrp sgent;
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false};
bool process_selinux;
log_set_progname(Prog);
const struct group *gr;
struct group grent;
const struct sgrp *sg;
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false};
bool process_selinux;
log_set_progname(Prog);
static int add_passwd (struct passwd *, const char *);
static void process_flags (int argc, char **argv, struct option_flags *flags);
static void check_flags (void);
-static void check_perms (struct option_flags *flags);
+static void check_perms(const struct option_flags *flags);
static void open_files (bool process_selinux);
-static void close_files (struct option_flags *flags);
+static void close_files(const struct option_flags *flags);
extern int allow_bad_names;
*
* It will not return if the user is not allowed.
*/
-static void check_perms (struct option_flags *flags)
+static void check_perms(const struct option_flags *flags)
{
#ifdef ACCT_TOOLS_SETUID
#ifdef USE_PAM
/*
* close_files - close and unlock the password, group and shadow databases
*/
-static void close_files (struct option_flags *flags)
+static void close_files(const struct option_flags *flags)
{
bool process_selinux;
char **passwords = NULL;
size_t nusers = 0;
#endif /* USE_PAM */
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false};
bool process_selinux;
log_set_progname(Prog);
NORETURN static void fail_exit (int, bool);
NORETURN static void oom (bool process_selinux);
static char *update_crypt_pw (char *, bool);
-static void update_noshadow (struct option_flags *flags);
-
-static void update_shadow (struct option_flags *flags);
+static void update_noshadow(const struct option_flags *flags);
+static void update_shadow(const struct option_flags *flags);
/*
* usage - print command usage and exit
}
-static void update_noshadow (struct option_flags *flags)
+static void update_noshadow(const struct option_flags *flags)
{
const struct passwd *pw;
struct passwd *npw;
pw_locked = false;
}
-static void update_shadow (struct option_flags *flags)
+static void update_shadow(const struct option_flags *flags)
{
const struct spwd *sp;
struct spwd *nsp;
char *cp; /* Miscellaneous character pointing */
const struct spwd *sp; /* Shadow file entry for user */
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false, .prefix = false};
bool process_selinux;
sanitize_env ();
static void fail_exit (int code, bool process_selinux);
NORETURN static void usage (int status);
static void process_flags (int argc, char **argv, struct option_flags *flags);
-static void open_files (struct option_flags *flags);
-static void close_files (bool changed, struct option_flags *flags);
+static void open_files(const struct option_flags *flags);
+static void close_files(bool changed, const struct option_flags *flags);
static void check_pw_file (bool *errors, bool *changed,
- struct option_flags *flags);
+ const struct option_flags *flags);
static void check_spw_file (bool *errors, bool *changed);
extern int allow_bad_names;
* In read-only mode, the databases are not locked and are opened
* only for reading.
*/
-static void open_files (struct option_flags *flags)
+static void open_files(const struct option_flags *flags)
{
bool use_tcb = false;
#ifdef WITH_TCB
* changes are committed in the databases. The databases are
* unlocked anyway.
*/
-static void close_files (bool changed, struct option_flags *flags)
+static void close_files(bool changed, const struct option_flags *flags)
{
bool process_selinux;
/*
* check_pw_file - check the content of the passwd file
*/
-static void check_pw_file (bool *errors, bool *changed, struct option_flags *flags)
+static void check_pw_file(bool *errors, bool *changed, const struct option_flags *flags)
{
struct commonio_entry *pfe, *tpfe;
struct passwd *pwd;
{
bool errors = false;
bool changed = false;
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false};
bool process_selinux;
log_set_progname(Prog);
struct passwd pwent;
const struct spwd *sp;
struct spwd spent;
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false};
bool process_selinux;
log_set_progname(Prog);
const struct passwd *pw;
struct passwd pwent;
const struct spwd *spwd;
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false};
bool process_selinux;
log_set_progname(Prog);
/* local function prototypes */
NORETURN static void fail_exit (int, bool);
-static void get_defaults (struct option_flags *);
+static void get_defaults(const struct option_flags *);
static void show_defaults (void);
static int set_defaults (void);
-static int get_groups (char *, struct option_flags *);
+static int get_groups(char *, const struct option_flags *);
static struct group * get_local_group (char * grp_name, bool process_selinux);
NORETURN static void usage (int status);
static void new_pwent (struct passwd *);
static void grp_update (bool);
static void process_flags (int argc, char **argv, struct option_flags *flags);
-static void close_files (struct option_flags *flags);
+static void close_files(const struct option_flags *flags);
static void close_group_files (bool process_selinux);
static void unlock_group_files (bool process_selinux);
static void open_files (bool process_selinux);
#endif /* ENABLE_LASTLOG */
static void tallylog_reset (const char *);
static void usr_update (unsigned long subuid_count, unsigned long subgid_count,
- struct option_flags *flags);
-static void create_home (struct option_flags *flags);
-static void create_mail (struct option_flags *flags);
+ const struct option_flags *flags);
+static void create_home(const struct option_flags *flags);
+static void create_mail(const struct option_flags *flags);
static void check_uid_range(int rflg, uid_t user_id);
* file does not exist.
*/
static void
-get_defaults(struct option_flags *flags)
+get_defaults(const struct option_flags *flags)
{
FILE *fp;
char *default_file = USER_DEFAULTS_FILE;
* converts it to a NULL-terminated array. Any unknown group
* names are reported as errors.
*/
-static int get_groups (char *list, struct option_flags *flags)
+static int get_groups(char *list, const struct option_flags *flags)
{
struct group *grp;
bool errors = false;
* close_files() closes all of the files that were opened for this
* new user. This causes any modified entries to be written out.
*/
-static void close_files (struct option_flags *flags)
+static void close_files(const struct option_flags *flags)
{
bool process_selinux;
*/
static void
usr_update (unsigned long subuid_count, unsigned long subgid_count,
- struct option_flags *flags)
+ const struct option_flags *flags)
{
struct passwd pwent;
struct spwd spent;
* already exist. It will be created mode 755 owned by the user
* with the user's default group.
*/
-static void create_home (struct option_flags *flags)
+static void create_home(const struct option_flags *flags)
{
char path[strlen(prefix_user_home) + 2];
char *bhome, *cp;
* exist. It will be created mode 660 owned by the user and group
* 'mail'
*/
-static void create_mail (struct option_flags *flags)
+static void create_mail(const struct option_flags *flags)
{
int fd;
char *file;
#endif
unsigned long subuid_count = 0;
unsigned long subgid_count = 0;
- struct option_flags flags = {
- .chroot = false,
- .prefix = false,
- };
+ struct option_flags flags = {.chroot = false, .prefix = false};
bool process_selinux;
log_set_progname(Prog);
static void usage (int status);
static void update_groups (bool process_selinux);
static void remove_usergroup (bool process_selinux);
-static void close_files (struct option_flags *flags);
+static void close_files(const struct option_flags *flags);
static void fail_exit (int, bool);
static void open_files (bool process_selinux);
static void update_user (bool process_selinux);
* close_files() closes all of the files that were opened for this
* new user. This causes any modified entries to be written out.
*/
-static void close_files (struct option_flags *flags)
+static void close_files(const struct option_flags *flags)
{
bool process_selinux;
int retval;
#endif /* USE_PAM */
#endif /* ACCT_TOOLS_SETUID */
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false, .prefix = false};
bool process_selinux;
log_set_progname(Prog);
static void grp_update (bool process_selinux);
static void process_flags (int, char **, struct option_flags *);
-static void close_files (struct option_flags *);
+static void close_files(const struct option_flags *);
static void open_files (bool process_selinux);
-static void usr_update (struct option_flags *flags);
+static void usr_update(const struct option_flags *flags);
static void move_home (bool process_selinux);
#ifdef ENABLE_LASTLOG
static void update_lastlog (void);
* close_files() closes all of the files that were opened for this new
* user. This causes any modified entries to be written out.
*/
-static void close_files (struct option_flags *flags)
+static void close_files(const struct option_flags *flags)
{
bool process_selinux;
* usr_update() creates the password file entries for this user and
* will update the group entries if required.
*/
-static void usr_update (struct option_flags *flags)
+static void usr_update(const struct option_flags *flags)
{
struct passwd pwent;
const struct passwd *pwd;
int retval;
#endif /* USE_PAM */
#endif /* ACCT_TOOLS_SETUID */
- struct option_flags flags;
+ struct option_flags flags = {.chroot = false, .prefix = false};
bool process_selinux;
log_set_progname(Prog);