From 7e3f5c09f57b2a12165dd6ff8aeda5aa1ccdae2a Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Sat, 26 Feb 2000 03:44:56 +0000 Subject: [PATCH] * server_acl.c (acl_get_line): Patch from Matt Crawford to permit line continuation by ending a line with a backslash git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12081 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/kadm5/srv/ChangeLog | 5 ++++ src/lib/kadm5/srv/server_acl.c | 48 +++++++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/lib/kadm5/srv/ChangeLog b/src/lib/kadm5/srv/ChangeLog index 23d05d607..cc1a96808 100644 --- a/src/lib/kadm5/srv/ChangeLog +++ b/src/lib/kadm5/srv/ChangeLog @@ -1,3 +1,8 @@ +2000-02-25 Ken Raeburn + + * server_acl.c (acl_get_line): Patch from Matt Crawford to permit + line continuation by ending a line with a backslash. + 2000-02-13 Tom Yu * svr_principal.c (kadm5_setkey_principal_3): New function. diff --git a/src/lib/kadm5/srv/server_acl.c b/src/lib/kadm5/srv/server_acl.c index 776b7e513..8d330ec7c 100644 --- a/src/lib/kadm5/srv/server_acl.c +++ b/src/lib/kadm5/srv/server_acl.c @@ -87,34 +87,56 @@ static const char *acl_cantopen_msg = "%s while opening ACL file %s"; /* * acl_get_line() - Get a line from the ACL file. + * Lines ending with \ are continued on the next line */ static char * acl_get_line(fp, lnp) FILE *fp; - int *lnp; + int *lnp; /* caller should set to 1 before first call */ { int i, domore; + static int line_incr = 0; static char acl_buf[BUFSIZ]; + *lnp += line_incr; + line_incr = 0; for (domore = 1; domore && !feof(fp); ) { - /* Copy in the line */ - for (i=0; - ((i 0 && acl_buf[i-1] == '\\') + i--; + break; /* it gets nulled-out below */ + } + else if (acl_buf[i] == '\n') { + if (i == 0 || acl_buf[i-1] != '\\') + break; /* empty line or normal end of line */ + else { + i -= 2; /* back up over "\\\n" and continue */ + line_incr++; + } + } + } /* Check if we exceeded our buffer size */ - if ((i == BUFSIZ) && (!feof(fp)) && (acl_buf[i] != '\n')) { + if (i == sizeof acl_buf && (i--, !feof(fp))) { + int c1 = acl_buf[i], c2; + krb5_klog_syslog(LOG_ERR, acl_line2long_msg, acl_acl_file, *lnp); - while (fgetc(fp) != '\n'); - i--; + while ((c2 = fgetc(fp)) != EOF) { + if (c2 == '\n') { + if (c1 != '\\') + break; + line_incr++; + } + c1 = c2; + } } - acl_buf[i] = '\0'; + acl_buf[i] = '\0'; if (acl_buf[0] == (char) EOF) /* ptooey */ acl_buf[0] = '\0'; else - (*lnp)++; + line_incr++; if ((acl_buf[0] != '#') && (acl_buf[0] != '\0')) domore = 0; } -- 2.26.2