openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/shadow/4.6-r0/shadow-4.6/src/groupmod.c
static void prepare_failure_reports(void)
{
    info_group.name = group_name;
#ifdef SHADOWGRP
    info_gshadow.name = group_name;
#endif
    info_passwd.name = group_name;

    info_group.audit_msg = xmalloc(512);
#ifdef SHADOWGRP
    info_gshadow.audit_msg = xmalloc(512);
#endif
    info_passwd.audit_msg = xmalloc(512);

    (void)snprintf(info_group.audit_msg, 511, "changing %s; ", gr_dbname());
#ifdef SHADOWGRP
    (void)snprintf(info_gshadow.audit_msg, 511, "changing %s; ", sgr_dbname());
#endif
    (void)snprintf(info_passwd.audit_msg, 511, "changing %s; ", pw_dbname());

    info_group.action = info_group.audit_msg + strlen(info_group.audit_msg);
#ifdef SHADOWGRP
    info_gshadow.action =
        info_gshadow.audit_msg + strlen(info_gshadow.audit_msg);
#endif
    info_passwd.action = info_passwd.audit_msg + strlen(info_passwd.audit_msg);

    (void)snprintf(info_group.action, 511 - strlen(info_group.audit_msg),
                   "group %s/%lu", group_name, (unsigned long int)group_id);
#ifdef SHADOWGRP
    (void)snprintf(info_gshadow.action, 511 - strlen(info_group.audit_msg),
                   "group %s", group_name);
#endif
    (void)snprintf(info_passwd.action, 511 - strlen(info_group.audit_msg),
                   "group %s/%lu", group_name, (unsigned long int)group_id);

    if (nflg)
    {
        strncat(info_group.action,
                ", new name: ", 511 - strlen(info_group.audit_msg));
        strncat(info_group.action, group_newname,
                511 - strlen(info_group.audit_msg));

#ifdef SHADOWGRP
        strncat(info_gshadow.action,
                ", new name: ", 511 - strlen(info_gshadow.audit_msg));
        strncat(info_gshadow.action, group_newname,
                511 - strlen(info_gshadow.audit_msg));
#endif

        strncat(info_passwd.action,
                ", new name: ", 511 - strlen(info_passwd.audit_msg));
        strncat(info_passwd.action, group_newname,
                511 - strlen(info_passwd.audit_msg));
    }
    if (pflg)
    {
        strncat(info_group.action, ", new password",
                511 - strlen(info_group.audit_msg));

#ifdef SHADOWGRP
        strncat(info_gshadow.action, ", new password",
                511 - strlen(info_gshadow.audit_msg));
#endif
    }
    if (gflg)
    {
        strncat(info_group.action,
                ", new gid: ", 511 - strlen(info_group.audit_msg));
        (void)snprintf(info_group.action + strlen(info_group.action),
                       511 - strlen(info_group.audit_msg), "%lu",
                       (unsigned long int)group_newid);

        strncat(info_passwd.action,
                ", new gid: ", 511 - strlen(info_passwd.audit_msg));
        (void)snprintf(info_passwd.action + strlen(info_passwd.action),
                       511 - strlen(info_passwd.audit_msg), "%lu",
                       (unsigned long int)group_newid);
    }
    info_group.audit_msg[511] = '\0';
#ifdef SHADOWGRP
    info_gshadow.audit_msg[511] = '\0';
#endif
    info_passwd.audit_msg[511] = '\0';

    // FIXME: add a system cleanup
    add_cleanup(cleanup_report_mod_group, &info_group);
#ifdef SHADOWGRP
    if (is_shadow_grp && (pflg || nflg))
    {
        add_cleanup(cleanup_report_mod_gshadow, &info_gshadow);
    }
#endif
    if (gflg)
    {
        add_cleanup(cleanup_report_mod_passwd, &info_passwd);
    }
}
/*
 * prepare_failure_reports - Prepare the cleanup_info structure for logging
 * of success and failure to syslog or audit.
 */
