* libmisc/chowntty.c: Avoid assignments in comparisons.
* libmisc/chowntty.c: Avoid implicit conversion of pointers to booleans. * libmisc/chowntty.c: Add brackets and parenthesis.
This commit is contained in:
parent
e91899c0da
commit
1e798b640d
@ -1,3 +1,10 @@
|
|||||||
|
2008-06-13 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* libmisc/chowntty.c: Avoid assignments in comparisons.
|
||||||
|
* libmisc/chowntty.c: Avoid implicit conversion of pointers to
|
||||||
|
booleans.
|
||||||
|
* libmisc/chowntty.c: Add brackets and parenthesis.
|
||||||
|
|
||||||
2008-06-13 Nicolas François <nicolas.francois@centraliens.net>
|
2008-06-13 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* libmisc/audit_help.c: Add brackets.
|
* libmisc/audit_help.c: Add brackets.
|
||||||
|
@ -78,21 +78,26 @@ void chown_tty (const char *tty, const struct passwd *info)
|
|||||||
* ID. Otherwise, use the user's primary group ID.
|
* ID. Otherwise, use the user's primary group ID.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!(group = getdef_str ("TTYGROUP")))
|
group = getdef_str ("TTYGROUP");
|
||||||
|
if (NULL == group) {
|
||||||
gid = info->pw_gid;
|
gid = info->pw_gid;
|
||||||
else if (group[0] >= '0' && group[0] <= '9')
|
} else if ((group[0] >= '0') && (group[0] <= '9')) {
|
||||||
gid = atoi (group);
|
gid = (gid_t) atol (group);
|
||||||
else if ((grent = getgrnam (group))) /* local, no need for xgetgrnam */
|
} else {
|
||||||
|
grent = getgrnam (group); /* local, no need for xgetgrnam */
|
||||||
|
if (NULL != grent) {
|
||||||
gid = grent->gr_gid;
|
gid = grent->gr_gid;
|
||||||
else
|
} else {
|
||||||
gid = info->pw_gid;
|
gid = info->pw_gid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Change the permissions on the TTY to be owned by the user with
|
* Change the permissions on the TTY to be owned by the user with
|
||||||
* the group as determined above.
|
* the group as determined above.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (*tty != '/') {
|
if ('/' != *tty) {
|
||||||
snprintf (full_tty, sizeof full_tty, "/dev/%s", tty);
|
snprintf (full_tty, sizeof full_tty, "/dev/%s", tty);
|
||||||
tty = full_tty;
|
tty = full_tty;
|
||||||
}
|
}
|
||||||
@ -104,8 +109,8 @@ void chown_tty (const char *tty, const struct passwd *info)
|
|||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((chown (tty, info->pw_uid, gid) != 0)||
|
if ( (chown (tty, info->pw_uid, gid) != 0)
|
||||||
(chmod (tty, getdef_num ("TTYPERM", 0600)) != 0)) {
|
|| (chmod (tty, getdef_num ("TTYPERM", 0600)) != 0)) {
|
||||||
int err = errno;
|
int err = errno;
|
||||||
|
|
||||||
snprintf (buf, sizeof buf, _("Unable to change tty %s"), tty);
|
snprintf (buf, sizeof buf, _("Unable to change tty %s"), tty);
|
||||||
@ -115,9 +120,10 @@ void chown_tty (const char *tty, const struct passwd *info)
|
|||||||
info->pw_name));
|
info->pw_name));
|
||||||
closelog ();
|
closelog ();
|
||||||
|
|
||||||
if (err != EROFS)
|
if (EROFS != err) {
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
/*
|
/*
|
||||||
* Please don't add code to chown /dev/vcs* to the user logging in -
|
* Please don't add code to chown /dev/vcs* to the user logging in -
|
||||||
|
Loading…
Reference in New Issue
Block a user