26RCSID(
"$Id: d1cc1b6c0b534884d13c5976fef7ddd0d7fe27f3 $")
29#define LOG_PREFIX mctx->mi->name
31#include <freeradius-devel/radius/radius.h>
32#include <freeradius-devel/server/base.h>
33#include <freeradius-devel/server/module_rlm.h>
34#include <freeradius-devel/util/perm.h>
35#include <freeradius-devel/unlang/xlat_func.h>
102 RPEDEBUG(
"Failed resolving user name");
107 RPEDEBUG(
"Failed resolving group name");
118 if (pwd->pw_gid == grp->gr_gid) {
124 for (member = grp->gr_mem; *member; member++) {
125 if (strcmp(*member, pwd->pw_name) == 0) {
153 char const *p = arg->vb_strvalue;
181 PERROR(
"Failed registering group expansion");
210 char const *encrypted_pass;
212 struct spwd *spwd = NULL;
215#ifdef HAVE_GETUSERSHELL
229 encrypted_pass = NULL;
231 if ((pwd = getpwnam(
name)) == NULL) {
234 encrypted_pass = pwd->pw_passwd;
246 if ((!encrypted_pass) || (strlen(encrypted_pass) < 10)) {
247 if ((spwd = getspnam(
name)) == NULL) {
250 encrypted_pass = spwd->sp_pwdp;
258 if (strcmp(pwd->pw_shell, DENY_SHELL) == 0) {
264#ifdef HAVE_GETUSERSHELL
269 while ((shell = getusershell()) != NULL) {
270 if (strcmp(shell, pwd->pw_shell) == 0 ||
271 strcmp(shell,
"/RADIUSD/ANY/SHELL") == 0) {
277 REDEBUG(
"[%s]: invalid shell [%s]",
name, pwd->pw_shell);
282#if defined(HAVE_GETSPNAM) && !defined(M_UNIX)
286 if (spwd && spwd->sp_lstchg > 0 && spwd->sp_max >= 0 &&
287 (
fr_time_to_sec(request->packet->timestamp) / 86400) > (spwd->sp_lstchg + spwd->sp_max)) {
294 if (spwd && spwd->sp_expire > 0 &&
295 (
fr_time_to_sec(request->packet->timestamp) / 86400) > spwd->sp_expire) {
301#if defined(__FreeBSD__) || defined(bsdi) || defined(_PWF_EXPIRE)
305 if ((pwd->pw_expire > 0) &&
317 if (encrypted_pass[0] == 0)
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
#define USES_APPLE_DEPRECATED_API
static int fr_dcursor_append(fr_dcursor_t *cursor, void *v)
Insert a single item at the end of the list.
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
Specifies an attribute which must be present for the module to function.
Specifies a dictionary which must be loaded/loadable for the module to function.
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
static xlat_action_t unix_group_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in)
Check if the user is a member of a particular unix group.
#define RPEDEBUG(fmt,...)
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_BOOL
A truth value.
#define fr_skip_whitespace(_p)
Skip whitespace ('\t', '\n', '\v', '\f', '\r', ' ')
module_instance_t * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for module calls.
Temporary structure to hold arguments for instantiation calls.
xlat_t * module_rlm_xlat_register(TALLOC_CTX *ctx, module_inst_ctx_t const *mctx, char const *name, xlat_func_t func, fr_type_t return_type)
module_t common
Common fields presented by all modules.
int fr_pair_value_strdup(fr_pair_t *vp, char const *src, bool tainted)
Copy data into an "string" data type.
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
int fr_perm_getgrnam(TALLOC_CTX *ctx, struct group **out, char const *name)
Resolve a group name to a group database entry.
int fr_perm_getpwnam(TALLOC_CTX *ctx, struct passwd **out, char const *name)
Resolve a username to a passwd entry.
#define RETURN_MODULE_REJECT
#define RETURN_MODULE_NOOP
#define RETURN_MODULE_UPDATED
rlm_rcode_t
Return codes indicating the result of the module call.
#define RETURN_MODULE_NOTFOUND
static fr_dict_attr_t const * attr_login_ip_host
static bool unix_check_group(request_t *request, char const *name)
Check if the user is in the given group.
static fr_dict_attr_t const * attr_crypt_password
static fr_dict_t const * dict_freeradius
static fr_dict_attr_t const * attr_expr_bool_enum
static fr_dict_t const * dict_radius
static int mod_bootstrap(module_inst_ctx_t const *mctx)
static fr_dict_attr_t const * attr_auth_type
static fr_dict_attr_t const * attr_nas_ip_address
static fr_dict_attr_t const * attr_framed_ip_address
static fr_dict_attr_t const * attr_framed_protocol
static fr_dict_attr_t const * attr_nas_port
static fr_dict_attr_t const * attr_acct_status_type
static fr_dict_attr_t const * attr_user_name
static fr_dict_attr_t const * attr_acct_delay_time
fr_dict_autoload_t rlm_unix_dict[]
static unlang_action_t mod_authorize(rlm_rcode_t *p_result, UNUSED module_ctx_t const *mctx, request_t *request)
fr_dict_attr_autoload_t rlm_unix_dict_attr[]
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
@ MODULE_TYPE_THREAD_UNSAFE
Module is not threadsafe.
module_flags_t flags
Flags that control how a module starts up and how a module is called.
void * boot
Data allocated during the boostrap phase.
#define MODULE_BINDING_TERMINATOR
Terminate a module binding list.
Named methods exported by a module.
#define pair_update_control(_attr, _da)
Return or allocate a fr_pair_t in the control list.
Stores an attribute, a value and various bits of other data.
static int64_t fr_time_to_sec(fr_time_t when)
Convert an fr_time_t (internal time) to number of sec since the unix epoch (wallclock time)
fr_type_t type
Type to cast argument to.
#define XLAT_ARG_PARSER_TERMINATOR
@ XLAT_ACTION_DONE
We're done evaluating this level of nesting.
Definition for a single argument consumend by an xlat function.
#define fr_value_box_alloc(_ctx, _type, _enumv)
Allocate a value box of a specific type.
static size_t char ** out
int xlat_func_args_set(xlat_t *x, xlat_arg_parser_t const args[])
Register the arguments of an xlat.