2008-12-23 03:22:43 +05:30
|
|
|
/*
|
2021-12-05 21:05:27 +05:30
|
|
|
* SPDX-FileCopyrightText: 2008 , Nicolas François
|
2008-12-23 03:22:43 +05:30
|
|
|
*
|
2021-12-05 21:05:27 +05:30
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2008-12-23 03:22:43 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "defines.h"
|
|
|
|
#include "groupio.h"
|
|
|
|
#include "sgroupio.h"
|
|
|
|
#include "prototypes.h"
|
2021-11-29 05:07:53 +05:30
|
|
|
#include "shadowlog.h"
|
2008-12-23 03:22:43 +05:30
|
|
|
|
|
|
|
/*
|
|
|
|
* cleanup_report_add_group - Report failure to add a group to the system
|
|
|
|
*
|
|
|
|
* It should be registered when it is decided to add a group to the system.
|
|
|
|
*/
|
|
|
|
void cleanup_report_add_group (void *group_name)
|
|
|
|
{
|
2023-02-01 18:20:48 +05:30
|
|
|
const char *name = group_name;
|
2008-12-23 03:22:43 +05:30
|
|
|
|
|
|
|
SYSLOG ((LOG_ERR, "failed to add group %s", name));
|
|
|
|
#ifdef WITH_AUDIT
|
2021-11-29 05:07:53 +05:30
|
|
|
audit_logger (AUDIT_ADD_GROUP, log_get_progname(),
|
2008-12-23 03:22:43 +05:30
|
|
|
"",
|
|
|
|
name, AUDIT_NO_ID,
|
|
|
|
SHADOW_AUDIT_FAILURE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* cleanup_report_del_group - Report failure to remove a group from the system
|
|
|
|
*
|
|
|
|
* It should be registered when it is decided to remove a group from the system.
|
|
|
|
*/
|
|
|
|
void cleanup_report_del_group (void *group_name)
|
|
|
|
{
|
2023-02-01 18:20:48 +05:30
|
|
|
const char *name = group_name;
|
2008-12-23 03:22:43 +05:30
|
|
|
|
|
|
|
SYSLOG ((LOG_ERR, "failed to remove group %s", name));
|
|
|
|
#ifdef WITH_AUDIT
|
2021-11-29 05:07:53 +05:30
|
|
|
audit_logger (AUDIT_DEL_GROUP, log_get_progname(),
|
2008-12-23 03:22:43 +05:30
|
|
|
"",
|
|
|
|
name, AUDIT_NO_ID,
|
|
|
|
SHADOW_AUDIT_FAILURE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void cleanup_report_mod_group (void *cleanup_info)
|
|
|
|
{
|
|
|
|
const struct cleanup_info_mod *info;
|
|
|
|
info = (const struct cleanup_info_mod *)cleanup_info;
|
|
|
|
|
|
|
|
SYSLOG ((LOG_ERR,
|
|
|
|
"failed to change %s (%s)",
|
|
|
|
gr_dbname (),
|
|
|
|
info->action));
|
|
|
|
#ifdef WITH_AUDIT
|
2021-11-29 05:07:53 +05:30
|
|
|
audit_logger (AUDIT_USER_ACCT, log_get_progname(),
|
2008-12-23 03:22:43 +05:30
|
|
|
info->audit_msg,
|
|
|
|
info->name, AUDIT_NO_ID,
|
|
|
|
SHADOW_AUDIT_FAILURE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-12-23 06:09:54 +05:30
|
|
|
#ifdef SHADOWGRP
|
2008-12-23 03:22:43 +05:30
|
|
|
void cleanup_report_mod_gshadow (void *cleanup_info)
|
|
|
|
{
|
|
|
|
const struct cleanup_info_mod *info;
|
|
|
|
info = (const struct cleanup_info_mod *)cleanup_info;
|
|
|
|
|
|
|
|
SYSLOG ((LOG_ERR,
|
|
|
|
"failed to change %s (%s)",
|
|
|
|
sgr_dbname (),
|
|
|
|
info->action));
|
|
|
|
#ifdef WITH_AUDIT
|
2021-11-29 05:07:53 +05:30
|
|
|
audit_logger (AUDIT_USER_ACCT, log_get_progname(),
|
2008-12-23 03:22:43 +05:30
|
|
|
info->audit_msg,
|
|
|
|
info->name, AUDIT_NO_ID,
|
|
|
|
SHADOW_AUDIT_FAILURE);
|
|
|
|
#endif
|
|
|
|
}
|
2008-12-23 06:09:54 +05:30
|
|
|
#endif
|
2008-12-23 03:22:43 +05:30
|
|
|
|
|
|
|
/*
|
|
|
|
* cleanup_report_add_group_group - Report failure to add a group to group
|
|
|
|
*
|
|
|
|
* It should be registered when it is decided to add a group to the
|
|
|
|
* group database.
|
|
|
|
*/
|
|
|
|
void cleanup_report_add_group_group (void *group_name)
|
|
|
|
{
|
2023-02-01 18:20:48 +05:30
|
|
|
const char *name = group_name;
|
2008-12-23 03:22:43 +05:30
|
|
|
|
|
|
|
SYSLOG ((LOG_ERR, "failed to add group %s to %s", name, gr_dbname ()));
|
|
|
|
#ifdef WITH_AUDIT
|
2021-11-29 05:07:53 +05:30
|
|
|
audit_logger (AUDIT_ADD_GROUP, log_get_progname(),
|
2008-12-23 03:22:43 +05:30
|
|
|
"adding group to /etc/group",
|
|
|
|
name, AUDIT_NO_ID,
|
|
|
|
SHADOW_AUDIT_FAILURE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SHADOWGRP
|
|
|
|
/*
|
|
|
|
* cleanup_report_add_group_gshadow - Report failure to add a group to gshadow
|
|
|
|
*
|
|
|
|
* It should be registered when it is decided to add a group to the
|
|
|
|
* gshadow database.
|
|
|
|
*/
|
|
|
|
void cleanup_report_add_group_gshadow (void *group_name)
|
|
|
|
{
|
2023-02-01 18:20:48 +05:30
|
|
|
const char *name = group_name;
|
2008-12-23 03:22:43 +05:30
|
|
|
|
|
|
|
SYSLOG ((LOG_ERR, "failed to add group %s to %s", name, sgr_dbname ()));
|
|
|
|
#ifdef WITH_AUDIT
|
2021-11-29 05:07:53 +05:30
|
|
|
audit_logger (AUDIT_ADD_GROUP, log_get_progname(),
|
2008-12-23 03:22:43 +05:30
|
|
|
"adding group to /etc/gshadow",
|
|
|
|
name, AUDIT_NO_ID,
|
|
|
|
SHADOW_AUDIT_FAILURE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* cleanup_report_del_group_group - Report failure to remove a group from the
|
|
|
|
* regular group database
|
|
|
|
*
|
|
|
|
* It should be registered when it is decided to remove a group from the
|
|
|
|
* regular group database.
|
|
|
|
*/
|
|
|
|
void cleanup_report_del_group_group (void *group_name)
|
|
|
|
{
|
2023-02-01 18:20:48 +05:30
|
|
|
const char *name = group_name;
|
2008-12-23 03:22:43 +05:30
|
|
|
|
|
|
|
SYSLOG ((LOG_ERR,
|
|
|
|
"failed to remove group %s from %s",
|
|
|
|
name, gr_dbname ()));
|
|
|
|
#ifdef WITH_AUDIT
|
2021-11-29 05:07:53 +05:30
|
|
|
audit_logger (AUDIT_ADD_GROUP, log_get_progname(),
|
2008-12-23 03:22:43 +05:30
|
|
|
"removing group from /etc/group",
|
|
|
|
name, AUDIT_NO_ID,
|
|
|
|
SHADOW_AUDIT_FAILURE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SHADOWGRP
|
|
|
|
/*
|
|
|
|
* cleanup_report_del_group_gshadow - Report failure to remove a group from
|
|
|
|
* gshadow
|
|
|
|
*
|
|
|
|
* It should be registered when it is decided to remove a group from the
|
|
|
|
* gshadow database.
|
|
|
|
*/
|
|
|
|
void cleanup_report_del_group_gshadow (void *group_name)
|
|
|
|
{
|
2023-02-01 18:20:48 +05:30
|
|
|
const char *name = group_name;
|
2008-12-23 03:22:43 +05:30
|
|
|
|
|
|
|
SYSLOG ((LOG_ERR,
|
|
|
|
"failed to remove group %s from %s",
|
|
|
|
name, sgr_dbname ()));
|
|
|
|
#ifdef WITH_AUDIT
|
2021-11-29 05:07:53 +05:30
|
|
|
audit_logger (AUDIT_ADD_GROUP, log_get_progname(),
|
2008-12-23 03:22:43 +05:30
|
|
|
"removing group from /etc/gshadow",
|
|
|
|
name, AUDIT_NO_ID,
|
|
|
|
SHADOW_AUDIT_FAILURE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* cleanup_unlock_group - Unlock the group file
|
|
|
|
*
|
|
|
|
* It should be registered after the group file is successfully locked.
|
|
|
|
*/
|
|
|
|
void cleanup_unlock_group (unused void *arg)
|
|
|
|
{
|
|
|
|
if (gr_unlock () == 0) {
|
2021-11-29 05:07:53 +05:30
|
|
|
fprintf (log_get_logfd(),
|
2008-12-23 03:22:43 +05:30
|
|
|
_("%s: failed to unlock %s\n"),
|
2021-11-29 05:07:53 +05:30
|
|
|
log_get_progname(), gr_dbname ());
|
2008-12-23 03:22:43 +05:30
|
|
|
SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
|
|
|
|
#ifdef WITH_AUDIT
|
|
|
|
audit_logger_message ("unlocking group file",
|
|
|
|
SHADOW_AUDIT_FAILURE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SHADOWGRP
|
|
|
|
/*
|
|
|
|
* cleanup_unlock_gshadow - Unlock the gshadow file
|
|
|
|
*
|
|
|
|
* It should be registered after the gshadow file is successfully locked.
|
|
|
|
*/
|
|
|
|
void cleanup_unlock_gshadow (unused void *arg)
|
|
|
|
{
|
|
|
|
if (sgr_unlock () == 0) {
|
2021-11-29 05:07:53 +05:30
|
|
|
fprintf (log_get_logfd(),
|
2008-12-23 03:22:43 +05:30
|
|
|
_("%s: failed to unlock %s\n"),
|
2021-11-29 05:07:53 +05:30
|
|
|
log_get_progname(), sgr_dbname ());
|
2008-12-23 03:22:43 +05:30
|
|
|
SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
|
|
|
|
#ifdef WITH_AUDIT
|
|
|
|
audit_logger_message ("unlocking gshadow file",
|
|
|
|
SHADOW_AUDIT_FAILURE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|