{"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":{"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_feature_clip_id":0,"_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},"jetpack_post_was_ever_published":false},"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":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"This is a small script to recursively set permissions on samba sysvol volume\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Javier Bahillo\"\/>\n\t<meta name=\"keywords\" content=\"samba,python,bash,recursive,script,gnu\/linux,zentyal\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.jbahillo.com\/?p=782\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"es_ES\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Javier Bahillo | Blog de un Administrador de Sistemas\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"New script &gt;set sysvol perm | Javier Bahillo\" \/>\n\t\t<meta property=\"og:description\" content=\"This is a small script to recursively set permissions on samba sysvol volume\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.jbahillo.com\/?p=782\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2014-08-29T14:00:08+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2014-08-29T14:04:47+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"New script &gt;set sysvol perm | Javier Bahillo\" \/>\n\t\t<meta name=\"twitter:description\" content=\"This is a small script to recursively set permissions on samba sysvol volume\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/?p=782#article\",\"name\":\"New script >set sysvol perm | Javier Bahillo\",\"headline\":\"New script >set sysvol perm\",\"author\":{\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/?author=21#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/#organization\"},\"datePublished\":\"2014-08-29T15:00:08+01:00\",\"dateModified\":\"2014-08-29T15:04:47+01:00\",\"inLanguage\":\"es-ES\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/?p=782#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/?p=782#webpage\"},\"articleSection\":\"GNU\\\/Linux, Zentyal, bash, python, samba, script\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/?p=782#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.jbahillo.com#listItem\",\"position\":1,\"name\":\"Inicio\",\"item\":\"https:\\\/\\\/www.jbahillo.com\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/?cat=10#listItem\",\"name\":\"GNU\\\/Linux\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/?cat=10#listItem\",\"position\":2,\"name\":\"GNU\\\/Linux\",\"item\":\"https:\\\/\\\/www.jbahillo.com\\\/?cat=10\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/?p=782#listItem\",\"name\":\"New script >set sysvol perm\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.jbahillo.com#listItem\",\"name\":\"Inicio\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/?p=782#listItem\",\"position\":3,\"name\":\"New script >set sysvol perm\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/?cat=10#listItem\",\"name\":\"GNU\\\/Linux\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/#organization\",\"name\":\"Javier Bahillo\",\"description\":\"Blog de un Administrador de Sistemas\",\"url\":\"https:\\\/\\\/www.jbahillo.com\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/?author=21#author\",\"url\":\"https:\\\/\\\/www.jbahillo.com\\\/?author=21\",\"name\":\"Javier Bahillo\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/?p=782#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/23ebe4a43dc73242549ef5e7aeabbb6f292b190480d690968359ac9f5d180474?s=96&r=g\",\"width\":96,\"height\":96,\"caption\":\"Javier Bahillo\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/?p=782#webpage\",\"url\":\"https:\\\/\\\/www.jbahillo.com\\\/?p=782\",\"name\":\"New script >set sysvol perm | Javier Bahillo\",\"description\":\"This is a small script to recursively set permissions on samba sysvol volume\",\"inLanguage\":\"es-ES\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/?p=782#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/?author=21#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/?author=21#author\"},\"datePublished\":\"2014-08-29T15:00:08+01:00\",\"dateModified\":\"2014-08-29T15:04:47+01:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/#website\",\"url\":\"https:\\\/\\\/www.jbahillo.com\\\/\",\"name\":\"Javier Bahillo\",\"description\":\"Blog de un Administrador de Sistemas\",\"inLanguage\":\"es-ES\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.jbahillo.com\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"New script >set sysvol perm | Javier Bahillo","description":"This is a small script to recursively set permissions on samba sysvol volume","canonical_url":"https:\/\/www.jbahillo.com\/?p=782","robots":"max-image-preview:large","keywords":"samba,python,bash,recursive,script,gnu\/linux,zentyal","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.jbahillo.com\/?p=782#article","name":"New script >set sysvol perm | Javier Bahillo","headline":"New script >set sysvol perm","author":{"@id":"https:\/\/www.jbahillo.com\/?author=21#author"},"publisher":{"@id":"https:\/\/www.jbahillo.com\/#organization"},"datePublished":"2014-08-29T15:00:08+01:00","dateModified":"2014-08-29T15:04:47+01:00","inLanguage":"es-ES","mainEntityOfPage":{"@id":"https:\/\/www.jbahillo.com\/?p=782#webpage"},"isPartOf":{"@id":"https:\/\/www.jbahillo.com\/?p=782#webpage"},"articleSection":"GNU\/Linux, Zentyal, bash, python, samba, script"},{"@type":"BreadcrumbList","@id":"https:\/\/www.jbahillo.com\/?p=782#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.jbahillo.com#listItem","position":1,"name":"Inicio","item":"https:\/\/www.jbahillo.com","nextItem":{"@type":"ListItem","@id":"https:\/\/www.jbahillo.com\/?cat=10#listItem","name":"GNU\/Linux"}},{"@type":"ListItem","@id":"https:\/\/www.jbahillo.com\/?cat=10#listItem","position":2,"name":"GNU\/Linux","item":"https:\/\/www.jbahillo.com\/?cat=10","nextItem":{"@type":"ListItem","@id":"https:\/\/www.jbahillo.com\/?p=782#listItem","name":"New script >set sysvol perm"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.jbahillo.com#listItem","name":"Inicio"}},{"@type":"ListItem","@id":"https:\/\/www.jbahillo.com\/?p=782#listItem","position":3,"name":"New script >set sysvol perm","previousItem":{"@type":"ListItem","@id":"https:\/\/www.jbahillo.com\/?cat=10#listItem","name":"GNU\/Linux"}}]},{"@type":"Organization","@id":"https:\/\/www.jbahillo.com\/#organization","name":"Javier Bahillo","description":"Blog de un Administrador de Sistemas","url":"https:\/\/www.jbahillo.com\/"},{"@type":"Person","@id":"https:\/\/www.jbahillo.com\/?author=21#author","url":"https:\/\/www.jbahillo.com\/?author=21","name":"Javier Bahillo","image":{"@type":"ImageObject","@id":"https:\/\/www.jbahillo.com\/?p=782#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/23ebe4a43dc73242549ef5e7aeabbb6f292b190480d690968359ac9f5d180474?s=96&r=g","width":96,"height":96,"caption":"Javier Bahillo"}},{"@type":"WebPage","@id":"https:\/\/www.jbahillo.com\/?p=782#webpage","url":"https:\/\/www.jbahillo.com\/?p=782","name":"New script >set sysvol perm | Javier Bahillo","description":"This is a small script to recursively set permissions on samba sysvol volume","inLanguage":"es-ES","isPartOf":{"@id":"https:\/\/www.jbahillo.com\/#website"},"breadcrumb":{"@id":"https:\/\/www.jbahillo.com\/?p=782#breadcrumblist"},"author":{"@id":"https:\/\/www.jbahillo.com\/?author=21#author"},"creator":{"@id":"https:\/\/www.jbahillo.com\/?author=21#author"},"datePublished":"2014-08-29T15:00:08+01:00","dateModified":"2014-08-29T15:04:47+01:00"},{"@type":"WebSite","@id":"https:\/\/www.jbahillo.com\/#website","url":"https:\/\/www.jbahillo.com\/","name":"Javier Bahillo","description":"Blog de un Administrador de Sistemas","inLanguage":"es-ES","publisher":{"@id":"https:\/\/www.jbahillo.com\/#organization"}}]},"og:locale":"es_ES","og:site_name":"Javier Bahillo | Blog de un Administrador de Sistemas","og:type":"article","og:title":"New script &gt;set sysvol perm | Javier Bahillo","og:description":"This is a small script to recursively set permissions on samba sysvol volume","og:url":"https:\/\/www.jbahillo.com\/?p=782","article:published_time":"2014-08-29T14:00:08+00:00","article:modified_time":"2014-08-29T14:04:47+00:00","twitter:card":"summary","twitter:title":"New script &gt;set sysvol perm | Javier Bahillo","twitter:description":"This is a small script to recursively set permissions on samba sysvol volume"},"aioseo_meta_data":{"post_id":"782","title":"New script &gt;set sysvol perm | #site_title","description":"This is a small script to recursively set permissions on samba sysvol volume","keywords":[{"label":"samba","value":"samba"},{"label":"python","value":"python"},{"label":"bash","value":"bash"},{"label":"recursive","value":"recursive"},{"label":"script","value":"script"}],"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[],"defaultGraph":"","defaultPostTypeGraph":""},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-04-23 00:41:55","updated":"2025-06-03 23:30:25","seo_analyzer_scan_date":null},"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}]}}