summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2000-02-26 03:44:56 +0000
committerKen Raeburn <raeburn@mit.edu>2000-02-26 03:44:56 +0000
commit7e3f5c09f57b2a12165dd6ff8aeda5aa1ccdae2a (patch)
treea3c6c4451f5390cfe99ab3c708b2cc53ac9543d0 /src/lib
parent119f6303edd683d6f20d04deaa6e25d5940434bd (diff)
* 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
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/kadm5/srv/ChangeLog5
-rw-r--r--src/lib/kadm5/srv/server_acl.c48
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 <raeburn@mit.edu>
+
+ * 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 <tlyu@mit.edu>
* 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<BUFSIZ) &&
- (!feof(fp)) &&
- ((acl_buf[i] = fgetc(fp)) != '\n'));
- i++);
-
+ /* Copy in the line, with continuations */
+ for (i=0; ((i < sizeof acl_buf) && !feof(fp)); i++ ) {
+ acl_buf[i] = fgetc(fp);
+ if (acl_buf[i] == (char)EOF) {
+ if (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;
}