- dbg("%s:%d:%d: parse error, rule skipped",
- filename, lineno, temp - line);
- }
- }
-exit:
- fclose(fd);
- return retval;
-}
-
-static int namedev_parse_permissions(char *filename)
-{
- char line[255];
- char *temp;
- char *temp2;
- FILE *fd;
- int retval = 0;
- struct perm_device dev;
-
- fd = fopen(filename, "r");
- if (fd != NULL) {
- dbg("reading '%s' as permissions file", filename);
- } else {
- dbg("can't open '%s' as permissions file", filename);
- return -ENODEV;
- }
-
- /* loop through the whole file */
- while (1) {
- temp = fgets(line, sizeof(line), fd);
- if (temp == NULL)
- break;
-
- dbg_parse("read '%s'", temp);
-
- /* eat the whitespace at the beginning of the line */
- while (isspace(*temp))
- ++temp;
-
- /* empty line? */
- if ((*temp == '\0') || (*temp == '\n'))
- continue;
-
- /* see if this is a comment */
- if (*temp == COMMENT_CHARACTER)
- continue;
-
- memset(&dev, 0x00, sizeof(dev));
-
- /* parse the 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;