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
int commit_files()
{
    char* wf;

    if (!flag_dirty)
    {
        if (opt_verbose)
            printf("No changes needed\n");
        return 1;
    }

    if (opt_dryrun)
    {
        printf("Would commit %d changes\n", flag_dirty);
        return 1;
    }

    printf("%d changes have been made, rewriting files\n", flag_dirty);

    if (opt_verbose == 2)
        printf("Writing passwd-file to %s\n", sys_passwd);

    asprintf(&wf, "%s%s", sys_passwd, WRITE_EXTENSION);

    if (wf == NULL)
    {
        fprintf(stderr, "Not enough memory available while committing "
                        "passwd-file\n");
        return 0;
    }

    if (!write_passwd(system_accounts, wf))
    {
        free(wf);
        return 0;
    }

    if (!put_file_in_place(wf, sys_passwd))
    {
        free(wf);
        return 0;
    }

    free(wf);

    if (system_shadow != NULL)
    {
        if (opt_verbose == 2)
            printf("Writing shadow-file to %s\n", sys_shadow);

        asprintf(&wf, "%s%s", sys_shadow, WRITE_EXTENSION);

        if (wf == NULL)
        {
            fprintf(stderr, "Not enough memory available while committing "
                            "shadow-file\n");
            return 0;
        }

        if (!write_shadow(system_shadow, wf))
        {
            free(wf);
            return 0;
        }

        if (!put_file_in_place(wf, sys_shadow))
        {
            free(wf);
            return 0;
        }

        free(wf);
    }

    if (opt_verbose == 2)
        printf("Writing group-file to %s\n", sys_group);

    asprintf(&wf, "%s%s", sys_group, WRITE_EXTENSION);

    if (wf == NULL)
    {
        fprintf(stderr, "Not enough memory available while committing "
                        "group-file\n");
        return 0;
    }

    if (!write_group(system_groups, wf))
    {
        free(wf);
        return 0;
    }

    if (!put_file_in_place(wf, sys_group))
    {
        free(wf);
        return 0;
    }

    free(wf);

    return 1;
}
/* Rewrite the account-database if we made any changes
 */
Rewrite the account-database if we made any changes
Rewrite the account - database if we made any changes
int commit_files()
{
    char* wf;
    if (!flag_dirty)
    {
        if (opt_verbose)
            printf("No changes needed\n");
        return 1;
    }
    if (opt_dryrun)
    {
        printf("Would commit %d changes\n", flag_dirty);
        return 1;
    }
    printf("%d changes have been made, rewriting files\n", flag_dirty);
    if (opt_verbose == 2)
        printf("Writing passwd-file to %s\n", sys_passwd);
    asprintf(&wf, "%s%s", sys_passwd, WRITE_EXTENSION);
    if (wf == NULL)
    {
        fprintf(stderr, "Not enough memory available while committing "
                        "passwd-file\n");
        return 0;
    }
    if (!write_passwd(system_accounts, wf))
    {
        free(wf);
        return 0;
    }
    if (!put_file_in_place(wf, sys_passwd))
    {
        free(wf);
        return 0;
    }
    free(wf);
    if (system_shadow != NULL)
    {
        if (opt_verbose == 2)
            printf("Writing shadow-file to %s\n", sys_shadow);
        asprintf(&wf, "%s%s", sys_shadow, WRITE_EXTENSION);
        if (wf == NULL)
        {
            fprintf(stderr, "Not enough memory available while committing "
                            "shadow-file\n");
            return 0;
        }
        if (!write_shadow(system_shadow, wf))
        {
            free(wf);
            return 0;
        }
        if (!put_file_in_place(wf, sys_shadow))
        {
            free(wf);
            return 0;
        }
        free(wf);
    }
    if (opt_verbose == 2)
        printf("Writing group-file to %s\n", sys_group);
    asprintf(&wf, "%s%s", sys_group, WRITE_EXTENSION);
    if (wf == NULL)
    {
        fprintf(stderr, "Not enough memory available while committing "
                        "group-file\n");
        return 0;
    }
    if (!write_group(system_groups, wf))
    {
        free(wf);
        return 0;
    }
    if (!put_file_in_place(wf, sys_group))
    {
        free(wf);
        return 0;
    }
    free(wf);
    return 1;
}
int commit_files ( ) { char * wf ; if ( ! flag_dirty ) { if ( opt_verbose ) printf ( " \n " ) ; return 1 ; } if ( opt_dryrun ) { printf ( " \n " , flag_dirty ) ; return 1 ; } printf ( " \n " , flag_dirty ) ; if ( opt_verbose == 2 ) printf ( " \n " , sys_passwd ) ; asprintf ( & wf , " " , sys_passwd , WRITE_EXTENSION ) ; if ( wf == NULL ) { fprintf ( stderr , " " " \n " ) ; return 0 ; } if ( ! write_passwd ( system_accounts , wf ) ) { free ( wf ) ; return 0 ; } if ( ! put_file_in_place ( wf , sys_passwd ) ) { free ( wf ) ; return 0 ; } free ( wf ) ; if ( system_shadow != NULL ) { if ( opt_verbose == 2 ) printf ( " \n " , sys_shadow ) ; asprintf ( & wf , " " , sys_shadow , WRITE_EXTENSION ) ; if ( wf == NULL ) { fprintf ( stderr , " " " \n " ) ; return 0 ; } if ( ! write_shadow ( system_shadow , wf ) ) { free ( wf ) ; return 0 ; } if ( ! put_file_in_place ( wf , sys_shadow ) ) { free ( wf ) ; return 0 ; } free ( wf ) ; } if ( opt_verbose == 2 ) printf ( " \n " , sys_group ) ; asprintf ( & wf , " " , sys_group , WRITE_EXTENSION ) ; if ( wf == NULL ) { fprintf ( stderr , " " " \n " ) ; return 0 ; } if ( ! write_group ( system_groups , wf ) ) { free ( wf ) ; return 0 ; } if ( ! put_file_in_place ( wf , sys_group ) ) { free ( wf ) ; return 0 ; } free ( wf ) ; return 1 ; }
Rewrite the account-database if we made any changes
Rewrite the account - database if we made any changes