[PC-BSD Commits] r17788 - pcbsd-projects/AD_4_PCBSD/pam

svn at pcbsd.org svn at pcbsd.org
Mon Jul 16 20:44:48 PDT 2012


Author: johnh
Date: 2012-07-17 03:44:47 +0000 (Tue, 17 Jul 2012)
New Revision: 17788

Modified:
   pcbsd-projects/AD_4_PCBSD/pam/pam-lexer.l
   pcbsd-projects/AD_4_PCBSD/pam/pam-parser.y
   pcbsd-projects/AD_4_PCBSD/pam/pamconf.c
   pcbsd-projects/AD_4_PCBSD/pam/pamconf.h
Log:
Bug fixes. '/' was not being parsed properly. Some functions in the
parser moved into the main C program and externed to the parser also.



Modified: pcbsd-projects/AD_4_PCBSD/pam/pam-lexer.l
===================================================================
--- pcbsd-projects/AD_4_PCBSD/pam/pam-lexer.l	2012-07-16 21:47:49 UTC (rev 17787)
+++ pcbsd-projects/AD_4_PCBSD/pam/pam-lexer.l	2012-07-17 03:44:47 UTC (rev 17788)
@@ -18,7 +18,7 @@
 
 
 \n				{ return (NEWLINE); }
-^#(.+)?$		{ yylval.str = strdup(yytext); return (COMMENT); }
+^#(.+)?$		{ yylval.str = xstrdup(yytext); return (COMMENT); }
 
 auth			{ return (AUTH); }
 account			{ return (ACCOUNT); }
@@ -31,7 +31,7 @@
 optional		{ return (OPTIONAL); }
 include			{ return (INCLUDE); }
 
-[a-zA-Z0-9_\-\.]+	{ yylval.str = strdup(yytext); return (STRING); }
+[a-zA-Z0-9_\-\./]+	{ yylval.str = xstrdup(yytext); return (STRING); }
 [ \t]+
 
 %%

Modified: pcbsd-projects/AD_4_PCBSD/pam/pam-parser.y
===================================================================
--- pcbsd-projects/AD_4_PCBSD/pam/pam-parser.y	2012-07-16 21:47:49 UTC (rev 17787)
+++ pcbsd-projects/AD_4_PCBSD/pam/pam-parser.y	2012-07-17 03:44:47 UTC (rev 17788)
@@ -17,10 +17,6 @@
 extern	struct pam_entry *cur;
 
 extern	void add_argument(struct pam_entry *pe, const char *arg);
-extern	struct pam_entry *new_pam_entry(int facility);
-extern	void free_arguments(struct pam_entry *pe);
-extern	void free_pam_entry(struct pam_entry *pe);
-extern	void free_pam_entries(struct pam_entry_list *pe_list);
 
 %}
 
@@ -210,101 +206,7 @@
 	}
 }
 
-struct pam_entry *
-new_pam_entry(int facility)
-{
-	struct pam_entry *pe = xalloc(sizeof(*pe));
-	pe->pes_arguments = NULL;
-	pe->pes_narguments = 0;
-	pe->facility = facility;
-	pe->type = PAM_ENTRY_NULL;
-	bzero(&pe->pe, sizeof(pe->pe));
-
-	switch (facility) {
-		case AUTH:
-			TAILQ_INSERT_TAIL(&p_config.pc_auth, pe, entries);
-			pe->index = p_config.pc_auth_nentries;
-			p_config.pc_auth_nentries++;
-			break;
-
-		case ACCOUNT:
-			TAILQ_INSERT_TAIL(&p_config.pc_account, pe, entries);
-			pe->index = p_config.pc_account_nentries;
-			p_config.pc_account_nentries++;
-			break;
-
-		case SESSION:
-			TAILQ_INSERT_TAIL(&p_config.pc_session, pe, entries);
-			pe->index = p_config.pc_session_nentries;
-			p_config.pc_session_nentries++;
-			break;
-
-		case PASSWORD:
-			TAILQ_INSERT_TAIL(&p_config.pc_password, pe, entries);
-			pe->index = p_config.pc_password_nentries;
-			p_config.pc_password_nentries++;
-			break;
-
-		case COMMENT:
-			TAILQ_INSERT_TAIL(&p_config.pc_comment, pe, entries);
-			pe->index = p_config.pc_comment_nentries;
-			p_config.pc_comment_nentries++;
-			break;
-	}
-
-	return (pe);
-}
-
 void
