~ubuntu-branches/ubuntu/natty/freeradius/natty-updates

« back to all changes in this revision

Viewing changes to src/modules/rlm_unix/rlm_unix.c

  • Committer: Bazaar Package Importer
  • Author(s): Josip Rodin
  • Date: 2009-11-23 03:57:37 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20091123035737-zsgtzhfych8hir68
Tags: 2.1.7+dfsg-1
* Adopting the package, closes: #536623.
* New upstream version, closes: #513484.
  + Fixes the blooper in unlang evaluation logic, closes: #526175.
* Used quilt (and added README.source), and moved upstream file patching
  into debian/patches/. The source is no longer in collab-maint git
  (to make it simpler for me to finally get this out the door), but
  kept the .gitignore should we need that again.
* Dropped the dialup_admin/bin/backup_radacct patch (integrated upstream).
* Dropped the raddb/Makefile patch (problem no longer exists upstream).
* Dropped the lib/packet.c lib/radius.c main/listen.c patches (was from
  upstream 2.0.5 anyway).
* Dropped references to otp.conf, it no longer exists upstream.
  Keep removing the conffile statoverride in prerm.
* Dropped references to snmp.conf, it no longer exists upstream.
  Keep removing the conffile statoverride in prerm.
* Ship /etc/freeradius/modules/* in the freeradius package.
* Stop shipping sites-enabled symlinks in the package and instead create
  them only on initial install, thanks to Matej Vela, closes: #533396.
* Add export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" to the init script
  at the request of John Morrissey, closes: #550143.
* Stop installing /var/run/freeradius in the package to silence Lintian.
  The init script already recreates it at will.
* Remove executable bit from example.pl to silence Lintian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *              accounting:     Functions to write radwtmp file.
4
4
 *              Also contains handler for "Group".
5
5
 *
6
 
 * Version:     $Id: rlm_unix.c,v 1.85 2007/12/10 16:07:30 aland Exp $
 
6
 * Version:     $Id$
7
7
 *
8
8
 *   This program is free software; you can redistribute it and/or modify
9
9
 *   it under the terms of the GNU General Public License as published by
25
25
 */
26
26
 
27
27
#include        <freeradius-devel/ident.h>
28
 
RCSID("$Id: rlm_unix.c,v 1.85 2007/12/10 16:07:30 aland Exp $")
 
28
RCSID("$Id$")
29
29
 
30
30
#include        <freeradius-devel/radiusd.h>
31
31
 
249
249
         *      Users with a particular shell are denied access
250
250
         */
251
251
        if (strcmp(pwd->pw_shell, DENY_SHELL) == 0) {
252
 
                radlog(L_AUTH, "rlm_unix: [%s]: invalid shell", name);
 
252
                radlog_request(L_AUTH, 0, request,
 
253
                               "rlm_unix: [%s]: invalid shell", name);
253
254
                return RLM_MODULE_REJECT;
254
255
        }
255
256
#endif
267
268
        }
268
269
        endusershell();
