~ubuntu-branches/ubuntu/maverick/krb5/maverick

« back to all changes in this revision

Viewing changes to src/kadmin/server/acls.l

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hartman
  • Date: 2009-05-07 16:16:34 UTC
  • mfrom: (13.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090507161634-xqyk0s9na0le4flj
Tags: 1.7dfsg~beta1-4
When  decrypting the TGS response fails with the subkey, try with the
session key to work around Heimdal bug, Closes: #527353 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%{
2
 
/*
3
 
 * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved.
4
 
 *
5
 
 * $Id: acls.l 8774 1996-07-22 20:49:46Z marc $
6
 
 * $Source$
7
 
 * 
8
 
 * $Log$
9
 
 * Revision 1.3  1996/07/22 20:28:49  marc
10
 
 * this commit includes all the changes on the OV_9510_INTEGRATION and
11
 
 * OV_MERGE branches.  This includes, but is not limited to, the new openvision
12
 
 * admin system, and major changes to gssapi to add functionality, and bring
13
 
 * the implementation in line with rfc1964.  before committing, the
14
 
 * code was built and tested for netbsd and solaris.
15
 
 *
16
 
 * Revision 1.2.4.1  1996/07/18 03:03:31  marc
17
 
 * merged in changes from OV_9510_BP to OV_9510_FINAL1
18
 
 *
19
 
 * Revision 1.2.2.1  1996/06/20  21:56:31  marc
20
 
 * File added to the repository on a branch
21
 
 *
22
 
 * Revision 1.2  1993/11/05  07:47:46  bjaspan
23
 
 * add and use cmp_gss_names, fix regexp bug
24
 
 *
25
 
 * Revision 1.1  1993/11/05  07:08:48  bjaspan
26
 
 * Initial revision
27
 
 *
28
 
 */
29
 
 
30
 
#if !defined(lint) && !defined(__CODECENTER__)
31
 
static char *rcsid = "$Header$";
32
 
#endif
33
 
 
34
 
enum tokens {
35
 
     NEWLINE = 257,
36
 
     COMMA,
37
 
     SEMI,
38
 
 
39
 
     GET = 300,
40
 
     ADD,
41
 
     MODIFY,
42
 
     DELETE,
43
 
 
44
 
     ID = 350,
45
 
};
46
 
 
47
 
typedef union {
48
 
     char *s;
49
 
} toktype;
50
 
 
51
 
toktype tokval;
52
 
int acl_lineno = 0;
53
 
 
54
 
%}
55
 
 
56
 
%%
57
 
 
58
 
\n              acl_lineno++; 
59
 
[ \t]*          ;
60
 
[ ]*#.*         ;
61
 
","             return (COMMA);
62
 
";"             return (SEMI);
63
 
"get"           return (GET);
64
 
"add"           return (ADD);
65
 
"modify"        return (MODIFY);
66
 
"delete"        return (DELETE);
67
 
^[^ \t\n]+              { tokval.s = yytext; return (ID); }
68
 
 
69
 
%%
70
 
     
71
 
#include <string.h>
72
 
#include <syslog.h>
73
 
#include <gssapi/gssapi.h>
74
 
#include <gssapi/gssapi_krb5.h>
75
 
#include <ovsec_admin/admin.h>
76
 
 
77
 
typedef struct _entry {
78
 
     gss_name_t gss_name;
79
 
     char *name;
80
 
     u_int privs;
81
 
     struct _entry *next;
82
 
} acl_entry;
83
 
 
84
 
static acl_entry *acl_head = NULL;
85
 
 
86
 
static void error(char *msg);
87
 
 
88
 
int parse_aclfile(FILE *acl_file)
89
 
{
90
 
     OM_uint32 gssstat, minor_stat;
91
 
     gss_buffer_desc in_buf;
92
 
     acl_entry *entry;
93
 
     enum tokens tok;
94
 
 
95
 
     yyin = acl_file;
96
 
 
97
 
     acl_lineno = 1;
98
 
     while ((tok = yylex()) != 0) {
99
 
          if (tok != ID) {
100
 
               error("expected identifier");
101
 
               goto error;
102
 
          }
103
 
 
104
 
          entry = (acl_entry *) malloc(sizeof(acl_entry));
105
 
          if (entry == NULL) {
106
 
               error("out of memory");
107
 
               goto error;
108
 
          }
109
 
          entry->name = strdup(tokval.s);
110
 
          entry->privs = 0;
111
 
          while (1) {
112
 
               switch (tok = yylex()) {
113
 
               case GET:
114
 
                    entry->privs |= OVSEC_KADM_PRIV_GET;
115
 
                    break;
116
 
               case ADD:
117
 
                    entry->privs |= OVSEC_KADM_PRIV_ADD;
118
 
                    break;
119
 
               case MODIFY:
120
 
                    entry->privs |= OVSEC_KADM_PRIV_MODIFY;
121
 
                    break;
122
 
               case DELETE:
123
 
                    entry->privs |= OVSEC_KADM_PRIV_DELETE;
124
 
                    break;
125
 
               default:
126
 
                    error("expected privilege");
127
 
                    goto error;
128
 
               }
129
 
               tok = yylex();
130
 
               if (tok == COMMA)
131
 
                    continue;
132
 
               else if (tok == SEMI)
133
 
                    break;
134
 
               else {
135
 
                    error("expected comma or semicolon");
136
 
                    goto error;
137
 
               }
138
 
          }
139
 
 
140
 
          in_buf.value = entry->name;
141
 
          in_buf.length = strlen(entry->name) + 1;
142
 
          gssstat = gss_import_name(&minor_stat, &in_buf,
143
 
                                    gss_nt_krb5_name, &entry->gss_name);
144
 
          if (gssstat != GSS_S_COMPLETE) {
145
 
               error("invalid name");
146
 
               goto error;
147
 
          }
148
 
          
149
 
          if (acl_head == NULL) {
150
 
               entry->next = NULL;
151
 
               acl_head = entry;
152
 
          } else {
153
 
               entry->next = acl_head;
154
 
               acl_head = entry;
155
 
          }
156
 
     }
157
 
     return 0;
158
 
 
159
 
error:
160
 
     return 1;
161
 
}
162
 
 
163
 
int acl_check(gss_name_t caller, int priv)
164
 
{
165
 
     acl_entry *entry;
166
 
     
167
 
     entry = acl_head;
168
 
     while (entry) {
169
 
          if (cmp_gss_names(entry->gss_name, caller) && entry->privs & priv)
170
 
               return 1;
171
 
          entry = entry->next;
172
 
     }
173
 
     return 0;
174
 
}
175
 
 
176
 
int cmp_gss_names(gss_name_t name1, gss_name_t name2)
177
 
{
178
 
     OM_uint32 minor_stat;
179
 
     int eq;
180
 
     (void) gss_compare_name(&minor_stat, name1, name2, &eq);
181
 
     return eq;
182
 
}
183
 
 
184
 
static void error(char *msg)
185
 
{
186
 
     syslog(LOG_ERR, "Error while parsing acl file, line %d: %s\n",
187
 
            acl_lineno, msg);
188
 
}
189
 
 
190
 
yywrap() { return(1); }