Task #370
Create Authentication Script
100%
Associated revisions
Added the basic authentication script as well as unit tests. Closes #370.
Added the basic authentication script as well as unit tests. Closes #370.
Updated the authentication script such that it loads conf files even if they have a UTF-8 byte order mark (closes #370)
Updated the authentication script such that it loads conf files even if they have a UTF-8 byte order mark (closes #370)
History
#1 Updated by Luke Murphey almost 13 years ago
- Assignee set to Luke Murphey
#2 Updated by Luke Murphey almost 13 years ago
- Status changed from New to In Progress
#3 Updated by Luke Murphey almost 13 years ago
- Target version set to 1.0.0
#4 Updated by Luke Murphey almost 13 years ago
- Status changed from In Progress to Closed
- % Done changed from 0 to 100
Applied in changeset r4.
#5 Updated by Luke Murphey almost 13 years ago
The current script does not read the conf files created by Splunk because Splunk includes some junk at the top of the file. This can be addressed using the following options:
- Utilize the Splunk conf parsing libraries
- Write my own parsing library
- Chop the the junk off and hand the resulting string to the config parser
- Try a different parser (like http://code.google.com/p/configobj/)
It is possible that the characters I am seeing are the BOM character. Note that bom_aware_readline in ($SPLUNK_HOME/lib/python2.7/site-packages/splunk/clilib/cli_common.py) may be filtering this:
def bom_aware_readline(fileobj):
atstart = (fileobj.tell() == 0)
line = ""
while True:
l = fileobj.readline()
if atstart:
if len(l) > 2 and ord(l[0]) == 239 and ord(l[1]) == 187 and ord(l[2]) == 191:
# UTF-8 BOM detected: skip it over
l = l[3:]
atstart = False
# if line ends with \, append \n, then to the top of the loop to append the next line.
if l.rstrip("\r\n").endswith("\\"):
line += l.rstrip("\r\n")
line += "\n"
else:
line += l
break
return line
#6 Updated by Luke Murphey almost 13 years ago
- Status changed from Closed to In Progress
#7 Updated by Luke Murphey almost 13 years ago
The UTF-8 BOM mark is 0xEF,0xBB,0xBF.
#8 Updated by Luke Murphey almost 13 years ago
Confirmed that the characters I am seeing are the BOM mark. The unit tests indicate the following:
MissingSectionHeaderError: File contains no section headers. file: test_load_bad_conf\default\radius.conf, line: 1 '\xef\xbb\xbf\n'
#9 Updated by Luke Murphey almost 13 years ago
- Status changed from In Progress to Closed
Applied in changeset r18.