{"id":58,"date":"2014-10-24T11:40:07","date_gmt":"2014-10-24T11:40:07","guid":{"rendered":"https:\/\/www.spotonoracle.com\/?p=58"},"modified":"2016-05-10T11:43:23","modified_gmt":"2016-05-10T11:43:23","slug":"scripting-mkstore","status":"publish","type":"post","link":"https:\/\/www.spotonoracle.com\/?p=58","title":{"rendered":"Scripting mkstore"},"content":{"rendered":"<p>I had the pleasure to load a wallet (secure external password store) with around 180 credentials. Faced with a repeating task, I always try to automate things as much as possible or at least to the level I deem sensible. In this case my urge not to waste an afternoon typing in the same stuff over and over was overwhelming.<br \/>\nUnfortunately, the &#8220;mkstore&#8221; utility does not have a command switch to provide the wallet password. No problem, on Linux\/Unix I would have just piped in the wallet password:<\/p>\n<pre class=\"brush: sql; collapse: false; title: ; wrap-lines: false; notranslate\" title=\"\">\r\necho MyWallet-Password | mkstore -wrl \/u01\/app\/oracle\/etc\/wallet\/auth -createCredential DEV1.localdomain SYSTEM manager\r\n<\/pre>\n<p>Working on Windows using batch scripts piping does not work with &#8220;mkstore&#8221;. Here&#8217;s what I came up with:<\/p>\n<pre class=\"brush: sql; collapse: false; title: ; wrap-lines: false; notranslate\" title=\"\">\r\necho | set \/p=&quot;MyWallet-Password&quot; &gt; C:\\Temp\\walletpwd.txt\r\n\r\nmkstore -wrl D:\\app\\oracle\\etc\\wallet\\auth -createCredential DEV1.localdomain SYSTEM manager &lt; C:\\Temp\\walletpwd.txt\r\n...\r\n...\r\n...\r\n<\/pre>\n<p>Since we were generating new passwords the service account on all databases I went over the Enterprise Manager repository to generate the &#8220;mkstore&#8221; calls:<\/p>\n<pre class=\"brush: sql; collapse: false; title: ; wrap-lines: false; notranslate\" title=\"\">\r\nselect\r\n     'mkstore -wrl &quot;D:\\app\\oracle\\etc\\wallet\\auth&quot; -createCredential '\r\n  || tgt.target_name\r\n  || ' srvacc &quot;'\r\n  || gen_pwd\r\n  || '&quot; &lt; C:\\Temp\\walletpwd.txt'\r\nfrom sysman.mgmt_targets tgt\r\n  join sysman.mgmt_target_properties tgsid on (tgsid.target_guid = tgt.target_guid)\r\nwhere tgt.target_type = 'oracle_database'\r\nand tgsid.property_name = 'SID'\r\norder by tgsid.property_value\r\n;\r\n<\/pre>\n<p>Now I could just copy &#038; paste the query output into a command line window. DONE.<\/p>\n<p>Please remember to delete the temporary file containing the wallet password:<\/p>\n<pre class=\"brush: sql; collapse: false; title: ; wrap-lines: false; notranslate\" title=\"\">\r\ndel \/F \/S \/Q C:\\Temp\\walletpwd.txt\r\n<\/pre>\n<p>Although it saved me a lot of typing I&#8217;m not quite happy with the solution. The reason is I do temporarily write the wallet password to a file in plain text. I do not like that at all. And in some environments this might be considered a security breach, even if the file is only there for a couple of minutes.<\/p>\n<p>If you come up with a solution that works without storing the wallet password in a file to redirect it to STDIN I&#8217;ll be happy to know about.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had the pleasure to load a wallet (secure external password store) with around 180 credentials. Faced with a repeating task, I always try to automate things as much as possible or at least to the level I deem sensible. In this case my urge not to waste an afternoon typing in the same stuff [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-58","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/posts\/58","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=58"}],"version-history":[{"count":2,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/posts\/58\/revisions"}],"predecessor-version":[{"id":60,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/posts\/58\/revisions\/60"}],"wp:attachment":[{"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}