+2010-03-23 Nicolas François <nicolas.francois@centraliens.net>
+
+ * src/newgrp.c: Limit the scope of variable pid.
+ * src/login_nopam.c: Limit the scope of variables end, lineno, i,
+ str_len.
+ * src/logoutd.c: Limit the scope of variable c.
+ * src/vipw.c: Re-indent.
+ * src/vipw.c: Close the file after the creation of the backup.
+ * src/useradd.c (set_default): Close input file on failure.
+ * src/useradd.c: Limit the scope of variables spool, file, fd, gr,
+ gid, mode.
+ * src/passwd.c: Limit the scope of variables last and ok.
+ * src/chage.c: Fix typo (non breaking space).
+ * src/login.c: Limit the scope of variables erasechar killchar, c,
+ failed.
+ * src/groups.c: Limit the scope of variable ngroups, pri_grp, i.
+ * src/id.c: Limit the scope of variable i.
+
2010-03-22 Nicolas François <nicolas.francois@centraliens.net>
* lib/utent.c (getutline): Remove getutline(). This function is
}
if (NULL != cp) {
(void) printf ("%6.6s, %4.4s\n", cp + 4, cp + 20);
- } else {
+ } else {
(void) printf ("time_t: %lu\n", date);
}
#endif
{
#ifdef HAVE_GETGROUPS
long sys_ngroups;
- int ngroups;
GETGROUPS_T *groups;
- int pri_grp; /* TODO: should be GETGROUPS_T */
- int i;
#else
char *logname;
char *getlogin ();
*/
#ifdef HAVE_GETGROUPS
+ int i;
+ int pri_grp; /* TODO: should be GETGROUPS_T */
/*
* This system supports concurrent group sets, so I can ask
* the system to tell me which groups are currently set for
* this process.
*/
- ngroups = getgroups (sys_ngroups, groups);
+ int ngroups = getgroups (sys_ngroups, groups);
if (ngroups < 0) {
perror ("getgroups");
exit (EXIT_FAILURE);
{
uid_t ruid, euid;
gid_t rgid, egid;
- int i;
long sys_ngroups;
/*
* The group numbers will be printed followed by their names.
*/
if (aflg && (ngroups = getgroups (sys_ngroups, groups)) != -1) {
+ int i;
/*
* Start off the group message. It will be of the format
static void setup_tty (void)
{
TERMIO termio;
- int erasechar;
- int killchar;
if (GTTY (0, &termio) == 0) { /* get terminal characteristics */
+ int erasechar;
+ int killchar;
/*
* Add your favorite terminal modes here ...
fname = getdef_str ("NOLOGINS_FILE");
if ((NULL != fname) && (access (fname, F_OK) == 0)) {
FILE *nlfp;
- int c;
/*
* Cat the file if it can be opened, otherwise just
*/
nlfp = fopen (fname, "r");
if (NULL != nlfp) {
+ int c;
while ((c = getc (nlfp)) != EOF) {
if (c == '\n') {
(void) putchar ('\r');
#endif
unsigned int delay;
unsigned int retries;
- bool failed;
bool subroot = false;
#ifndef USE_PAM
bool is_console;
*/
failcount = 0;
while (true) {
- failed = false;
+ bool failed = false;
failcount++;
#ifdef HAS_PAM_FAIL_DELAY
#else /* ! USE_PAM */
while (true) { /* repeatedly get login/password pairs */
+ bool failed;
/* user_passwd is always a pointer to this constant string
* or a passwd or shadow password that will be memzero by
* pw_free / spw_free.
char *users; /* becomes list of login names */
char *froms; /* becomes list of terminals or hosts */
bool match = false;
- int end;
- int lineno = 0; /* for diagnostics */
/*
* Process the table one line at a time and stop at the first match.
*/
fp = fopen (TABLE, "r");
if (NULL != fp) {
+ int lineno = 0; /* for diagnostics */
while ( !match
&& (fgets (line, (int) sizeof (line), fp) == line)) {
+ int end;
lineno++;
end = (int) strlen (line) - 1;
if (line[end] != '\n') {
#ifdef PRIMARY_GROUP_MATCH
struct passwd *userinf;
#endif
- int i;
char *at;
/*
return true;
/* local, no need for xgetgrnam */
} else if ((group = getgrnam (tok)) != NULL) { /* try group membership */
+ int i;
for (i = 0; NULL != group->gr_mem[i]; i++) {
if (strcasecmp (string, group->gr_mem[i]) == 0) {
return true;
static bool from_match (const char *tok, const char *string)
{
size_t tok_len;
- size_t str_len;
/*
* If a token has the magic value "ALL" the match always succeeds. Return
if (string_match (tok, string)) { /* ALL or exact match */
return true;
} else if (tok[0] == '.') { /* domain: match last fields */
+ size_t str_len;
str_len = strlen (string);
tok_len = strlen (tok);
if ( (str_len > tok_len)
{
TERMIO oldt, newt;
FILE *mesg_file, *tty_file;
- int c;
bool is_tty;
tty_file = fdopen (tty_fd, "w");
mesg_file = fopen (HUP_MESG_FILE, "r");
if (NULL != mesg_file) {
+ int c;
while ((c = getc (mesg_file)) != EOF) {
if (c == '\n') {
putc ('\r', tty_file);
* receives SIGCHLD from the terminating subshell. -- JWP
*/
{
- pid_t child, pid;
+ pid_t child;
/* Ignore these signals. The signal handlers will later be
* restored to the default handlers. */
int cst = 0;
gid_t gid = getgid();
struct group *grp = getgrgid (gid);
+ pid_t pid;
do {
errno = 0;
*/
static void check_password (const struct passwd *pw, const struct spwd *sp)
{
- time_t now, last, ok;
+ time_t now;
int exp_status;
exp_status = isexpired (pw, sp);
* Passwords may only be changed after sp_min time is up.
*/
if (sp->sp_lstchg > 0) {
+ time_t last, ok;
last = sp->sp_lstchg * SCALE;
ok = last + (sp->sp_min > 0 ? sp->sp_min * SCALE : 0);
fprintf (stderr,
_("%s: line too long in %s: %s..."),
Prog, def_file, buf);
+ (void) fclose (ifp);
return -1;
}
}
*/
static void create_mail (void)
{
- char *spool, *file;
- int fd;
- struct group *gr;
- gid_t gid;
- mode_t mode;
-
if (strcasecmp (create_mail_spool, "yes") == 0) {
+ char *spool, *file;
+ int fd;
+ struct group *gr;
+ gid_t gid;
+ mode_t mode;
+
spool = getdef_str ("MAIL_DIR");
if (NULL == spool) {
spool = "/var/mail";
"%s %s", editor, fileedit);
if (system (buf) != 0) {
fprintf (stderr, "%s: %s: %s\n", progname, editor,
- strerror (errno));
+ strerror (errno));
exit (1);
} else {
exit (0);
free (to_rename);
vipwexit (_("failed to create backup file"), errno, 1);
}
+ (void) fclose (f);
} else {
#endif /* WITH_TCB */
to_rename = fileedit;