-free_arguments(struct pam_entry *pe)
-{
-	if (pe != NULL) {
-		int i;
-
-		for (i = 0;i < pe->pes_narguments;i++) {
-			if (pe->pes_arguments[i] != NULL)
-				free(pe->pes_arguments[i]);
-			pe->pes_arguments[i] = 0;
-		}
-
-		free(pe->pes_arguments);
-		pe->pes_arguments = NULL;
-		pe->pes_narguments = 0;
-	}
-}
-
-void
-free_pam_entry(struct pam_entry *pe)
-{
-	switch (pe->type) {
-		case PAM_ENTRY_SERVICE:
-			free_arguments(pe);
-			free(pe->pes_module);
-			break;
-
-		case PAM_ENTRY_INCLUDE:
-			free(pe->pei_service);
-			break;
-
-		case PAM_ENTRY_COMMENT:
-			free(pe->pec_text);
-			break;
-	}
-
-	free(pe);
-}
-
-void
-free_pam_entries(struct pam_entry_list *pe_list)
-{
-	while (!TAILQ_EMPTY(pe_list)) {
-		struct pam_entry *pe = TAILQ_FIRST(pe_list);
-		TAILQ_REMOVE(pe_list, pe, entries);
-		free_pam_entry(pe);
-	}
-}
-
-void
 yyerror(const char *str)
 {
 	fprintf(stderr, "%s:%d: error: %s\n", __FILE__, lineno, str);

Modified: pcbsd-projects/AD_4_PCBSD/pam/pamconf.c
===================================================================
--- pcbsd-projects/AD_4_PCBSD/pam/pamconf.c	2012-07-16 21:47:49 UTC (rev 17787)
+++ pcbsd-projects/AD_4_PCBSD/pam/pamconf.c	2012-07-17 03:44:47 UTC (rev 17788)
@@ -72,6 +72,100 @@
 	return (ptr);
 }
 
+struct pam_entry *
+new_pam_entry(int facility)
+{
+	struct pam_entry *pe = xalloc(sizeof(*pe));
+	pe->pes_arguments = NULL;
+	pe->pes_narguments = 0;
+	pe->facility = facility;
+	pe->type = PAM_ENTRY_NULL;
+	bzero(&pe->pe, sizeof(pe->pe));
+
+	switch (facility) {
+		case AUTH:
+			TAILQ_INSERT_TAIL(&p_config.pc_auth, pe, entries);
+			pe->index = p_config.pc_auth_nentries;
+			p_config.pc_auth_nentries++;
+			break;
+
+		case ACCOUNT:
+			TAILQ_INSERT_TAIL(&p_config.pc_account, pe, entries);
+			pe->index = p_config.pc_account_nentries;
+			p_config.pc_account_nentries++;
+			break;
+
+		case SESSION:
+			TAILQ_INSERT_TAIL(&p_config.pc_session, pe, entries);
+			pe->index = p_config.pc_session_nentries;
+			p_config.pc_session_nentries++;
+			break;
+
+		case PASSWORD:
+			TAILQ_INSERT_TAIL(&p_config.pc_password, pe, entries);
+			pe->index = p_config.pc_password_nentries;
+			p_config.pc_password_nentries++;
+			break;
+
+		case COMMENT:
+			TAILQ_INSERT_TAIL(&p_config.pc_comment, pe, entries);
+			pe->index = p_config.pc_comment_nentries;
+			p_config.pc_comment_nentries++;
+			break;
+	}
+
+	return (pe);
+}
+
+void
+free_arguments(struct pam_entry *pe)
+{
+	if (pe != NULL) {
+		int i;
+
+		for (i = 0;i < pe->pes_narguments;i++) {
+			if (pe->pes_arguments[i] != NULL)
+				xfree(&pe->pes_arguments[i]);
+			pe->pes_arguments[i] = 0;
+		}
+
+		xfree(&pe->pes_arguments);
+		pe->pes_arguments = NULL;
+		pe->pes_narguments = 0;
+	}
+}
+
+void
+free_pam_entry(struct pam_entry *pe)
+{
+	switch (pe->type) {
+		case PAM_ENTRY_SERVICE:
+			free_arguments(pe);
+			xfree(&pe->pes_module);
+			break;
+
+		case PAM_ENTRY_INCLUDE:
+			xfree(&pe->pei_service);
+			break;
+
+		case PAM_ENTRY_COMMENT:
+			xfree(&pe->pec_text);
+			break;
+	}
+
+	free(pe);
+}
+
+void
+free_pam_entries(struct pam_entry_list *pe_list)
+{
+	while (!TAILQ_EMPTY(pe_list)) {
+		struct pam_entry *pe = TAILQ_FIRST(pe_list);
+		TAILQ_REMOVE(pe_list, pe, entries);
+		free_pam_entry(pe);
+	}
+}
+
 static void
 usage(void)
 {
@@ -165,6 +259,9 @@
 clean(char *str)
 {
 	char *ptr;
+
+	if (str == NULL)
+		return (NULL);
         
 	while (isspace(*str))
 		str++;
@@ -173,6 +270,7 @@
 		*ptr = 0;
 		ptr--;
 	}
+
 	return (str);
 }
 
@@ -638,7 +736,7 @@
 					TAILQ_REMOVE(pel, pe, entries);
 					TAILQ_REMOVE(&pam_fentries, pe, fentries);
 					free_pam_entry(pe);
-				} 
+				}
 
 			/*
 			 *	this is a include entry. If no service was specified,

Modified: pcbsd-projects/AD_4_PCBSD/pam/pamconf.h
===================================================================
--- pcbsd-projects/AD_4_PCBSD/pam/pamconf.h	2012-07-16 21:47:49 UTC (rev 17787)
+++ pcbsd-projects/AD_4_PCBSD/pam/pamconf.h	2012-07-17 03:44:47 UTC (rev 17788)
@@ -108,5 +108,10 @@
 
 #define	xfree(p) _xfree((char **)p)
 
+extern	struct pam_entry *new_pam_entry(int facility);
+extern	void free_arguments(struct pam_entry *pe);
+extern	void free_pam_entry(struct pam_entry *pe);
+extern	void free_pam_entries(struct pam_entry_list *pe_list);
 
+
 #endif	/* __PAMCONF_H */



More information about the Commits mailing list