4
* $Id: pam_conv.y,v 1.1.1.2 2002/09/15 20:08:22 hartmans Exp $
6
* Copyright (c) Andrew G. Morgan 1997 <morgan@parc.power.net>
8
* This file is covered by the Linux-PAM License (which should be
9
* distributed with this file.)
12
const static char bisonid[]=
13
"$Id: pam_conv.y,v 1.1.1.2 2002/09/15 20:08:22 hartmans Exp $\n"
14
"Copyright (c) Andrew G. Morgan 1997-8 <morgan@linux.kernel.org>\n";
24
/* XXX - later we'll change this to be the specific conf file(s) */
25
#define newpamf stderr
27
#define PAM_D "./pam.d"
28
#define PAM_D_MODE 0755
29
#define PAM_D_MAGIC_HEADER \
31
"#[For version 1.0 syntax, the above header is optional]\n"
33
#define PAM_D_FILE_FMT PAM_D "/%s"
35
const char *old_to_new_ctrl_flag(const char *old);
36
void yyerror(const char *format, ...);
46
%type <string> tok path tokenls
62
: tok tok tok path tokenls NL {
67
/* make sure we have lower case */
68
for (i=0; $1[i]; ++i) {
69
$1[i] = tolower($1[i]);
72
/* $1 = service-name */
73
yyerror("Appending to " PAM_D "/%s", $1);
75
filename = malloc(strlen($1) + sizeof(PAM_D) + 6);
76
sprintf(filename, PAM_D_FILE_FMT, $1);
77
conf = fopen(filename, "r");
80
conf = fopen(filename, "w");
82
fprintf(conf, PAM_D_MAGIC_HEADER);
85
"# The PAM configuration file for the `%s' service\n"
90
conf = fopen(filename, "a");
93
yyerror("trouble opening %s - aborting", filename);
98
/* $2 = module-type */
99
fprintf(conf, "%-10s", $2);
102
/* $3 = required etc. */
106
trans = old_to_new_ctrl_flag($3);
108
fprintf(conf, " %-10s", trans);
111
/* $4 = module-path */
112
fprintf(conf, " %s", $4);
117
fprintf(conf, " \\\n\t\t%s", $5);
127
yyerror("malformed line");
139
len = strlen($1) + strlen($2) + 2;
141
sprintf($$,"%s %s",$1,$2);
152
/* XXX - this could be used to check if file present */
165
const char *old_to_new_ctrl_flag(const char *old)
167
static const char *clist[] = {
176
for (i=0; clist[i]; ++i) {
177
if (strcasecmp(clist[i], old) == 0) {
185
void yyerror(const char *format, ...)
189
fprintf(stderr, "line %d: ", current_line);
190
va_start(args, format);
191
vfprintf(stderr, format, args);
193
fprintf(stderr, "\n");
196
int main(int argc, char *argv[])
198
if (mkdir(PAM_D, PAM_D_MODE) != 0) {
199
yyerror(PAM_D " already exists.. aborting");