Avoid implicit brackets.
This commit is contained in:
parent
7279ff37f3
commit
3d04ff4037
@ -6,6 +6,7 @@
|
|||||||
get_old_fields(), and check_fields() split out of main().
|
get_old_fields(), and check_fields() split out of main().
|
||||||
* src/chfn.c: Before pam_end(), the return value of the previous
|
* src/chfn.c: Before pam_end(), the return value of the previous
|
||||||
pam API was already checked. No need to validate it again.
|
pam API was already checked. No need to validate it again.
|
||||||
|
* src/chfn.c: Avoid implicit brackets.
|
||||||
|
|
||||||
2007-12-31 Nicolas François <nicolas.francois@centraliens.net>
|
2007-12-31 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
71
src/chfn.c
71
src/chfn.c
@ -92,15 +92,16 @@ static void get_old_fields (const char *gecos);
|
|||||||
*/
|
*/
|
||||||
static void usage (void)
|
static void usage (void)
|
||||||
{
|
{
|
||||||
if (amroot)
|
if (amroot) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("Usage: %s [-f full_name] [-r room_no] "
|
_("Usage: %s [-f full_name] [-r room_no] "
|
||||||
"[-w work_ph]\n"
|
"[-w work_ph]\n"
|
||||||
"\t[-h home_ph] [-o other] [user]\n"), Prog);
|
"\t[-h home_ph] [-o other] [user]\n"), Prog);
|
||||||
else
|
} else {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("Usage: %s [-f full_name] [-r room_no] "
|
_("Usage: %s [-f full_name] [-r room_no] "
|
||||||
"[-w work_ph] [-h home_ph]\n"), Prog);
|
"[-w work_ph] [-h home_ph]\n"), Prog);
|
||||||
|
}
|
||||||
exit (E_USAGE);
|
exit (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,17 +127,23 @@ static int may_change_field (int field)
|
|||||||
* "no" is equivalent to "frwh". Only root can change anything
|
* "no" is equivalent to "frwh". Only root can change anything
|
||||||
* if the string is empty or not defined at all.
|
* if the string is empty or not defined at all.
|
||||||
*/
|
*/
|
||||||
if (amroot)
|
if (amroot) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
cp = getdef_str ("CHFN_RESTRICT");
|
cp = getdef_str ("CHFN_RESTRICT");
|
||||||
if (!cp)
|
if (!cp) {
|
||||||
cp = "";
|
cp = "";
|
||||||
else if (strcmp (cp, "yes") == 0)
|
} else if (strcmp (cp, "yes") == 0) {
|
||||||
cp = "rwh";
|
cp = "rwh";
|
||||||
else if (strcmp (cp, "no") == 0)
|
} else if (strcmp (cp, "no") == 0) {
|
||||||
cp = "frwh";
|
cp = "frwh";
|
||||||
if (strchr (cp, field))
|
}
|
||||||
|
|
||||||
|
if (strchr (cp, field)) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,28 +157,33 @@ static void new_fields (void)
|
|||||||
{
|
{
|
||||||
printf (_("Enter the new value, or press ENTER for the default\n"));
|
printf (_("Enter the new value, or press ENTER for the default\n"));
|
||||||
|
|
||||||
if (may_change_field ('f'))
|
if (may_change_field ('f')) {
|
||||||
change_field (fullnm, sizeof fullnm, _("Full Name"));
|
change_field (fullnm, sizeof fullnm, _("Full Name"));
|
||||||
else
|
} else {
|
||||||
printf (_("\tFull Name: %s\n"), fullnm);
|
printf (_("\tFull Name: %s\n"), fullnm);
|
||||||
|
}
|
||||||
|
|
||||||
if (may_change_field ('r'))
|
if (may_change_field ('r')) {
|
||||||
change_field (roomno, sizeof roomno, _("Room Number"));
|
change_field (roomno, sizeof roomno, _("Room Number"));
|
||||||
else
|
} else {
|
||||||
printf (_("\tRoom Number: %s\n"), roomno);
|
printf (_("\tRoom Number: %s\n"), roomno);
|
||||||
|
}
|
||||||
|
|
||||||
if (may_change_field ('w'))
|
if (may_change_field ('w')) {
|
||||||
change_field (workph, sizeof workph, _("Work Phone"));
|
change_field (workph, sizeof workph, _("Work Phone"));
|
||||||
else
|
} else {
|
||||||
printf (_("\tWork Phone: %s\n"), workph);
|
printf (_("\tWork Phone: %s\n"), workph);
|
||||||
|
}
|
||||||
|
|
||||||
if (may_change_field ('h'))
|
if (may_change_field ('h')) {
|
||||||
change_field (homeph, sizeof homeph, _("Home Phone"));
|
change_field (homeph, sizeof homeph, _("Home Phone"));
|
||||||
else
|
} else {
|
||||||
printf (_("\tHome Phone: %s\n"), homeph);
|
printf (_("\tHome Phone: %s\n"), homeph);
|
||||||
|
}
|
||||||
|
|
||||||
if (amroot)
|
if (amroot) {
|
||||||
change_field (slop, sizeof slop, _("Other"));
|
change_field (slop, sizeof slop, _("Other"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -189,22 +201,26 @@ static char *copy_field (char *in, char *out, char *extra)
|
|||||||
char *cp = NULL;
|
char *cp = NULL;
|
||||||
|
|
||||||
while (in) {
|
while (in) {
|
||||||
if ((cp = strchr (in, ',')))
|
if ((cp = strchr (in, ','))) {
|
||||||
*cp++ = '\0';
|
*cp++ = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
if (!strchr (in, '='))
|
if (!strchr (in, '=')) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (extra) {
|
if (extra) {
|
||||||
if (extra[0])
|
if (extra[0]) {
|
||||||
strcat (extra, ",");
|
strcat (extra, ",");
|
||||||
|
}
|
||||||
|
|
||||||
strcat (extra, in);
|
strcat (extra, in);
|
||||||
}
|
}
|
||||||
in = cp;
|
in = cp;
|
||||||
}
|
}
|
||||||
if (in && out)
|
if (in && out) {
|
||||||
strcpy (out, in);
|
strcpy (out, in);
|
||||||
|
}
|
||||||
|
|
||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
@ -325,8 +341,9 @@ static void check_perms (const struct passwd *pw)
|
|||||||
* any changes can be made. Idea from util-linux chfn/chsh.
|
* any changes can be made. Idea from util-linux chfn/chsh.
|
||||||
* --marekm
|
* --marekm
|
||||||
*/
|
*/
|
||||||
if (!amroot && getdef_bool ("CHFN_AUTH"))
|
if (!amroot && getdef_bool ("CHFN_AUTH")) {
|
||||||
passwd_check (pw->pw_name, pw->pw_passwd, "chfn");
|
passwd_check (pw->pw_name, pw->pw_passwd, "chfn");
|
||||||
|
}
|
||||||
|
|
||||||
#else /* !USE_PAM */
|
#else /* !USE_PAM */
|
||||||
retval = PAM_SUCCESS;
|
retval = PAM_SUCCESS;
|
||||||
@ -476,27 +493,31 @@ static void get_old_fields (const char *gecos)
|
|||||||
* Now get the room number. It is the next comma separated field,
|
* Now get the room number. It is the next comma separated field,
|
||||||
* if there is indeed one.
|
* if there is indeed one.
|
||||||
*/
|
*/
|
||||||
if (cp)
|
if (cp) {
|
||||||
cp = copy_field (cp, rflg ? (char *) 0 : roomno, slop);
|
cp = copy_field (cp, rflg ? (char *) 0 : roomno, slop);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now get the work phone number. It is the third field.
|
* Now get the work phone number. It is the third field.
|
||||||
*/
|
*/
|
||||||
if (cp)
|
if (cp) {
|
||||||
cp = copy_field (cp, wflg ? (char *) 0 : workph, slop);
|
cp = copy_field (cp, wflg ? (char *) 0 : workph, slop);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now get the home phone number. It is the fourth field.
|
* Now get the home phone number. It is the fourth field.
|
||||||
*/
|
*/
|
||||||
if (cp)
|
if (cp) {
|
||||||
cp = copy_field (cp, hflg ? (char *) 0 : homeph, slop);
|
cp = copy_field (cp, hflg ? (char *) 0 : homeph, slop);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Anything left over is "slop".
|
* Anything left over is "slop".
|
||||||
*/
|
*/
|
||||||
if (cp && !oflg) {
|
if (cp && !oflg) {
|
||||||
if (slop[0])
|
if (slop[0]) {
|
||||||
strcat (slop, ",");
|
strcat (slop, ",");
|
||||||
|
}
|
||||||
|
|
||||||
strcat (slop, cp);
|
strcat (slop, cp);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user