{"id":782,"date":"2014-08-29T15:00:08","date_gmt":"2014-08-29T14:00:08","guid":{"rendered":"http:\/\/www.jbahillo.com\/?p=782"},"modified":"2014-08-29T15:04:47","modified_gmt":"2014-08-29T14:04:47","slug":"new-script-set-sysvol-perm","status":"publish","type":"post","link":"https:\/\/www.jbahillo.com\/?p=782","title":{"rendered":"New script >set sysvol perm"},"content":{"rendered":"<p>Today I have had to deal with an environment where I had to fix a lot of sysvol permissions, with a lot of different policies with different permissions.<\/p>\n<p>I had begun doing it by hand using samba-tool ntacl set sddl-ACL patg, but I soon realized this was a nightmare . Thus I invested some time in creating a small script on python that at least did part of this for me:<\/p>\n<pre class=\"brush: python; gutter: true\">import os\r\nimport sys\r\narg = sys.argv[1]\r\ncommand = &quot;samba-tool ntacl set &quot;\r\nwp = os.getcwd()\r\nfor dirname, dirnames, filenames in os.walk(wp):\r\n os.system(command + &quot;\\&quot;&quot; + arg + &quot;\\&quot; &quot; + &quot;\\&quot;&quot; + dirname + &quot;\\&quot;&quot;)\r\n files = [f for f in os.listdir(dirname) if os.path.isfile(os.path.join(dirname,f))]\r\n    for f in files:\r\n os.system(command + &quot;\\&quot;&quot; + arg + &quot;\\&quot; &quot; + &quot;\\&quot;&quot; + dirname + &quot;\/&quot; + f + &quot;\\&quot;&quot;)\r\n<\/pre>\n<p>With this at least I had to do it once per policy. Once done, I just created a bash script that got the path and the sddl from samba-tool ntacl sysvolcheck (and run the script above until this command were ok:<\/p>\n<pre class=\"brush: bash; gutter: true\">#!\/bin\/bash\r\nuntil samba-tool ntacl sysvolcheck 2&gt;\/dev\/null\r\ndo\r\n\r\nDIR=$(samba-tool ntacl sysvolcheck 2&gt;&amp;1 | grep ERROR | cut -d&quot; &quot; -f12)\r\nPERM=$(samba-tool ntacl sysvolcheck 2&gt;&amp;1 | grep ERROR | cut -d&quot; &quot; -f19)\r\n\r\n\r\ncd &quot;$DIR&quot;\r\n\r\npython script.py $PERM\r\ndone\r\n<\/pre>\n<p>Hope this is useful if you were looking for this. <\/p>\n<p>P.S. You can find the code in <a href=\"https:\/\/github.com\/jbahillo\/xavy\"> my github<\/a> under GPLv2 as ever<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I have had to deal with an environment where I had to fix a lot of sysvol permissions, with a lot of different policies with different permissions. I had begun doing it by hand using samba-tool ntacl set sddl-ACL&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/www.jbahillo.com\/?p=782\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":21,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"ep_exclude_from_search":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[10,96],"tags":[72,129,99,73],"class_list":["post-782","post","type-post","status-publish","format-standard","hentry","category-gnulinux","category-zentyal","tag-bash","tag-python","tag-samba","tag-script"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p74T96-cC","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=\/wp\/v2\/posts\/782","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=782"}],"version-history":[{"count":3,"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=\/wp\/v2\/posts\/782\/revisions"}],"predecessor-version":[{"id":785,"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=\/wp\/v2\/posts\/782\/revisions\/785"}],"wp:attachment":[{"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=782"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}