269
270
        if (shell == NULL) {
270
 
                radlog(L_AUTH, "rlm_unix: [%s]: invalid shell [%s]",
 
271
                radlog_request(L_AUTH, 0, request, "[%s]: invalid shell [%s]",
271
272
                       name, pwd->pw_shell);
272
273
                return RLM_MODULE_REJECT;
273
274
        }
280
281
         */
281
282
        if (spwd && spwd->sp_expire > 0 &&
282
283
            (request->timestamp / 86400) > spwd->sp_expire) {
283
 
                radlog(L_AUTH, "rlm_unix: [%s]: password has expired", name);
 
284
                radlog_request(L_AUTH, 0, request, "[%s]: password has expired", name);
284
285
                return RLM_MODULE_REJECT;
285
286
        }
286
287
#endif
291
292
         */
292
293
        if ((pwd->pw_expire > 0) &&
293
294
            (request->timestamp > pwd->pw_expire)) {
294
 
                radlog(L_AUTH, "rlm_unix: [%s]: password has expired", name);
 
295
                radlog_request(L_AUTH, 0, request, "[%s]: password has expired", name);
295
296
                return RLM_MODULE_REJECT;
296
297
        }
297
298
#endif
354
355
 
355
356
        if (!request->password ||
356
357
            (request->password->attribute != PW_USER_PASSWORD)) {
357
 
                radlog(L_AUTH, "rlm_unix: Attribute \"User-Password\" is required for authentication.");
 
358
                radlog_request(L_AUTH, 0, request, "Attribute \"User-Password\" is required for authentication.");
358
359
                return RLM_MODULE_INVALID;
359
360
        }
360
361
 
366
367
         */
367
368
        if (fr_crypt_check((char *) request->password->vp_strvalue,
368
369
                             (char *) vp->vp_strvalue) != 0) {
369
 
                radlog(L_AUTH, "rlm_unix: [%s]: invalid password",
370
 
                       request->username->vp_strvalue);
 
370
                radlog_request(L_AUTH, 0, request, "invalid password \"%s\"",
 
371
                               request->username->vp_strvalue);
371
372
                return RLM_MODULE_REJECT;
372
373
        }
373
374
#endif /* OSFFIA */
420
421
        int             status = -1;
421
422
        int             nas_address = 0;
422
423
        int             framed_address = 0;
 
424
#ifdef USER_PROCESS
423
425
        int             protocol = -1;
 
426
#endif
424
427
        int             nas_port = 0;
425
428
        int             port_seen = 0;
426
 
        int             nas_port_type = 0;
427
429
        struct unix_instance *inst = (struct unix_instance *) instance;
428
430
 
429
431
        /*
430
432
         *      No radwtmp.  Don't do anything.
431
433
         */
432
434
        if (!inst->radwtmp) {
433
 
                DEBUG2("rlm_unix: No radwtmp file configured.  Ignoring accounting request.");
 
435
                RDEBUG2("No radwtmp file configured.  Ignoring accounting request.");
434
436
                return RLM_MODULE_NOOP;
435
437
        }
436
438
 
437
439
        if (request->packet->src_ipaddr.af != AF_INET) {
438
 
                DEBUG2("rlm_unix: IPv6 is not supported!");
 
440
                RDEBUG2("IPv6 is not supported!");
439
441
                return RLM_MODULE_NOOP;
440
442
        }
441
443
 
459
461
         *      We're only interested in accounting messages
460
462
         *      with a username in it.
461
463
         */
462
 
        if ((vp = pairfind(request->packet->vps, PW_USER_NAME)) == NULL)
 
464
        if (pairfind(request->packet->vps, PW_USER_NAME) == NULL)
463
465
                return RLM_MODULE_NOOP;
464
466
 
465
467
        t = request->timestamp;
481
483
                        case PW_FRAMED_IP_ADDRESS:
482
484
                                framed_address = vp->vp_ipaddr;
483
485
                                break;
 
486
#ifdef USER_PROCESS
484
487
                        case PW_FRAMED_PROTOCOL:
485
488
                                protocol = vp->vp_integer;
486
489
                                break;
 
490
#endif
487
491
                        case PW_NAS_IP_ADDRESS:
488
492
                                nas_address = vp->vp_ipaddr;
489
493
                                break;
494
498
                        case PW_ACCT_DELAY_TIME:
495
499
                                delay = vp->vp_ipaddr;
496
500
                                break;
497
 
                        case PW_NAS_PORT_TYPE:
498
 
                                nas_port_type = vp->vp_ipaddr;
499
 
                                break;
500
501
                }
501
502
        }
502
503
 
507
508
        if (strncmp(ut.ut_name, "!root", sizeof(ut.ut_name)) == 0 || !port_seen)
508
509
                return RLM_MODULE_NOOP;
509
510
 
510
 
        s = "";
511
 
 
512
511
        /*
513
512
         *      If we didn't find out the NAS address, use the
514
513
         *      originator's IP address.
515
514
         */
516
515
        if (nas_address == 0) {
517
516
                nas_address = request->packet->src_ipaddr.ipaddr.ip4addr.s_addr;
518
 
 
519
 
                s = request->client->shortname;
520
517
        }
 
518
        s = request->client->shortname;
521
519
        if (!s || s[0] == 0) s = uue(&(nas_address));
522
520
 
523
521
#ifdef __linux__