~ubuntu-branches/ubuntu/raring/sudo/raring

« back to all changes in this revision

Viewing changes to plugins/sudoers/auth/securid.c

  • Committer: Package Import Robot
  • Author(s): Tyler Hicks
  • Date: 2012-07-16 14:01:42 UTC
  • mfrom: (1.3.22 sid)
  • Revision ID: package-import@ubuntu.com-20120716140142-b0tgau0k6nid4mrf
Tags: 1.8.5p2-1ubuntu1
* Merge from debian/testing (LP: #1024154), remaining changes:
  - debian/patches/keep_home_by_default.patch:
    + Set HOME in initial_keepenv_table.
  - debian/rules:
    + compile with --without-lecture --with-tty-tickets (Ubuntu specific)
    + install man/man8/sudo_root.8 in both flavours (Ubuntu specific)
    + install apport hooks
    + The ubuntu-sudo-as-admin-successful.patch was taken upstream by
      Debian however it requires a --enable-admin-flag configure flag to
      actually enable it in both flavours.
  - debian/control:
    + Mark Debian Vcs-* as XS-Debian-Vcs-*
    + update debian/control
  - debian/sudoers:
    + grant admin group sudo access
  - debian/source_sudo.py, debian/sudo-ldap.dirs, debian/sudo.dirs:
    + add usr/share/apport/package-hooks
  - debian/sudo.pam:
    + Use pam_env to read /etc/environment and /etc/default/locale
      environment files. Reading ~/.pam_environment is not permitted due to
      security reasons.
* Dropped changes:
  - debian/patches/lp927828-fix-abort-in-pam-modules-when-timestamp-valid.patch
    + Fixed upstream in 1.8.5
  - debian/patches/CVE-2012-2337.patch:
    + Fixed upstream in 1.8.4p5
  - debian/patches/pam_env_merge.patch:
    + Feature released upstream in 1.8.5
  - debian/{sudo,sudo-ldap}.{preinst,postinst,postrm}:
    + Drop Ubuntu-specific sudoers file migration code because the only
      upgrade path to quantal is from precise. All necessary sudoers file
      migration will have already been done by the time this version of the
      sudo package is installed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (c) 1999-2005, 2007, 2010-2011
3
 
 *      Todd C. Miller <Todd.Miller@courtesan.com>
4
 
 *
5
 
 * Permission to use, copy, modify, and distribute this software for any
6
 
 * purpose with or without fee is hereby granted, provided that the above
7
 
 * copyright notice and this permission notice appear in all copies.
8
 
 *
9
 
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
 
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
 
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
 
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
 
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
 
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
 
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
 
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
17
 
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
18
 
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
 
 *
20
 
 * Sponsored in part by the Defense Advanced Research Projects
21
 
 * Agency (DARPA) and Air Force Research Laboratory, Air Force
22
 
 * Materiel Command, USAF, under agreement number F39502-99-1-0512.
23
 
 */
24
 
 
25
 
#include <config.h>
26
 
 
27
 
#include <sys/types.h>
28
 
#include <sys/param.h>
29
 
#include <stdio.h>
30
 
#ifdef STDC_HEADERS
31
 
# include <stdlib.h>
32
 
# include <stddef.h>
33
 
#else
34
 
# ifdef HAVE_STDLIB_H
35
 
#  include <stdlib.h>
36
 
# endif
37
 
#endif /* STDC_HEADERS */
38
 
#ifdef HAVE_STRING_H
39
 
# include <string.h>
40
 
#endif /* HAVE_STRING_H */
41
 
#ifdef HAVE_STRINGS_H
42
 
# include <strings.h>
43
 
#endif /* HAVE_STRINGS_H */
44
 
#ifdef HAVE_UNISTD_H
45
 
# include <unistd.h>
46
 
#endif /* HAVE_UNISTD_H */
47
 
#include <pwd.h>
48
 
 
49
 
#include <sdi_athd.h>
50
 
#include <sdconf.h>
51
 
#include <sdacmvls.h>
52
 
 
53
 
#include "sudoers.h"
54
 
#include "sudo_auth.h"
55
 
 
56
 
union config_record configure;
57
 
 
58
 
int
59
 
securid_init(struct passwd *pw, sudo_auth *auth)
60
 
{
61
 
    static struct SD_CLIENT sd_dat;             /* SecurID data block */
62
 
 
63
 
    auth->data = (void *) &sd_dat;              /* For method-specific data */
64
 
 
65
 
    if (creadcfg() == 0)
66
 
        return AUTH_SUCCESS;
67
 
    else
68
 
        return AUTH_FATAL;
69
 
}
70
 
 
71
 
int
72
 
securid_setup(struct passwd *pw, char **promptp, sudo_auth *auth)
73
 
{
74
 
    struct SD_CLIENT *sd = (struct SD_CLIENT *) auth->data;
75
 
 
76
 
    /* Re-initialize SecurID every time. */
77
 
    if (sd_init(sd) == 0) {
78
 
        /* The programmer's guide says username is 32 bytes */
79
 
        strlcpy(sd->username, pw->pw_name, 32);
80
 
        return AUTH_SUCCESS;
81
 
    } else {
82
 
        warningx(_("unable to contact the SecurID server"));
83
 
        return AUTH_FATAL;
84
 
    }
85
 
}
86
 
 
87
 
int
88
 
securid_verify(struct passwd *pw, char *pass, sudo_auth *auth)
89
 
{
90
 
    struct SD_CLIENT *sd = (struct SD_CLIENT *) auth->data;
91
 
    int rval;
92
 
 
93
 
    rval = sd_auth(sd);
94
 
    sd_close();
95
 
    if (rval == ACM_OK)
96
 
        return AUTH_SUCCESS;
97
 
    else
98
 
        return AUTH_FAILURE;
99
 
}