openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/shadow/4.6-r0/shadow-4.6/libmisc/chowntty.c
void chown_tty(const struct passwd* info)
{
    struct group* grent;
    gid_t gid;

    /*
     * See if login.defs has some value configured for the port group
     * ID.  Otherwise, use the user's primary group ID.
     */

    grent = getgr_nam_gid(getdef_str("TTYGROUP"));
    if (NULL != grent)
    {
        gid = grent->gr_gid;
    }
    else
    {
        gid = info->pw_gid;
    }

    /*
     * Change the permissions on the TTY to be owned by the user with
     * the group as determined above.
     */

    if ((fchown(STDIN_FILENO, info->pw_uid, gid) != 0) ||
        (fchmod(STDIN_FILENO, (mode_t)getdef_num("TTYPERM", 0600)) != 0))
    {
        int err = errno;

        fprintf(stderr, _("Unable to change owner or mode of tty stdin: %s"),
                strerror(err));
        SYSLOG(
            (LOG_WARN,
             "unable to change owner or mode of tty stdin for user `%s': %s\n",
             info->pw_name, strerror(err)));
        if (EROFS != err)
        {
            closelog();
            exit(EXIT_FAILURE);
        }
    }
#ifdef __linux__
    /*
     * Please don't add code to chown /dev/vcs* to the user logging in -
     * it's a potential security hole.  I wouldn't like the previous user
     * to hold the file descriptor open and watch my screen.  We don't
     * have the *BSD revoke() system call yet, and vhangup() only works
     * for tty devices (which vcs* is not).  --marekm
     */
#endif
}
/*
 *	chown_tty() sets the login tty to be owned by the new user ID
 *	with TTYPERM modes
 */
chown_tty() sets the login tty to be owned by the new user ID
with TTYPERM modes
chown_tty () sets the login tty to be owned by the new user ID with TTYPERM modes
void chown_tty(const struct passwd* info)
{
    struct group* grent;
    gid_t gid;
    grent = getgr_nam_gid(getdef_str("TTYGROUP"));
    if (NULL != grent)
    {
        gid = grent->gr_gid;
    }
    else
    {
        gid = info->pw_gid;
    }
    if ((fchown(STDIN_FILENO, info->pw_uid, gid) != 0) ||
        (fchmod(STDIN_FILENO, (mode_t)getdef_num("TTYPERM", 0600)) != 0))
    {
        int err = errno;
        fprintf(stderr, _("Unable to change owner or mode of tty stdin: %s"),
                strerror(err));
        SYSLOG(
            (LOG_WARN,
             "unable to change owner or mode of tty stdin for user `%s': %s\n",
             info->pw_name, strerror(err)));
        if (EROFS != err)
        {
            closelog();
            exit(EXIT_FAILURE);
        }
    }
#ifdef __linux__
#endif
}
void chown_tty ( const struct passwd * info ) { struct group * grent ; gid_t gid ; grent = getgr_nam_gid ( getdef_str ( " " ) ) ; if ( NULL != grent ) { gid = grent -> gr_gid ; } else { gid = info -> pw_gid ; } if ( ( fchown ( STDIN_FILENO , info -> pw_uid , gid ) != 0 ) || ( fchmod ( STDIN_FILENO , ( mode_t ) getdef_num ( " " , 0600 ) ) != 0 ) ) { int err = errno ; fprintf ( stderr , _ ( " " ) , strerror ( err ) ) ; SYSLOG ( ( LOG_WARN , " \n " , info -> pw_name , strerror ( err ) ) ) ; if ( EROFS != err ) { closelog ( ) ; exit ( EXIT_FAILURE ) ; } } #ifdef __linux__ #endif }
chown_tty() sets the login tty to be owned by the new user ID
      with TTYPERM modes
chown_tty () sets the login tty to be owned by the new user ID with TTYPERM modes
/*
     * See if login.defs has some value configured for the port group
     * ID.  Otherwise, use the user's primary group ID.
     */ /*
     * Change the permissions on the TTY to be owned by the user with
     * the group as determined above.
     */ /*
     * Please don't add code to chown /dev/vcs* to the user logging in -
     * it's a potential security hole.  I wouldn't like the previous user
     * to hold the file descriptor open and watch my screen.  We don't
     * have the *BSD revoke() system call yet, and vhangup() only works
     * for tty devices (which vcs* is not).  --marekm
     */