openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/base-passwd/3.5.29-r0/base-passwd-3.5.29/update-passwd.c
void process_changed_accounts(struct _node* passwd, struct _node* group,
                              struct _node* master)
{
    for (; passwd; passwd = passwd->next)
    {
        struct _node* mc; /* mastercopy of this account */

        if (((passwd->id < 0) || (passwd->id > 99)) && (passwd->id != 65534))
            continue;

        mc = find_by_named_entry(master, passwd);
        if (mc == NULL)
            continue;

        if (passwd->id != mc->id)
        {
            if (opt_verbose)
                printf("Changing uid of %s from %u to %u\n", passwd->name,
                       passwd->id, mc->id);
            passwd->id = mc->id;
            passwd->d.pw.pw_uid = mc->d.pw.pw_uid;
            flag_dirty++;
        }

        if (passwd->d.pw.pw_gid != mc->d.pw.pw_gid)
        {
            if (opt_verbose)
            {
                const struct _node* oldentry =
                    find_by_id(group, passwd->d.pw.pw_gid);
                const struct _node* newentry =
                    find_by_id(group, mc->d.pw.pw_gid);
                const char* oldname = oldentry ? oldentry->name : "ABSENT";
                const char* newname = newentry ? newentry->name : "ABSENT";
                printf("Changing gid of %s from %u (%s) to %u (%s)\n",
                       passwd->name, passwd->d.pw.pw_gid, oldname,
                       mc->d.pw.pw_gid, newname);
            }
            passwd->d.pw.pw_gid = mc->d.pw.pw_gid;
            flag_dirty++;
        }

        if (!keepgecos(specialusers, passwd->id))
            if ((passwd->d.pw.pw_gecos == NULL) ||
                (strcmp(passwd->d.pw.pw_gecos, mc->d.pw.pw_gecos) != 0))
            {
                if (opt_verbose)
                {
                    const char* oldgecos =
                        passwd->d.pw.pw_gecos ? passwd->d.pw.pw_gecos : "";
                    printf("Changing GECOS of %s from \"%s\" to \"%s\".\n",
                           passwd->name, oldgecos, mc->d.pw.pw_gecos);
                }
                /* We update the pw_gecos entry of passwd so it now points into
                 * the buffer from mc. This is safe for us, since we know we
                 * won't free the data in mc until after we are done.
                 */
                passwd->d.pw.pw_gecos = mc->d.pw.pw_gecos;
                flag_dirty++;
            }

        if (!keephome(specialusers, passwd->id))
            if ((passwd->d.pw.pw_dir == NULL) ||
                (strcmp(passwd->d.pw.pw_dir, mc->d.pw.pw_dir) != 0))
            {
                if (opt_verbose)
                {
                    const char* olddir =
                        passwd->d.pw.pw_dir ? passwd->d.pw.pw_dir : "(none)";
                    printf("Changing home-directory of %s from %s to %s\n",
                           passwd->name, olddir, mc->d.pw.pw_dir);
                }
                /* We update the pw_dir entry of passwd so it now points into
                 * the buffer from mc. This is safe for us, since we know we
                 * won't free the data in mc until after we are done.
                 */
                passwd->d.pw.pw_dir = mc->d.pw.pw_dir;
                flag_dirty++;
            }

        if (!keepshell(specialusers, passwd->id))
            if ((passwd->d.pw.pw_shell == NULL) ||
                (strcmp(passwd->d.pw.pw_shell, mc->d.pw.pw_shell) != 0))
            {
                if (opt_verbose)
                {
                    const char* oldshell = passwd->d.pw.pw_shell
                                               ? passwd->d.pw.pw_shell
                                               : "(none)";
                    printf("Changing shell of %s from %s to %s\n", passwd->name,
                           oldshell, mc->d.pw.pw_shell);
                }
                /* We update the pw_shell entry of passwd so it now points into
                 * the buffer from mc. This is safe for us, since we know we
                 * won't free the data in mc until after we are done.
                 */
                passwd->d.pw.pw_shell = mc->d.pw.pw_shell;
                flag_dirty++;
            }
    }
}
/* Check if account-information needs to be updated.
 */
