* include/sys/strace.h (paranoid_printf): Define as not being part of "all"
output. * pwdgrp.h (pwdgrp::next_num): Rename from next_int. Returns true/false if parse operation succeeded. (pwdgrp::reparse): Remove. (pwdgrp::raw_ptr): New function. Returns pointer in line. (pwdgrp::next_num): New functions for parsing other than unsigned long. * grp.cc (pwdgrp::parse_group): Reinstate previous parsing behavior. Don't fill in fields with NULL and assign empty gr_mem to known pointer rather than doing a pointless calloc. Streamline gr_mem parsing. Don't increment curr_lines here. * passwd.cc (pwdgrp::parse_passwd): Use new behavior of next_num. Don't increment curr_lines here. * uinfo.cc (pwdgrp::next_str): Keep returning EOL if out of data. (pwdgrp::reparse): Remove. (pwdgrp::next_num): Rename from next_int. Return bool indicating success of parse, argument returns value parsed. (pwdgrp::add_line): Increment curr_lines here on successful parse. (pwdgrp::load): (from Pierre Humblet) Don't return status. Just report it here.
This commit is contained in:
@ -39,38 +39,36 @@ pwdgrp::parse_group ()
|
||||
char *dp;
|
||||
|
||||
# define grp (*group_buf)[curr_lines]
|
||||
|
||||
memset (&grp, 0, sizeof (grp));
|
||||
|
||||
grp.gr_name = next_str ();
|
||||
if (!grp.gr_name)
|
||||
if (!*grp.gr_name)
|
||||
return false;
|
||||
|
||||
grp.gr_passwd = next_str ();
|
||||
int n = next_int ();
|
||||
if (n >= 0)
|
||||
|
||||
if (!next_num (grp.gr_gid))
|
||||
return false;
|
||||
|
||||
int n;
|
||||
dp = raw_ptr ();
|
||||
for (n = 0; *next_str (','); n++)
|
||||
continue;
|
||||
|
||||
grp.gr_mem = &null_ptr;
|
||||
if (n)
|
||||
{
|
||||
grp.gr_gid = n;
|
||||
dp = next_str ();
|
||||
if (!dp)
|
||||
{
|
||||
static char empty[] = "";
|
||||
dp = empty;
|
||||
}
|
||||
int i = 0;
|
||||
for (char *cp = dp; (cp = strchr (cp, ',')) != NULL; cp++)
|
||||
i++;
|
||||
char **namearray = (char **) calloc (i + 2, sizeof (char *));
|
||||
char **namearray = (char **) calloc (n + 2, sizeof (char *));
|
||||
if (namearray)
|
||||
{
|
||||
reparse (dp);
|
||||
for (i = 0; (dp = next_str (',')); i++)
|
||||
for (int i = 0; i < n; i++, dp = strchr (dp, '\0') + 1)
|
||||
namearray[i] = dp;
|
||||
namearray[i] = NULL;
|
||||
grp.gr_mem = namearray;
|
||||
}
|
||||
curr_lines++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
return true;
|
||||
# undef grp
|
||||
}
|
||||
|
||||
@ -85,8 +83,7 @@ pwdgrp::read_group ()
|
||||
if ((*group_buf)[i].gr_mem != &null_ptr)
|
||||
free ((*group_buf)[i].gr_mem);
|
||||
|
||||
if (!gr.load ("/etc/group"))
|
||||
debug_printf ("gr.load failed");
|
||||
load ("/etc/group");
|
||||
|
||||
/* Complete /etc/group in memory if needed */
|
||||
if (!internal_getgrgid (myself->gid))
|
||||
@ -106,11 +103,11 @@ pwdgrp::read_group ()
|
||||
snprintf (linebuf, sizeof (linebuf), "%s:%s:%lu:%s",
|
||||
group_name, strbuf, myself->gid, cygheap->user.name ());
|
||||
debug_printf ("Completing /etc/group: %s", linebuf);
|
||||
gr.add_line (linebuf);
|
||||
add_line (linebuf);
|
||||
}
|
||||
static char NO_COPY pretty_ls[] = "????????::-1:";
|
||||
if (wincap.has_security ())
|
||||
gr.add_line (pretty_ls);
|
||||
add_line (pretty_ls);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user