Nickelblog
https://blog.ncbt.org/
Slaying the Technology DragonMon, 17 Oct 2022 15:03:13 GMTen-usoldSchool v0.7.21http://cyber.law.harvard.edu/rss/rss.htmlFri, 03 Feb 2023 15:51:40 GMTcroldhamFri, February 3, 2023 10:51 AM ESTFixing a WiFi (actually DHCP) issue on my Mac<p>In general over the years, my Macs have <em>just worked</em>. I've seen none of the weird behavior with them that I have with Windows. However last week I encountered something new.</p>
<p>On startup or login, I would see the WiFi indicator pulse as it tried to get an IP address from my local DHCP server. After the requisite 30 seconds it would give up and the WiFi icon would get the <strong>!</strong> overlay indicating it had self-assigned an IP from the 169 range. All the other devices in my house had no trouble getting an IP address. If I tethered my Mac to my iPhone or iPad, it would pull an IP without any trouble. Furthermore, I also have a wired ethernet adapter on this machine and it could not get an IP either. If I assigned an IP manually to either device, network traffic would flow normally, so I knew that the WiFi was successfully associating to the AP and the wired ethernet was passing traffic as well.</p>
<p>I first suspected my network, but all the other devices didn't have any trouble. Logs for my DHCP server showed DHCPREQUEST from the Mac and DHCPOFFER from the DHCP server, but no DHCPACKs.</p>
<p>I tried the following:</p>
<ul>
<li>Removing the WiFi network entry from the list of known SSIDs and re-associating the Mac with the SSID (required re-entering the WiFi password)</li>
<li>Manually assigning an IP address to the WiFi's MAC address in my DHCP server.</li>
<li>Creating a new "Network Location" in the Network control panel.</li>
<li>Restarting the machine, as well as powering off the machine fully and doing a cold boot.</li>
<li>Manually removing the IP address leases for my Mac from the lease database on my DHCP server.</li>
</ul>
<p>I did not try turning off the macOS Firewall, as this is a machine managed by my work, and they have that setting locked.</p>
<p>What did finally work was to create a new administrator account and login to that account. At that point both the wireless and wired devices could pull an IP over DHCP. DHCP continued to work after restarting and logging into my original account.</p>
<p>My guess is one or more of the files macOS uses to keep track of network status had become corrupted such that the Mac would never accept a DHCP offered IP, but only for my network (which is in the 172 block). I wish I knew where those files were, as there doesn't seem to be an easier way for them to get rewritten.</p>
Mon, 17 Oct 2022 15:03:13 GMT
https://blog.ncbt.org/2022/10/17/150313.html?title=fixingAWifiActuallyDhcpIssueOnMyMac
https://blog.ncbt.org/2022/10/17/150313.html?title=fixingAWifiActuallyDhcpIssueOnMyMacDo the Cool Kids Still Say <em>Fly</em>?<p>I built and maintained a Django website for our homeschool co-op for years. Started out on a $10/month VPS somewhere (I can't even remember where), and bounced it around to different providers, then to <a href="https://cloud.google.com/kubernetes-engine">GKE</a>, and finally to <a href="https://www.digitalocean.com/products/kubernetes">Digital Ocean Managed Kubernetes</a>. DO's Kubernetes was super-stable, after I set it up I basically never had to touch it, and it ran well for over 2 years. All our kids are graduated now, so the co-op decided they wanted to use a different solution. I took this as an opportunity to move my hosted stuff out of DO and try out Fly.io.</p>
<p>I listen to a lot of Elixir podcasts and <a href="https://podcast.thinkingelixir.com/">Fly supports one of them directly</a>. I have to say it is a breath of fresh air after wrestling with k8s. I need k8s at my job, so I use it there every day. Having to use it for personal stuff, when I just want to throw a PoC up on the Internet, just adds friction.</p>
<p>Their free tier is quite generous. For my Elixir apps (including <a href="https://blog.ncbt.org/2022/02/22.html#a173940">HiHat</a>, which is probably how you are reading this post), the old blog I keep running from my <a href="http://abbysjourney.net">daughter's cancer journey</a>, and an HA-enabled (replicated) Pg instance, I'm still in the "free" zone. Though I would gladly pay them money and eventually probably will.</p>
<p>So here's a solid 👍 for <a href="https://fly.io">Fly.io</a>.</p>
<p><font size="-1"><em>(image credit <a href="https://www.pexels.com/@rakicevic-nenad-233369/">Rakicevic Nenad</a> on <a href="https://www.pexels.com/">Pexels</a>)</em></font></p>
Tue, 12 Jul 2022 22:43:54 GMT
https://blog.ncbt.org/2022/07/12/224354.html?title=doTheCoolKidsStillSayFly
https://blog.ncbt.org/2022/07/12/224354.html?title=doTheCoolKidsStillSayFlyHiHat<p>I've moved the personalized domain name functionality off <a href="https://aws.amazon.com/cloudfront/">CloudFront</a> and to a custom server I've written in Elixir and Python. The working name for this is "HiHat" (get it? ba-dum-tss 🥁🤣). I want to turn this into a turnkey solution that can be deployed at the free tier on any of the modern PaaS platforms (<a href="https://render.com/">Render.com</a>, <a href="https://www.heroku.com/">Heroku</a>, <a href="https://gigalixir.com">Gigalixir</a>, <a href="https://fly.io">fly.io</a>) so folks can just deploy it and get a custom domain with SSL that fronts their Drummer blog. It has too many rough edges at the moment to make public.</p>
Tue, 22 Feb 2022 17:39:40 GMT
https://blog.ncbt.org/2022/02/22/173940.html?title=hihat
https://blog.ncbt.org/2022/02/22/173940.html?title=hihat<img class="imgRightMargin" src="http://scripting.com/images/2021/05/31/drumset.png" border="0" style="float: right; padding-left: 25px; padding-bottom: 10px; padding-top: 10px; padding-right: 15px;">A Drummer BlogTue, 18 Jan 2022 00:20:45 GMT
https://blog.ncbt.org/2022/01/17.html#a002045
https://blog.ncbt.org/2022/01/17.html#a002045I've followed <a href="http://scripting.com/">Dave Winer</a>'s work for a long time. He is a true pioneer, not just in the area of software development, but the Internet as a whole. I'm going to blog via his outline tool called <a href="http://docserver.scripting.com/drummer/about.opml">Drummer</a> for a while. This is why some of my posts below have unusual dates, I ran into a few quirks with backdating posts.Tue, 18 Jan 2022 00:30:46 GMT
https://blog.ncbt.org/2022/01/17.html#a003046
https://blog.ncbt.org/2022/01/17.html#a003046The personalized domain name is being handled by <a href="https://aws.amazon.com/cloudfront/">CloudFront</a>. Thanks to Dave, Ken Booth, and their <a href="http://www.dailymiscellany.com/2021/11/29/153122.html?title=usingCloudfrontToSetUpCustomDomainForDrummer">two</a> <a href="https://github.com/scripting/drummerSupport/issues/67">posts</a> that documented the setup.Tue, 18 Jan 2022 00:44:29 GMT
https://blog.ncbt.org/2022/01/17.html#a004429
https://blog.ncbt.org/2022/01/17.html#a004429Flashing the QNAP QNA-UC5G1T on a Mac<p>Note that since I managed to brick one adapter trying to do this I disclaim responsibility if you, dear reader, try it and fail. On the other hand, I searched the Internet high and low for anyone else that was successful flashing these adapters without a physical Windows machine. Finding nothing, it seemed wise to write up my success.</p>
<p>TL;DR</p>
<ul>
<li>1. Start Fusion 12 and a Windows 10 VM.</li>
<li>2. Download the drivers for the adapter and the updated firmware onto the Windows VM. </li>
<li>3. Install the drivers for the adapter in Windows before plugging it in.</li>
<li>4. Plug in the adapter. MacOS will claim it. </li>
<li>5. Unload the driver and the ECM kext bundle from a Terminal prompt:</li>
<li><code>sudo kextunload /System/Library/DriverExtensions/AppleUserECM.dext<br>sudo kextunload -v -c com.apple.driver.usb.cdc.ecm</code></li>
<li>6. Finally, attach the adapter to the VM with the <code>Virtual Machine->Bluetooth and USB</code> menu option in Fusion. Run the autorun.bat file as an Administrator and it should flash successfully.</li>
</ul>
<p>The long story.</p>
<p>I am in the process of reconstructing my home lab and have several NUC-form-factor machines that don’t have any free PCIe slots, but do have USB 3.1. As I just upgraded to a Mikrotik 10 GbE switch, I would like to have faster than 1 Gb ethernet to them, so I purchased 4 <a href="https://www.qnap.com/en-us/product/qna-uc5g1t">QNA-UC5G1T adapters</a>. William Lam’s excellent website <a href="https://williamlam.com/2019/09/usb-native-driver-fling-for-esxi-adds-support-for-multi-gig-1g-2-5g-5g-adapter.html">had an article on them</a> indicating they should have their firmware flashed to 3.1.6 (available <a href="https://www.qnap.com/en-us/download?model=qna-uc5g1t&category=firmware">here</a>) to get the best performance. Unfortunately the flash utility only works under Windows.</p>
<p>My first attempt at flashing the adapter under VMware Fusion 11 was a failure. I bricked the device, and QNAP was kind enough to RMA it for me and send me a new one.</p>
<p>I’ve since upgraded to Fusion 12. Starting my Windows 10 VM, I plugged the adapter in and told Fusion to attach it to the VM instead of the Mac. I was greeted with a message indicating the host machine had already claimed the device.</p>
<p><div class="divInlineImage"><center><img class="imgInline" src="https://croldham-drummer.s3.amazonaws.com/screen-shot-2020-11-06-at-9.22.06-pm.png"></center>Helpful Dialog</div></p>
<p>I found the device in the Network PrefPane and removed it, but that did not help. I realized I would have to go a little deeper.</p>
<p>MacOS’s System Information tool showed me that the driver being used for the adapter was /System/Library/DriverExtensions/AppleUserECM.dext. I unloaded this kext from the terminal</p>
<ul>
<li><code>sudo kextunload com.apple.driver.usb.cdc.ecm</code></li>
</ul>
<p>and also unloaded the ECM bundle</p>
<ul>
<li><code>sudo kextunload /System/Library/DriverExtensions/AppleUserECM.dext</code></li>
</ul>
<p>At that point I was able to attach the adapter to the Fusion VM. Following the instructions in the firmware zip file, I successfully flashed the adapter.</p>
<p><div class="divInlineImage"><center><img class="imgInline" src="https://croldham-drummer.s3.amazonaws.com/screen-shot-2020-11-06-at-9.01.46-pm.png"></center>Success!</div></p>
Sun, 16 Jan 2022 00:28:07 GMT
https://blog.ncbt.org/2022/01/15/002807.html?title=flashingTheQnapQnauc5g1tOnAMac
https://blog.ncbt.org/2022/01/15/002807.html?title=flashingTheQnapQnauc5g1tOnAMac<a href="https://keyboard.io">Keyboard.io's Atreus</a><p>There’s something about computer keyboards…even in this age of tablets and phones they remain the primary way we get significant amounts of text and code into computers. I’ve spent time with the original <a href="https://en.wikipedia.org/wiki/Buckling_spring">IBM Model M “buckling spring”</a>, the first generation <a href="https://en.wikipedia.org/wiki/Kinesis_(keyboard)">Kinesis Advantage</a>, ThinkPad keyboards (still one of the absolute best laptop keyboards ever), the abysmal Dell Latitude d610 (stiff as a board, required significant force just to press the keys), the Apple Extended Keyboard, various MacBook Pro keyboards, as well as lots of terrible rubber-dome and membrane keyboards.</p>
<p>I’m in the minority in that I actually like the 3rd generation butterfly keyboard on the 2019 and later MacBook Pros. I like its tactile feel and the short travel of the keys.</p>
<p>When I started at SaltStack I was introduced to the mechanical keyboard community by some co-workers. Some of the above might qualify as “mechanical” keyboards, but I had no idea that there was such a <a href="https://deskthority.net/">cult</a> <a href="https://geekhack.org/">surrounding</a> <a href="https://www.reddit.com/r/MechanicalKeyboards/">them</a>.</p>
<p>I was intrigued by the <a href="https://ergodox.io/">ErgoDox</a> and participated in the MassDrop for the unassembled keyboard, bought a soldering iron, and like a <a href="https://www.cbr.com/star-wars-how-are-lightsabers-made/">Jedi padawan</a>, I constructed my own keyboard. I used it for about 8 or 9 months, and sold it in favor of a <a href="https://www.amazon.com/Filco-Majestouch-2-Tenkeyless-FKBN87M-EB2/dp/B004WOF7QM/ref=psdc_12879431_t2_B004VKUSG6">Filco Majestouch 2</a> with Cherry MX Brown switches. That was a great keyboard, and I still have it.</p>
<p>When the <a href="https://keyboard.io">Keyboard.io</a> folks initiated their Kickstarter for the <a href="https://shop.keyboard.io/products/model-01-keyboard?variant=30996744405065">Model 01</a>, I was completely hooked. I ended up getting two of those (one for work, one for home). The learning curve was surprisingly steep, but I grew to really appreciate the palm buttons.</p>
<p>Through a fortunate happenstance another co-worker participated in the kickstarter for Keyboard.io’s latest creation, the <a href="https://shop.keyboard.io/collections/keyboardio-atreus/products/keyboardio-atreus">Atreus</a>. He had irreconcilable differences with it, and was willing to sell it to me. I’ve spent the last few days with it, tweaking the layout and getting used to it, and I think it might be the best keyboard I have ever owned.</p>
<p>This unit came with Kailh BOX Brown switches (<a href="https://www.keyboardco.com/blog/index.php/2017/11/an-introduction-to-kailh-switches-including-speed-box/">here’s a comparison article on Kailh switches</a>), <br>QNAP QNA-UC5G1T on a Macthese are tactile but non-clicky like CherryMX Brown switches, which I had on my Majestouch and ErgoDox. I like these much more, however. They seem “tighter” somehow, there’s no discernible wiggle in the keycaps. Actuation force is slightly less than my other keyboards. My typing speed on the alpha characters actually increased over my Model 01.</p>
<p>I had been eyeing the Atreus for a while but was highly concerned that I would not be able to get used to the lack of a number row at the top of the keyboard. Losing real function and Escape keys to the Apple TouchBar has been a sore spot. I took a closer look at the layout and realized there were plenty of keys available to use for layer shifting.Paradoxically I’ve noticed that fewer keys enables more accuracy for me. I think it’s because the keyboard is so small my fingers don’t get “lost” as easily.</p>
<p>It will take a while to get used to my custom layout. I include an image below for anyone who finds this article and is curious about how others have setup their Atreus.</p>
<p><div class="divInlineImage"><center><img class="imgInline" src="https://croldham-drummer.s3.amazonaws.com/screen-shot-2020-10-09-at-7.49.26-pm.png"></center>Layer Map</div></p>
<p>The above is from <a href="https://docs.google.com/spreadsheets/d/1_d-ymDszaH8G2PaNho7XyRnFGL-c4ibGB2b79jyoeU4/edit?usp=sharing">this Google Sheet</a>. Feel free to copy if you want to make your own layout. Many thanks to Github user <a href="https://github.com/mattmc3">mattmc3</a> who created that sheet and posted it in <a href="https://github.com/keyboardio/Kaleidoscope/pull/706#issuecomment-628370192">this PR discussion</a> on adding Atreus layouts that are similar to the Model 01’s.</p>
Sun, 16 Jan 2022 00:15:51 GMT
https://blog.ncbt.org/2022/01/15/001551.html?title=keyboardiosAtreus
https://blog.ncbt.org/2022/01/15/001551.html?title=keyboardiosAtreusBeware Amazon Teen Logins<p>If you pay for the privilege of Amazon Prime, Amazon has a new feature they have quietly rolled out that changes the way your family members interact with your Prime Membership.</p>
<p>The tl;dr is that if you are grandfathered into the older method of family management that enabled you to share your Prime benefits with three adults, do not touch your Prime settings. If you change anything you will be migrated to the new Households features and you will not be able to go back.</p>
<p>I’m not sure who at Amazon designed the new Teen Logins feature, but it is a wreck. If you read the basic information on the Teen Logins Parent’s Page it sounds like a great deal, seeming similar to the way Family Sharing works with Apple’s iOS ecosystem. Teens can pay with a parent’s card, and the parent gets a notification to approve or deny the request. They get Prime shipping benefits, and parents can restrict where a teen can ship. Teens can “Shop, stream and explore Amazon from your own login.” But here’s what the page does NOT say:</p>
<p><ol><li>Teens can only access their Teen Login account from the Amazon App on a smartphone.</li><li>If a teen already has an Amazon login, to link their existing account to a Teen Login account, the existing login cannot have any payment methods, nor any digital content.</li><li>They cannot stream digital video to anything other than a smartphone.</li><li>Teen Logins cannot access shared family content.</li></ol></p>
<p>So for those of us that already had accounts for our kids and had other safeguards in place to protect them, we basically cannot move themto the new Teen Logins feature and at least one member of our family loses access to Prime Shipping.</p>
<p>I was on Chat with Amazon representatives for 45+ minutes this morning. I only found out about these limitations from them, I could notfind anything on the Amazon site about it. And the 5 representatives I talked to were either unable or unwilling to switch my account back to the way it was before. They were, however, perfectly willing to suggest that I spend an additional $59.50 per year for the “Prime Student” membership for one of my kids.</p>
<p>I know that people abuse the Prime Membership features, but ironically I was trying to do the right thing when I started this process — I was in the process of removing my oldest from our Amazon account because he was moving out.</p>
<p>My recommendation to Amazon would be to scrap the Teen Login program altogether and switch to simply allowing up to 5 or 6 household members to share a Prime subscription. Maybe only allow the first two members to ship to any address, and the remaining ones to only ship to the address. Or, at the very least, remove the draconian restrictions on the Teen program (can’t use a web browser? WHA?!?).</p>
<p>Amazon Teen Logins. Just say “no”.</p>
Sat, 15 Jan 2022 23:41:31 GMT
https://blog.ncbt.org/2022/01/15/234131.html?title=bewareAmazonTeenLogins
https://blog.ncbt.org/2022/01/15/234131.html?title=bewareAmazonTeenLoginsWas This Information Helpful?<p>After helping a friend troubleshoot issues stemming from the difference between Microsoft’s MSI and Click-to-Run installers, I am now convinced that all knowledge base articles that ask for feedback need an additional checkbox.</p>
<p><div class="divInlineImage"><center><img class="imgInline" src="http://croldham-drummer.s3.amazonaws.com/info-helpful.png"></center>(additional checkbox anyone?)</div></p>
<p>(Background, friend had legal Office 2013 license installed via MSI. Bought Project as a downloadable online. Project uses Click-to-Run installer. This article says that MSI and CTR versions cannot co-exist, and to fix the problem he needs to uninstall Office.)</p>
<p>No wonder Google Docs is taking over the world.</p>
Thu, 03 Mar 2016 23:57:00 GMT
https://blog.ncbt.org/2016/03/03/060300.html?title=wasThisInformationHelpful
https://blog.ncbt.org/2016/03/03/060300.html?title=wasThisInformationHelpfulMitigating GHOST with Salt<p>Using SaltStack to recover from CVE-2015–0235 (Qualys Security Advisory, GHOST: glibc gethostbyname buffer overflow)</p>
<p>Most of us sysadmin types were pounded with this announcement this morning. The GHOST vulnerability is worth patching against—most Linux distros have already released patches—but it’s useful to know if your machines are vulnerable, or if after patching, the patch was successful.</p>
<p>The canonical way to test for the vulnerability is with a short C program:</p>
<ul>
<li>/* ghost.c */</li>
<li>/* Code taken from CVE announcement */</li>
<li>/* See http://www.openwall.com/lists/oss-security/2015/01/27/9 */</li>
<li>#include <netdb.h></li>
<li>#include <stdio.h></li>
<li>#include <stdlib.h></li>
<li>#include <string.h></li>
<li>#include <errno.h></li>
<li>#define CANARY "in_the_coal_mine"</li>
<li>struct </li>
<li>} temp = { </li>
<ul>
<li>"buffer", CANARY</li>
</ul>
<li> };</li>
<li>int main(void) {</li>
<ul>
<li> struct hostent resbuf;</li>
<li> struct hostent *result;</li>
<li> int herrno;</li>
<li> int retval;</li>
<li> /*** strlen (name) = size_needed - sizeof (*host_addr) - sizeof (*h_addr_ptrs) - 1; ***/</li>
<li> size_t len = sizeof(temp.buffer) - 16*sizeof(unsigned char) - 2*sizeof(char *) - 1;</li>
<li> char name[sizeof(temp.buffer)];</li>
<li> memset(name, '0', len);</li>
<li> name[len] = '\0';</li>
<li> retval = gethostbyname_r(name, &resbuf, temp.buffer,sizeof(temp.buffer), &result, &herrno);</li>
<li> if (strcmp(temp.canary, CANARY) != 0) {</li>
<ul>
<li> puts("vulnerable");</li>
<li> exit(EXIT_FAILURE);</li>
</ul>
<li> }</li>
<li> if (retval == ERANGE) {</li>
<ul>
<li> puts("not vulnerable");</li>
<li> exit(EXIT_SUCCESS);</li>
<li> }</li>
</ul>
<li> puts("test aborted: should not happen");</li>
<li> exit(EXIT_FAILURE);</li>
</ul>
<li>}</li>
</ul>
<p>Which can then be saved to a file “ghost.c” and compiled on most Linux machines with</p>
<ul>
<li>gcc ghost.c -o ghost</li>
</ul>
<p>Running it with <code> ./ghost</code> should produce either “not vulnerable” with an exit code of 0, or “vulnerable” with an exit code of 1.</p>
<p>But let’s say you have 1000 machines, all with running salt-minions. How can we test for this on all of them?</p>
<p>We’ll assume first that they are all the same distro as your Salt master. Yes, I know that’s a degenerate case, but to start with let’s just consider the easy route.</p>
<p>First, save <code>ghost.c</code> to a directory on your master and compile it as describe above. Then put the executable in your <code>/srv/salt</code> directory (or wherever your file_roots points). Put this sls file in the same directory:</p>
<p># /srv/salt/ghosttest.sls</p>
<ul>
<li>/tmp/ghost:</li>
<ul>
<li>file.managed:</li>
<ul>
<li>- source: salt://ghost</li>
</ul>
<li>- owner: root</li>
<ul>
<li>- mode: '0644'</li>
</ul>
</ul>
<li>runghost:</li>
<ul>
<li>cmd.run:</li>
<ul>
<li>- name: /tmp/ghost</li>
</ul>
</ul>
</ul>
<p>Now you can fire off this on all your minions with</p>
<ul>
<li>salt \* state.sls ghosttest</li>
</ul>
<p>Because Salt will treat the result of cmd.run as a failure if the executed command returns a non-zero exit status, all vulnerable minions will show “FAILED”. Successfully patched minions will show “SUCCESS.”</p>
<p>Note that all vulnerable services will need to be restarted after a patch (or the affected system will need to be rebooted). Salt can help with this if, in fact, you need to restart individual services rather than restart an entire box.</p>
<p>There are a couple of odd results you can get back from this. First, on one of my machines I got</p>
<ul>
<li>w01:</li>
<li>—————</li>
<ul>
<li>ID: /tmp/ghost</li>
<ul>
<li>Function: file.managed</li>
<li>Result: True</li>
<li>Comment: File /tmp/ghost is in the correct state</li>
<li>Started: 11:06:30.632664</li>
<li>Duration: 779.398 ms</li>
<li>Changes:</li>
<ul>
<li>—————</li>
</ul>
</ul>
<li>ID: runghost</li>
<ul>
<li>Function: cmd.run</li>
<li>Name: /tmp/ghost</li>
<li>Result: False</li>
<li>Comment: Command “/tmp/ghost” run</li>
<li>Started: 11:06:31.412444</li>
<li>Duration: 60.247 ms</li>
<li>Changes:</li>
<ul>
<li>—————</li>
</ul>
</ul>
<li>pid:</li>
<ul>
<li>28508</li>
</ul>
<li>retcode:</li>
<ul>
<li>127</li>
</ul>
<li>stderr:</li>
<ul>
<li>/bin/bash: /tmp/ghost: No such file or directory</li>
</ul>
<li>stdout:</li>
</ul>
</ul>
<p>Salt told me the file was present and in the correct state, but bash said “No such file or directory.” Bug in Salt, right? I mean, that’s happened before.</p>
<p>No, not today! If I logged into the machine and ran the executable byhand I got the same message. In this case it was because all my other machines are 64-bit, but this one is 32-bit, and the test executable waslinked against the 64-bit glibc. So the message was correct, but confusing since the missing file is not the executable but the library.</p>
<p>Let’s fix this. I happen to have development tools installed on that box, so let’s build a 32-bit compiled version there, put it back on the master, and also modify the sls file so the correct executable will get copied to 64 or 32 bit machines.</p>
<p>/tmp/ghost.c:</p>
<ul>
<li>file.managed:</li>
<ul>
<li>- source: salt://ghost.c</li>
</ul>
<li>gcc ghost.c -o ghost:</li>
<ul>
<li>cmd.run:</li>
<ul>
<li>- user: root</li>
<li>- cwd: /tmp</li>
</ul>
</ul>
<li># Note this will not work unless file_recv is 'True' in the</li>
<li># salt-master config</li>
<li>cp.push:</li>
<ul>
<li>module.run:</li>
<ul>
<li>- path: /tmp/ghost</li>
</ul>
</ul>
</ul>
<p>Then, run this sls and copy the file out of the cache directory (see cp.push documentation)</p>
<ul>
<li># salt <32bitminion> state.sls ghostbuild</li>
<li># cp /var/cache/salt/master/minions/<32bitminion> /tmp/ghost /srv/salt/ghost32</li>
</ul>
<p>(replace <em>32bitminion</em> with the minion_id where you did the build)</p>
<p>Now change your ghostcheck.sls to look like this</p>
<p>/tmp/ghost:</p>
<ul>
<li>file.managed:</li>
<ul>
<li>{% if grains['osarch'] == 'i386' %}</li>
<li>- source: salt://ghost32</li>
<li>{% else %}</li>
<li>- source: salt://ghost</li>
<li>{% endif %}</li>
<li>- owner: root</li>
<li>- mode: '0700'</li>
</ul>
<li>runghost:</li>
<ul>
<li>cmd.run:</li>
<ul>
<li>- name: /tmp/ghost</li>
<li>- cwd: /tmp</li>
<li>- user: root</li>
<li>- require:</li>
<ul>
<li>- file: /tmp/ghost</li>
</ul>
</ul>
</ul>
</ul>
<p>Now I get accurate results from all my minions, 32-bit or 64-bit.</p>
<p>Obviously the simpler way to do this would be to build and run ghost.c on all minions, but many folks don’t keep gcc and friends on things like webservers.</p>
<p>Finally, if you don’t want to reboot all your machines, you just wantto restart affected services, you can do the following (props to the hackernews discussion for this snippet)</p>
<ul>
<li>salt \* cmd.run 'netstat -lnp | grep -e "\(tcp.*LISTEN\|udp\)" | cut -d / -f 2- | sort -u'</li>
</ul>
<p>which will tell you which services on which machines need to be restarted. Then for each of these services and machines you can say</p>
<ul>
<li>salt <affectedminion> service.restart <affectedservice></li>
</ul>
Fri, 20 Feb 2015 22:21:15 GMT
https://blog.ncbt.org/2015/02/20/050215.html?title=mitigatingGhostWithSalt
https://blog.ncbt.org/2015/02/20/050215.html?title=mitigatingGhostWithSaltInstalling macOS 10.9.2 with Salt<p>Several weeks ago I installed Salt on all my Macs. I have 7 currently, two of which cannot run Mavericks andare stuck at Lion (10.7). I know you can configure them to install updates automatically, but a couple of these are development machines and one is a server, and I just don’t like the idea of having them install updates and reboot whenever they feel like it.</p>
<p>Furthermore, the 10.9.2 release contains an important fix—the so called ‘gotofail’ security vulnerablity, fully documented here: <a href="https://www.imperialviolet.org/2014/02/22/applebug.html">https://www.imperialviolet.org/2014/02/22/applebug.html</a>. You can check to see if you are vulnerable with <a href="http://gotofail.com">http://gotofail.com</a>.</p>
<p>I was dreading manually going to each of these machines and running Software Update, waiting for it to figure out if there were really packages to install (why does that take so long, anyway?), and doing the click dance to get it installed.</p>
<p>Enter Salt.</p>
<p>(full disclaimer—I do work for SaltStack, the company behind open source Salt)</p>
<p>Using Salt turned probably an hour of updating into 3 commands executed at my leisure. Note, I run my salt-master on Ubuntu in a FusionVM on my Mac Mini server. After downloading the combo updater from Apple’s support site, I mounted it and extracted the .pkg file from it, then copied that file to my Salt master’s <code>/srv</code> directory (<code>/srv/salt/OSXUpd10.9.2.pkg</code>).</p>
<p>Then:</p>
<ul>
<li>salt-master# salt -C 'G@os:MacOS and G@osrelease:10.9.1' cp.get_file OSXUpd10.9.2.pkg /tmp/OSXUpd10.9.2.pkg</li>
<li>salt-master# salt -C 'G@os:MacOS and G@osrelease:10.9.1' cmd.run 'installer -pkg /tmp/OSXUpd10.9.2.pkg -target /'</li>
<li>salt-master# salt -C 'G@os:MacOS and G@osrelease:10.9.1' cmd.run 'shutdown -r now'</li>
</ul>
<p>So what the above says is</p>
<ol>
<li>For all MacOS machines that are on 10.9.1, copy the package file to the /tmp directory on the machine (thus avoiding my Lion machines). The -C says this is a compound target, and the command will match against both the os grain (to be “MacOS”) and the osrelease grain (to be “10.9.1”).</li>
<li>For those same machines, run Apple’s package utility in unattended mode on the package file, and install that to the boot volume.</li>
<li>Finally, reboot the machine.</li>
</ol>
<p>The response I got back was identical for each machine, and looks like</p>
<ul>
<li>mini-server:</li>
<ul>
<li>installer: Package name is OS X Update</li>
<li>installer: Installing at base path /</li>
<li>installer: The install was successful.</li>
<li>installer: The install requires restarting now.</li>
</ul>
</ul>
<p>So, did it work? After waiting for the machines to come back up (use salt-run manage.status on the Salt master to see when they are all online again), the following will show the OS release number for all my Macs.</p>
<ul>
<li>salt-master# salt -C 'G@os:MacOS' grains.item osrelease</li>
<ul>
<li>mini-server:</li>
<ul>
<li>osrelease:</li>
<ul>
<li>10.9.2</li>
</ul>
</ul>
<li>imac-01:</li>
<ul>
<li>osrelease:</li>
<ul>
<li>10.9.2</li>
</ul>
</ul>
<li>air-01:</li>
<ul>
<li>osrelease:</li>
<ul>
<li>10.9.2</li>
</ul>
</ul>
<li>mini-01:</li>
<ul>
<li>osrelease:</li>
<li>10.7.5</li>
</ul>
<li>macbookpro-01:</li>
<ul>
<li>osrelease:</li>
<ul>
<li>10.9.2</li>
</ul>
</ul>
<li>macbookpro-02:</li>
<ul>
<li>osrelease:</li>
<ul>
<li>10.9.2</li>
</ul>
</ul>
<li>white-macbook:</li>
<ul>
<li>osrelease:</li>
<ul>
<li>10.7.5</li>
</ul>
</ul>
</ul>
</ul>
<p>(Just to be clear, names sanitized)</p>
<p>Voila!</p>
Mon, 02 Feb 2015 22:21:15 GMT
https://blog.ncbt.org/2015/02/02/050215.html?title=installingMacos1092WithSalt
https://blog.ncbt.org/2015/02/02/050215.html?title=installingMacos1092WithSaltRemoving WireLurker with Salt<p>Claud Xiao from Palo Alto Networks has been in touch with me and I updated this script with his recommendations.</p>
<p>Please note I don’t plan to add Windows support, the anti-malware vendors do a great job maintaining signatures and removing stuff like this.</p>
<p>The news hit the fan early yesterday morning—lots of Apple haters were giddy with excitement at the revelation of the WireLurker trojan that infects iOS devices via their host Macintosh when the devices are plugged in via USB. </p>
<p>Publicized by Palo Alto Networks, details on WireLurker can be found at their website. Helpfully, Palo Alto also published a Python script that can detect the infection. Removing the infection from an iOS deviceis a matter of backing up the device, erasing it completely by restoring it to factory defaults, and then restoring the backup. Props to Topher Kessler of MacIssues for <a href="http://www.macissues.com/2014/11/06/faq-on-how-to-detect-and-remove-wirelurker-from-os-x-and-ios/">documenting this process</a>.</p>
<p>I took Palo Alto’s script and modified it so it can either be run from the command line or as a Salt execution module. From the command line:</p>
<ul>
<li>python wireunlurk.py</li>
</ul>
<p>will scan your Mac for signs of WireLurker. </p>
<ul>
<li>-h for help (not much there) or </li>
<li>-c for “clean”.</li>
</ul>
<p>wireunlurk.py will move any infected files to a dynamically-created directory in /tmp that starts with wireunlurk_bk.</p>
<p>If you want to run this in your Salt infrastructure, put <code>wireunlurk.py</code> in <code>/srv/salt/_modules</code> (or equivalent directory if you have customized it) and run the following on your Salt master:</p>
<ul>
<li>salt -G 'os:MacOS' saltutil.sync_modules</li>
<li>salt -G 'os:MacOS' wireunlurk.scan</li>
</ul>
<p>Add <code>clean=True</code> if you want to clean up the infection as well. This saved me a significant amount of time scanning my Macs just at home—we have 7 Macs on my home network and rather than ssh’ing to each one, or using a tool like <code>csshX</code>, as soon as I got the script running and ‘saltified’ I executed the above command and could sleep with peace of mind knowing none of our above command and could sleep with peace of mind knowing none of our devices were infected.</p>
<p>You can find my modified script here: </p>
<ul>
<li><a href="https://github.com/saltstack/salt-contrib/tree/master/modules/wireunlurk">https://github.com/saltstack/salt-contrib/tree/master/modules/wireunlurk</a></li>
</ul>
Sat, 24 Jan 2015 21:31:11 GMT
https://blog.ncbt.org/2015/01/24/040111.html?title=removingWirelurkerWithSalt
https://blog.ncbt.org/2015/01/24/040111.html?title=removingWirelurkerWithSalt