Check if account-information needs to be updated.
Check if account - information needs to be updated .
void process_changed_accounts(struct _node* passwd, struct _node* group,
                              struct _node* master)
{
    for (; passwd; passwd = passwd->next)
    {
        struct _node* mc; 
        if (((passwd->id < 0) || (passwd->id > 99)) && (passwd->id != 65534))
            continue;
        mc = find_by_named_entry(master, passwd);
        if (mc == NULL)
            continue;
        if (passwd->id != mc->id)
        {
            if (opt_verbose)
                printf("Changing uid of %s from %u to %u\n", passwd->name,
                       passwd->id, mc->id);
            passwd->id = mc->id;
            passwd->d.pw.pw_uid = mc->d.pw.pw_uid;
            flag_dirty++;
        }
        if (passwd->d.pw.pw_gid != mc->d.pw.pw_gid)
        {
            if (opt_verbose)
            {
                const struct _node* oldentry =
                    find_by_id(group, passwd->d.pw.pw_gid);
                const struct _node* newentry =
                    find_by_id(group, mc->d.pw.pw_gid);
                const char* oldname = oldentry ? oldentry->name : "ABSENT";
                const char* newname = newentry ? newentry->name : "ABSENT";
                printf("Changing gid of %s from %u (%s) to %u (%s)\n",
                       passwd->name, passwd->d.pw.pw_gid, oldname,
                       mc->d.pw.pw_gid, newname);
            }
            passwd->d.pw.pw_gid = mc->d.pw.pw_gid;
            flag_dirty++;
        }
        if (!keepgecos(specialusers, passwd->id))
            if ((passwd->d.pw.pw_gecos == NULL) ||
                (strcmp(passwd->d.pw.pw_gecos, mc->d.pw.pw_gecos) != 0))
            {
                if (opt_verbose)
                {
                    const char* oldgecos =
                        passwd->d.pw.pw_gecos ? passwd->d.pw.pw_gecos : "";
                    printf("Changing GECOS of %s from \"%s\" to \"%s\".\n",
                           passwd->name, oldgecos, mc->d.pw.pw_gecos);
                }
                passwd->d.pw.pw_gecos = mc->d.pw.pw_gecos;
                flag_dirty++;
            }
        if (!keephome(specialusers, passwd->id))
            if ((passwd->d.pw.pw_dir == NULL) ||
                (strcmp(passwd->d.pw.pw_dir, mc->d.pw.pw_dir) != 0))
            {
                if (opt_verbose)
                {
                    const char* olddir =
                        passwd->d.pw.pw_dir ? passwd->d.pw.pw_dir : "(none)";
                    printf("Changing home-directory of %s from %s to %s\n",
                           passwd->name, olddir, mc->d.pw.pw_dir);
                }
                passwd->d.pw.pw_dir = mc->d.pw.pw_dir;
                flag_dirty++;
            }
        if (!keepshell(specialusers, passwd->id))
            if ((passwd->d.pw.pw_shell == NULL) ||
                (strcmp(passwd->d.pw.pw_shell, mc->d.pw.pw_shell) != 0))
            {
                if (opt_verbose)
                {
                    const char* oldshell = passwd->d.pw.pw_shell
                                               ? passwd->d.pw.pw_shell
                                               : "(none)";
                    printf("Changing shell of %s from %s to %s\n", passwd->name,
                           oldshell, mc->d.pw.pw_shell);
                }
                passwd->d.pw.pw_shell = mc->d.pw.pw_shell;
                flag_dirty++;
            }
    }
}
void process_changed_accounts ( struct _node * passwd , struct _node * group , struct _node * master ) { for ( ; passwd ; passwd = passwd -> next ) { struct _node * mc ; if ( ( ( passwd -> id < 0 ) || ( passwd -> id > 99 ) ) && ( passwd -> id != 65534 ) ) continue ; mc = find_by_named_entry ( master , passwd ) ; if ( mc == NULL ) continue ; if ( passwd -> id != mc -> id ) { if ( opt_verbose ) printf ( " \n " , passwd -> name , passwd -> id , mc -> id ) ; passwd -> id = mc -> id ; passwd -> d . pw . pw_uid = mc -> d . pw . pw_uid ; flag_dirty ++ ; } if ( passwd -> d . pw . pw_gid != mc -> d . pw . pw_gid ) { if ( opt_verbose ) { const struct _node * oldentry = find_by_id ( group , passwd -> d . pw . pw_gid ) ; const struct _node * newentry = find_by_id ( group , mc -> d . pw . pw_gid ) ; const char * oldname = oldentry ? oldentry -> name : " " ; const char * newname = newentry ? newentry -> name : " " ; printf ( " \n " , passwd -> name , passwd -> d . pw . pw_gid , oldname , mc -> d . pw . pw_gid , newname ) ; } passwd -> d . pw . pw_gid = mc -> d . pw . pw_gid ; flag_dirty ++ ; } if ( ! keepgecos ( specialusers , passwd -> id ) ) if ( ( passwd -> d . pw . pw_gecos == NULL ) || ( strcmp ( passwd -> d . pw . pw_gecos , mc -> d . pw . pw_gecos ) != 0 ) ) { if ( opt_verbose ) { const char * oldgecos = passwd -> d . pw . pw_gecos ? passwd -> d . pw . pw_gecos : " " ; printf ( " \" \" \" \" \n " , passwd -> name , oldgecos , mc -> d . pw . pw_gecos ) ; } passwd -> d . pw . pw_gecos = mc -> d . pw . pw_gecos ; flag_dirty ++ ; } if ( ! keephome ( specialusers , passwd -> id ) ) if ( ( passwd -> d . pw . pw_dir == NULL ) || ( strcmp ( passwd -> d . pw . pw_dir , mc -> d . pw . pw_dir ) != 0 ) ) { if ( opt_verbose ) { const char * olddir = passwd -> d . pw . pw_dir ? passwd -> d . pw . pw_dir : " " ; printf ( " \n " , passwd -> name , olddir , mc -> d . pw . pw_dir ) ; } passwd -> d . pw . pw_dir = mc -> d . pw . pw_dir ; flag_dirty ++ ; } if ( ! keepshell ( specialusers , passwd -> id ) ) if ( ( passwd -> d . pw . pw_shell == NULL ) || ( strcmp ( passwd -> d . pw . pw_shell , mc -> d . pw . pw_shell ) != 0 ) ) { if ( opt_verbose ) { const char * oldshell = passwd -> d . pw . pw_shell ? passwd -> d . pw . pw_shell : " " ; printf ( " \n " , passwd -> name , oldshell , mc -> d . pw . pw_shell ) ; } passwd -> d . pw . pw_shell = mc -> d . pw . pw_shell ; flag_dirty ++ ; } } }
Check if account-information needs to be updated.
Check if account - information needs to be updated .
/* mastercopy of this account */ /* We update the pw_gecos entry of passwd so it now points into
                 * the buffer from mc. This is safe for us, since we know we
                 * won't free the data in mc until after we are done.
                 */ /* We update the pw_dir entry of passwd so it now points into
                 * the buffer from mc. This is safe for us, since we know we
                 * won't free the data in mc until after we are done.
                 */ /* We update the pw_shell entry of passwd so it now points into
                 * the buffer from mc. This is safe for us, since we know we
                 * won't free the data in mc until after we are done.
                 */