{"action":"created","comment":{"url":"https://api.github.com/repos/freenas/iocage/pulls/comments/230038826","pull_request_review_id":170680165,"id":230038826,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMDAzODgyNg==","diff_hunk":"@@ -654,72 +654,68 @@ def check_release_newer(release, callback=None, silent=False):\n             silent=silent)\n \n \n-def construct_devfs(ruleset_name, paths, includes=None, comment=None):\n+def generate_devfs_ruleset(conf, paths=None, includes=None):\n     \"\"\"\n-    ruleset_name: The ruleset without the brackets or a number,\n-        for example 'foo' will be contructed into [foo=IOCAGE_GEN_RULENUM]\n-\n-    Will construct a devfs ruleset from dict(paths), and list(includes) with:\n-        paths dict:\n-            EXAMPLE: \"usbctl\": mode 660 group uucp\n-            - path to unhide: mode (can be None)\n-        includes list:\n-            EXAMPLE [\"$devfsrules_hide_all\", \"$devfsrules_unhide_basic\"]\n-            - [entry, entry]\n-\n-    Returns a tuple containing the string and which devfs_ruleset got assigned.\n-    \"\"\"\n-    includes = [] if includes is None else includes\n-    ct_str = f'## {ruleset_name}' if comment is None else comment\n-    rules = []\n-    ruleset_number = 5  # The system has 4 already claimed.\n-\n-    try:\n-        with open('/etc/devfs.rules', 'r') as f:\n-            exists = False\n+    Will add a per jail devfs ruleset with the specified rules\n \n-            for line in f.readlines():\n-                if line.rstrip() == ct_str:\n-                    exists = True\n-                    continue\n-\n-                if exists:\n-                    return None, int(line.rsplit('=')[1].strip(']\\n'))\n+    Returns the devfs_ruleset number that has been allocated.\n+    \"\"\"\n+    ruleset = 5  # 0-4 is always reserved\n+    devfs_rulesets = su.run(\n+        ['devfs', 'rule', 'showsets'],\n+        stdout=su.PIPE, universal_newlines=True\n+    )\n+    ruleset_list = [int(i) for i in devfs_rulesets.stdout.splitlines()]\n+    devfs_dict = {\n+        'zfs': None\n+    }\n+    devfs_includes = [\n+        '1',  # '$devfsrules_hide_all'\n+        '2',  # '$devfsrules_unhide_basic'\n+        '3',  # '$devfsrules_unhide_login'\n+    ]\n \n-                if line.startswith('['):\n-                    try:\n-                        line = int(line.rsplit('=')[1].strip(']\\n'))\n-                    except IndexError:\n-                        rules.append(line)\n-                    rules.append(line)\n-    except FileNotFoundError:\n-        logit(\n-            {\n-                'level': 'EXCEPTION',\n-                'message':\n-                    '/etc/devfs.rules could not be found, unable to continue.'\n-            }\n+    while ruleset in ruleset_list:\n+        ruleset += 1\n+\n+    ruleset = str(ruleset)\n+    if paths is not None:\n+        devfs_dict.update(paths)\n+\n+    if includes is not None:\n+        devfs_includes += includes\n+\n+    # We may end up setting all of these.\n+    if conf['allow_tun'] == '1':\n+        devfs_dict['tun*'] = None\n+    if conf['dhcp'] == 'on':\n+        devfs_dict['bpf*'] = None\n+\n+    for include in devfs_includes:\n+        # In case a plugin or something tries to use the human readable names\n+        if include == '$devfsrules_hide_all':\n+            include = '1'\n+        elif include == '$devfsrules_unhide_basic':\n+            include = '2'\n+        elif include == '$devfsrules_unhide_login':\n+            include = '3'\n+\n+        su.run(\n+            ['devfs', 'rule', '-s', ruleset, 'add', 'include', include],","path":"iocage_lib/ioc_common.py","position":93,"original_position":93,"commit_id":"a4594bb97d6001e4d4ea1f003229798f459e96dc","original_commit_id":"a4594bb97d6001e4d4ea1f003229798f459e96dc","user":{"login":"william-gr","id":56250,"node_id":"MDQ6VXNlcjU2MjUw","avatar_url":"https://avatars0.githubusercontent.com/u/56250?v=4","gravatar_id":"","url":"https://api.github.com/users/william-gr","html_url":"https://github.com/william-gr","followers_url":"https://api.github.com/users/william-gr/followers","following_url":"https://api.github.com/users/william-gr/following{/other_user}","gists_url":"https://api.github.com/users/william-gr/gists{/gist_id}","starred_url":"https://api.github.com/users/william-gr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/william-gr/subscriptions","organizations_url":"https://api.github.com/users/william-gr/orgs","repos_url":"https://api.github.com/users/william-gr/repos","events_url":"https://api.github.com/users/william-gr/events{/privacy}","received_events_url":"https://api.github.com/users/william-gr/received_events","type":"User","site_admin":false},"body":"Hmm, why do we need to operate on /dev, and not on the devfs insided the jail?","created_at":"2018-11-01T13:18:58Z","updated_at":"2018-11-01T13:19:01Z","html_url":"https://github.com/freenas/iocage/pull/73#discussion_r230038826","pull_request_url":"https://api.github.com/repos/freenas/iocage/pulls/73","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/freenas/iocage/pulls/comments/230038826"},"html":{"href":"https://github.com/freenas/iocage/pull/73#discussion_r230038826"},"pull_request":{"href":"https://api.github.com/repos/freenas/iocage/pulls/73"}}},"pull_request":{"url":"https://api.github.com/repos/freenas/iocage/pulls/73","id":227519224,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI3NTE5MjI0","html_url":"https://github.com/freenas/iocage/pull/73","diff_url":"https://github.com/freenas/iocage/pull/73.diff","patch_url":"https://github.com/freenas/iocage/pull/73.patch","issue_url":"https://api.github.com/repos/freenas/iocage/issues/73","number":73,"state":"open","locked":false,"title":"Rewrite how devfs_rulesets are generated","user":{"login":"skarekrow","id":1589047,"node_id":"MDQ6VXNlcjE1ODkwNDc=","avatar_url":"https://avatars2.githubusercontent.com/u/1589047?v=4","gravatar_id":"","url":"https://api.github.com/users/skarekrow","html_url":"https://github.com/skarekrow","followers_url":"https://api.github.com/users/skarekrow/followers","following_url":"https://api.github.com/users/skarekrow/following{/other_user}","gists_url":"https://api.github.com/users/skarekrow/gists{/gist_id}","starred_url":"https://api.github.com/users/skarekrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skarekrow/subscriptions","organizations_url":"https://api.github.com/users/skarekrow/orgs","repos_url":"https://api.github.com/users/skarekrow/repos","events_url":"https://api.github.com/users/skarekrow/events{/privacy}","received_events_url":"https://api.github.com/users/skarekrow/received_events","type":"User","site_admin":false},"body":"- Simplify plugin devfs ruleset generation\r\n- Rewrite generate_devfs_ruleset\r\n\r\nWe now no longer touch the hosts /etc/devfs.rules, instead we create a dynamic ruleset that we clean up on jail destruction.\r\n\r\nThis ends up fixing some bugs where setting dhcp after setting allow_tun or vice versa would not work.\r\n\r\nIn addition, tuns can now properly be created in the target jail, as before the devfs rules were not being correctly reloaded.\r\n\r\nFreeNAS Ticket: #40872","created_at":"2018-11-01T05:45:27Z","updated_at":"2018-11-01T13:19:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"34d27d87a5888ee48c6d0ed373052696a6abf55f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/freenas/iocage/pulls/73/commits","review_comments_url":"https://api.github.com/repos/freenas/iocage/pulls/73/comments","review_comment_url":"https://api.github.com/repos/freenas/iocage/pulls/comments{/number}","comments_url":"https://api.github.com/repos/freenas/iocage/issues/73/comments","statuses_url":"https://api.github.com/repos/freenas/iocage/statuses/a4594bb97d6001e4d4ea1f003229798f459e96dc","head":{"label":"freenas:FIX-40872","ref":"FIX-40872","sha":"a4594bb97d6001e4d4ea1f003229798f459e96dc","user":{"login":"freenas","id":3792476,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3OTI0NzY=","avatar_url":"https://avatars2.githubusercontent.com/u/3792476?v=4","gravatar_id":"","url":"https://api.github.com/users/freenas","html_url":"https://github.com/freenas","followers_url":"https://api.github.com/users/freenas/followers","following_url":"https://api.github.com/users/freenas/following{/other_user}","gists_url":"https://api.github.com/users/freenas/gists{/gist_id}","starred_url":"https://api.github.com/users/freenas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freenas/subscriptions","organizations_url":"https://api.github.com/users/freenas/orgs","repos_url":"https://api.github.com/users/freenas/repos","events_url":"https://api.github.com/users/freenas/events{/privacy}","received_events_url":"https://api.github.com/users/freenas/received_events","type":"Organization","site_admin":false},"repo":{"id":135636971,"node_id":"MDEwOlJlcG9zaXRvcnkxMzU2MzY5NzE=","name":"iocage","full_name":"freenas/iocage","private":false,"owner":{"login":"freenas","id":3792476,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3OTI0NzY=","avatar_url":"https://avatars2.githubusercontent.com/u/3792476?v=4","gravatar_id":"","url":"https://api.github.com/users/freenas","html_url":"https://github.com/freenas","followers_url":"https://api.github.com/users/freenas/followers","following_url":"https://api.github.com/users/freenas/following{/other_user}","gists_url":"https://api.github.com/users/freenas/gists{/gist_id}","starred_url":"https://api.github.com/users/freenas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freenas/subscriptions","organizations_url":"https://api.github.com/users/freenas/orgs","repos_url":"https://api.github.com/users/freenas/repos","events_url":"https://api.github.com/users/freenas/events{/privacy}","received_events_url":"https://api.github.com/users/freenas/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/freenas/iocage","description":"A FreeBSD jail manager written in Python 3","fork":true,"url":"https://api.github.com/repos/freenas/iocage","forks_url":"https://api.github.com/repos/freenas/iocage/forks","keys_url":"https://api.github.com/repos/freenas/iocage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/freenas/iocage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/freenas/iocage/teams","hooks_url":"https://api.github.com/repos/freenas/iocage/hooks","issue_events_url":"https://api.github.com/repos/freenas/iocage/issues/events{/number}","events_url":"https://api.github.com/repos/freenas/iocage/events","assignees_url":"https://api.github.com/repos/freenas/iocage/assignees{/user}","branches_url":"https://api.github.com/repos/freenas/iocage/branches{/branch}","tags_url":"https://api.github.com/repos/freenas/iocage/tags","blobs_url":"https://api.github.com/repos/freenas/iocage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/freenas/iocage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/freenas/iocage/git/refs{/sha}","trees_url":"https://api.github.com/repos/freenas/iocage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/freenas/iocage/statuses/{sha}","languages_url":"https://api.github.com/repos/freenas/iocage/languages","stargazers_url":"https://api.github.com/repos/freenas/iocage/stargazers","contributors_url":"https://api.github.com/repos/freenas/iocage/contributors","subscribers_url":"https://api.github.com/repos/freenas/iocage/subscribers","subscription_url":"https://api.github.com/repos/freenas/iocage/subscription","commits_url":"https://api.github.com/repos/freenas/iocage/commits{/sha}","git_commits_url":"https://api.github.com/repos/freenas/iocage/git/commits{/sha}","comments_url":"https://api.github.com/repos/freenas/iocage/comments{/number}","issue_comment_url":"https://api.github.com/repos/freenas/iocage/issues/comments{/number}","contents_url":"https://api.github.com/repos/freenas/iocage/contents/{+path}","compare_url":"https://api.github.com/repos/freenas/iocage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/freenas/iocage/merges","archive_url":"https://api.github.com/repos/freenas/iocage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/freenas/iocage/downloads","issues_url":"https://api.github.com/repos/freenas/iocage/issues{/number}","pulls_url":"https://api.github.com/repos/freenas/iocage/pulls{/number}","milestones_url":"https://api.github.com/repos/freenas/iocage/milestones{/number}","notifications_url":"https://api.github.com/repos/freenas/iocage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/freenas/iocage/labels{/name}","releases_url":"https://api.github.com/repos/freenas/iocage/releases{/id}","deployments_url":"https://api.github.com/repos/freenas/iocage/deployments","created_at":"2018-05-31T21:27:33Z","updated_at":"2018-10-26T20:14:21Z","pushed_at":"2018-11-01T05:49:28Z","git_url":"git://github.com/freenas/iocage.git","ssh_url":"git@github.com:freenas/iocage.git","clone_url":"https://github.com/freenas/iocage.git","svn_url":"https://github.com/freenas/iocage","homepage":"","size":3389,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":2,"watchers":2,"default_branch":"master"}},"base":{"label":"freenas:master","ref":"master","sha":"f38873921dcf91e6800609ed4126013391c953b7","user":{"login":"freenas","id":3792476,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3OTI0NzY=","avatar_url":"https://avatars2.githubusercontent.com/u/3792476?v=4","gravatar_id":"","url":"https://api.github.com/users/freenas","html_url":"https://github.com/freenas","followers_url":"https://api.github.com/users/freenas/followers","following_url":"https://api.github.com/users/freenas/following{/other_user}","gists_url":"https://api.github.com/users/freenas/gists{/gist_id}","starred_url":"https://api.github.com/users/freenas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freenas/subscriptions","organizations_url":"https://api.github.com/users/freenas/orgs","repos_url":"https://api.github.com/users/freenas/repos","events_url":"https://api.github.com/users/freenas/events{/privacy}","received_events_url":"https://api.github.com/users/freenas/received_events","type":"Organization","site_admin":false},"repo":{"id":135636971,"node_id":"MDEwOlJlcG9zaXRvcnkxMzU2MzY5NzE=","name":"iocage","full_name":"freenas/iocage","private":false,"owner":{"login":"freenas","id":3792476,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3OTI0NzY=","avatar_url":"https://avatars2.githubusercontent.com/u/3792476?v=4","gravatar_id":"","url":"https://api.github.com/users/freenas","html_url":"https://github.com/freenas","followers_url":"https://api.github.com/users/freenas/followers","following_url":"https://api.github.com/users/freenas/following{/other_user}","gists_url":"https://api.github.com/users/freenas/gists{/gist_id}","starred_url":"https://api.github.com/users/freenas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freenas/subscriptions","organizations_url":"https://api.github.com/users/freenas/orgs","repos_url":"https://api.github.com/users/freenas/repos","events_url":"https://api.github.com/users/freenas/events{/privacy}","received_events_url":"https://api.github.com/users/freenas/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/freenas/iocage","description":"A FreeBSD jail manager written in Python 3","fork":true,"url":"https://api.github.com/repos/freenas/iocage","forks_url":"https://api.github.com/repos/freenas/iocage/forks","keys_url":"https://api.github.com/repos/freenas/iocage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/freenas/iocage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/freenas/iocage/teams","hooks_url":"https://api.github.com/repos/freenas/iocage/hooks","issue_events_url":"https://api.github.com/repos/freenas/iocage/issues/events{/number}","events_url":"https://api.github.com/repos/freenas/iocage/events","assignees_url":"https://api.github.com/repos/freenas/iocage/assignees{/user}","branches_url":"https://api.github.com/repos/freenas/iocage/branches{/branch}","tags_url":"https://api.github.com/repos/freenas/iocage/tags","blobs_url":"https://api.github.com/repos/freenas/iocage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/freenas/iocage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/freenas/iocage/git/refs{/sha}","trees_url":"https://api.github.com/repos/freenas/iocage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/freenas/iocage/statuses/{sha}","languages_url":"https://api.github.com/repos/freenas/iocage/languages","stargazers_url":"https://api.github.com/repos/freenas/iocage/stargazers","contributors_url":"https://api.github.com/repos/freenas/iocage/contributors","subscribers_url":"https://api.github.com/repos/freenas/iocage/subscribers","subscription_url":"https://api.github.com/repos/freenas/iocage/subscription","commits_url":"https://api.github.com/repos/freenas/iocage/commits{/sha}","git_commits_url":"https://api.github.com/repos/freenas/iocage/git/commits{/sha}","comments_url":"https://api.github.com/repos/freenas/iocage/comments{/number}","issue_comment_url":"https://api.github.com/repos/freenas/iocage/issues/comments{/number}","contents_url":"https://api.github.com/repos/freenas/iocage/contents/{+path}","compare_url":"https://api.github.com/repos/freenas/iocage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/freenas/iocage/merges","archive_url":"https://api.github.com/repos/freenas/iocage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/freenas/iocage/downloads","issues_url":"https://api.github.com/repos/freenas/iocage/issues{/number}","pulls_url":"https://api.github.com/repos/freenas/iocage/pulls{/number}","milestones_url":"https://api.github.com/repos/freenas/iocage/milestones{/number}","notifications_url":"https://api.github.com/repos/freenas/iocage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/freenas/iocage/labels{/name}","releases_url":"https://api.github.com/repos/freenas/iocage/releases{/id}","deployments_url":"https://api.github.com/repos/freenas/iocage/deployments","created_at":"2018-05-31T21:27:33Z","updated_at":"2018-10-26T20:14:21Z","pushed_at":"2018-11-01T05:49:28Z","git_url":"git://github.com/freenas/iocage.git","ssh_url":"git@github.com:freenas/iocage.git","clone_url":"https://github.com/freenas/iocage.git","svn_url":"https://github.com/freenas/iocage","homepage":"","size":3389,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":2,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/freenas/iocage/pulls/73"},"html":{"href":"https://github.com/freenas/iocage/pull/73"},"issue":{"href":"https://api.github.com/repos/freenas/iocage/issues/73"},"comments":{"href":"https://api.github.com/repos/freenas/iocage/issues/73/comments"},"review_comments":{"href":"https://api.github.com/repos/freenas/iocage/pulls/73/comments"},"review_comment":{"href":"https://api.github.com/repos/freenas/iocage/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/freenas/iocage/pulls/73/commits"},"statuses":{"href":"https://api.github.com/repos/freenas/iocage/statuses/a4594bb97d6001e4d4ea1f003229798f459e96dc"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"william-gr"}}