- /* loop through the whole file */
- cur = 0;
- lineno = 0;
- while (cur < bufsize) {
- count = buf_get_line(buf, bufsize, cur);
- bufline = &buf[cur];
- cur += count+1;
- lineno++;
-
- if (count >= LINE_SIZE) {
- info("line too long, rule skipped %s, line %d",
- filename, lineno);
- continue;
- }
-
- /* eat the whitespace */
- while ((count > 0) && isspace(bufline[0])) {
- bufline++;
- count--;
- }
- if (count == 0)
- continue;
-
- /* see if this is a comment */
- if (bufline[0] == COMMENT_CHARACTER)
- continue;
-
- strncpy(line, bufline, count);
- line[count] = '\0';
- dbg_parse("read '%s'", line);
-
- /* parse the line */
- memset(&dev, 0x00, sizeof(struct perm_device));
- temp = line;
-
- temp2 = strsep(&temp, ":");
- if (!temp2) {
- dbg("cannot parse line '%s'", line);
- continue;
- }
- strfieldcpy(dev.name, temp2);
-
- temp2 = strsep(&temp, ":");
- if (!temp2) {
- dbg("cannot parse line '%s'", line);
- continue;
- }
- strfieldcpy(dev.owner, temp2);
-
- temp2 = strsep(&temp, ":");
- if (!temp2) {
- dbg("cannot parse line '%s'", line);
- continue;
- }
- strfieldcpy(dev.group, temp2);
-
- if (!temp) {
- dbg("cannot parse line '%s'", line);
- continue;
- }
- dev.mode = strtol(temp, NULL, 8);
-
- dbg_parse("name='%s', owner='%s', group='%s', mode=%#o",
- dev.name, dev.owner, dev.group, dev.mode);
-
- retval = add_perm_dev(&dev);
- if (retval) {
- dbg("add_perm_dev returned with error %d", retval);
- goto exit;
- }
- }