Prepare the cleanup_info structure for logging
of success and failure to syslog or audit.
Prepare the cleanup_info structure for logging of success and failure to syslog or audit .
static void prepare_failure_reports(void)
{
    info_group.name = group_name;
#ifdef SHADOWGRP
    info_gshadow.name = group_name;
#endif
    info_passwd.name = group_name;
    info_group.audit_msg = xmalloc(512);
#ifdef SHADOWGRP
    info_gshadow.audit_msg = xmalloc(512);
#endif
    info_passwd.audit_msg = xmalloc(512);
    (void)snprintf(info_group.audit_msg, 511, "changing %s; ", gr_dbname());
#ifdef SHADOWGRP
    (void)snprintf(info_gshadow.audit_msg, 511, "changing %s; ", sgr_dbname());
#endif
    (void)snprintf(info_passwd.audit_msg, 511, "changing %s; ", pw_dbname());
    info_group.action = info_group.audit_msg + strlen(info_group.audit_msg);
#ifdef SHADOWGRP
    info_gshadow.action =
        info_gshadow.audit_msg + strlen(info_gshadow.audit_msg);
#endif
    info_passwd.action = info_passwd.audit_msg + strlen(info_passwd.audit_msg);
    (void)snprintf(info_group.action, 511 - strlen(info_group.audit_msg),
                   "group %s/%lu", group_name, (unsigned long int)group_id);
#ifdef SHADOWGRP
    (void)snprintf(info_gshadow.action, 511 - strlen(info_group.audit_msg),
                   "group %s", group_name);
#endif
    (void)snprintf(info_passwd.action, 511 - strlen(info_group.audit_msg),
                   "group %s/%lu", group_name, (unsigned long int)group_id);
    if (nflg)
    {
        strncat(info_group.action,
                ", new name: ", 511 - strlen(info_group.audit_msg));
        strncat(info_group.action, group_newname,
                511 - strlen(info_group.audit_msg));
#ifdef SHADOWGRP
        strncat(info_gshadow.action,
                ", new name: ", 511 - strlen(info_gshadow.audit_msg));
        strncat(info_gshadow.action, group_newname,
                511 - strlen(info_gshadow.audit_msg));
#endif
        strncat(info_passwd.action,
                ", new name: ", 511 - strlen(info_passwd.audit_msg));
        strncat(info_passwd.action, group_newname,
                511 - strlen(info_passwd.audit_msg));
    }
    if (pflg)
    {
        strncat(info_group.action, ", new password",
                511 - strlen(info_group.audit_msg));
#ifdef SHADOWGRP
        strncat(info_gshadow.action, ", new password",
                511 - strlen(info_gshadow.audit_msg));
#endif
    }
    if (gflg)
    {
        strncat(info_group.action,
                ", new gid: ", 511 - strlen(info_group.audit_msg));
        (void)snprintf(info_group.action + strlen(info_group.action),
                       511 - strlen(info_group.audit_msg), "%lu",
                       (unsigned long int)group_newid);
        strncat(info_passwd.action,
                ", new gid: ", 511 - strlen(info_passwd.audit_msg));
        (void)snprintf(info_passwd.action + strlen(info_passwd.action),
                       511 - strlen(info_passwd.audit_msg), "%lu",
                       (unsigned long int)group_newid);
    }
    info_group.audit_msg[511] = '\0';
#ifdef SHADOWGRP
    info_gshadow.audit_msg[511] = '\0';
#endif
    info_passwd.audit_msg[511] = '\0';
    add_cleanup(cleanup_report_mod_group, &info_group);
#ifdef SHADOWGRP
    if (is_shadow_grp && (pflg || nflg))
    {
        add_cleanup(cleanup_report_mod_gshadow, &info_gshadow);
    }
#endif
    if (gflg)
    {
        add_cleanup(cleanup_report_mod_passwd, &info_passwd);
    }
}
static void prepare_failure_reports ( void ) { info_group . name = group_name ; #ifdef SHADOWGRP info_gshadow . name = group_name ; #endif info_passwd . name = group_name ; info_group . audit_msg = xmalloc ( 512 ) ; #ifdef SHADOWGRP info_gshadow . audit_msg = xmalloc ( 512 ) ; #endif info_passwd . audit_msg = xmalloc ( 512 ) ; ( void ) snprintf ( info_group . audit_msg , 511 , " " , gr_dbname ( ) ) ; #ifdef SHADOWGRP ( void ) snprintf ( info_gshadow . audit_msg , 511 , " " , sgr_dbname ( ) ) ; #endif ( void ) snprintf ( info_passwd . audit_msg , 511 , " " , pw_dbname ( ) ) ; info_group . action = info_group . audit_msg + strlen ( info_group . audit_msg ) ; #ifdef SHADOWGRP info_gshadow . action = info_gshadow . audit_msg + strlen ( info_gshadow . audit_msg ) ; #endif info_passwd . action = info_passwd . audit_msg + strlen ( info_passwd . audit_msg ) ; ( void ) snprintf ( info_group . action , 511 - strlen ( info_group . audit_msg ) , " " , group_name , ( unsigned long int ) group_id ) ; #ifdef SHADOWGRP ( void ) snprintf ( info_gshadow . action , 511 - strlen ( info_group . audit_msg ) , " " , group_name ) ; #endif ( void ) snprintf ( info_passwd . action , 511 - strlen ( info_group . audit_msg ) , " " , group_name , ( unsigned long int ) group_id ) ; if ( nflg ) { strncat ( info_group . action , " " , 511 - strlen ( info_group . audit_msg ) ) ; strncat ( info_group . action , group_newname , 511 - strlen ( info_group . audit_msg ) ) ; #ifdef SHADOWGRP strncat ( info_gshadow . action , " " , 511 - strlen ( info_gshadow . audit_msg ) ) ; strncat ( info_gshadow . action , group_newname , 511 - strlen ( info_gshadow . audit_msg ) ) ; #endif strncat ( info_passwd . action , " " , 511 - strlen ( info_passwd . audit_msg ) ) ; strncat ( info_passwd . action , group_newname , 511 - strlen ( info_passwd . audit_msg ) ) ; } if ( pflg ) { strncat ( info_group . action , " " , 511 - strlen ( info_group . audit_msg ) ) ; #ifdef SHADOWGRP strncat ( info_gshadow . action , " " , 511 - strlen ( info_gshadow . audit_msg ) ) ; #endif } if ( gflg ) { strncat ( info_group . action , " " , 511 - strlen ( info_group . audit_msg ) ) ; ( void ) snprintf ( info_group . action + strlen ( info_group . action ) , 511 - strlen ( info_group . audit_msg ) , " " , ( unsigned long int ) group_newid ) ; strncat ( info_passwd . action , " " , 511 - strlen ( info_passwd . audit_msg ) ) ; ( void ) snprintf ( info_passwd . action + strlen ( info_passwd . action ) , 511 - strlen ( info_passwd . audit_msg ) , " " , ( unsigned long int ) group_newid ) ; } info_group . audit_msg [ 511 ] = ' \0 ' ; #ifdef SHADOWGRP info_gshadow . audit_msg [ 511 ] = ' \0 ' ; #endif info_passwd . audit_msg [ 511 ] = ' \0 ' ; add_cleanup ( cleanup_report_mod_group , & info_group ) ; #ifdef SHADOWGRP if ( is_shadow_grp && ( pflg || nflg ) ) { add_cleanup ( cleanup_report_mod_gshadow , & info_gshadow ) ; } #endif if ( gflg ) { add_cleanup ( cleanup_report_mod_passwd , & info_passwd ) ; } }
prepare_failure_reports - Prepare the cleanup_info structure for logging
 of success and failure to syslog or audit.
prepare_failure_reports - Prepare the cleanup_info structure for logging of success and failure to syslog or audit .
// FIXME: add a system cleanup