{"id":37108,"date":"2022-09-22T15:49:16","date_gmt":"2022-09-22T19:49:16","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=37108"},"modified":"2022-09-23T07:51:37","modified_gmt":"2022-09-23T11:51:37","slug":"terminal-and-full-disk-access","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2022\/09\/22\/terminal-and-full-disk-access\/","title":{"rendered":"Terminal and Full Disk Access"},"content":{"rendered":"<p><a href=\"https:\/\/lapcatsoftware.com\/articles\/FullDiskAccess.html\">Jeff Johnson<\/a> (<a href=\"https:\/\/twitter.com\/lapcatsoftware\/status\/1572972693603123201\">tweet<\/a>):<\/p>\n<blockquote cite=\"https:\/\/lapcatsoftware.com\/articles\/FullDiskAccess.html\"><p>Many expert Mac users grant Full Disk Access to Terminal app, because the permissions dialogs quickly become very annoying when you try to do things in Terminal, as we&rsquo;ve already seen above.<\/p><p>[&#8230;]<\/p><p>What you may not realize is that if you grant Full Disk Access to Terminal, you thereby provide Full Disk Access to every unsandboxed app on your Mac too! And how can this be? The reason is that unsandboxed apps can open executable shell scripts in Terminal, and those scripts will execute with the permissions not of the opening app but rather with the permissions of Terminal, i.e. Full Disk Access.<\/p><p>[&#8230;]<\/p><p>If you think the solution to this problem is simply to withhold Full Disk Access from Terminal: it&rsquo;s not that simple! Every unsandboxed app effectively has all of the permissions of Terminal, whatever those permissions happen to be.<\/p><\/blockquote>\n\n<p>I don&rsquo;t understand why Terminal executes shell script files in the first place. It doesn&rsquo;t even prompt to confirm. Aside from the security implications&mdash;for what I think is not a commonly used feature, anyway&mdash;it also means that I sometimes execute a script by accident, double-clicking and expecting it (because of the icon) to open in a text editor.<\/p>\n\n<p><a href=\"https:\/\/developer.apple.com\/forums\/thread\/678819\">Quinn the Eskimo<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/forums\/thread\/678819\">\n<p>MAC presents some serious challenges for scripting because scripts are run by interpreters and the system can&rsquo;t distinguish file system operations done by the interpreter from those done by the script.  For example, if you have a script that needs to manipulate files on your desktop, you wouldn&rsquo;t want to give the interpreter that privilege because then <em>any<\/em> script could do that.<\/p>\n<p>The easiest solution to this problem is to package your script as a standalone program that MAC can use for its tracking.  This may be easy or hard depending on the specific scripting environment.  For example, AppleScript makes it easy to export a script as a signed app, but that&rsquo;s not true for shell scripts.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/developer.apple.com\/forums\/thread\/114452?answerId=352695022#352695022\">Sheldon15<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/forums\/thread\/114452?answerId=352695022#352695022\">\n<p>I find it&rsquo;s a little backward approach to not have a robust way to test for FDA and instead handle errors resulting from the lack thereof. The problem is that sometimes you can&rsquo;t distinguish errors resulting from the lack of FDA and other kinds of errors. Or you have a lengthy operation that you know will fail or will be incomplete without FDA and you want to tell the user in advance.<\/p>\n<p>In my case, my app estimates size of a directory. Some subdirectories inside of it will not be counted due to the lack of FDA, and the overall size will not match Finder&rsquo;s estimation. The scope of all folders protected from FDA is not clearly defined in the documentation, so I will not be able to detect when I have a lack of FDA or it&rsquo;s a different kind of error. I can guess and recommend the user to add my app to FDA, but it&rsquo;s confusing if he&rsquo;s already done that and still sees the recommendation.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/developer.apple.com\/forums\/thread\/114452?answerId=352695022#352695022\">John Daniel<\/a> (in <a href=\"https:\/\/mjtsai.com\/blog\/2022\/09\/22\/terminal-and-full-disk-access\/#comment-3808253\">2019<\/a>):<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/forums\/thread\/114452?answerId=352695022#352695022\"><p><strike>Full Disk Access isn&rsquo;t very reliable either. You can do everything right and it still doesn&rsquo;t work sometimes. You have to budget for this and provide documentation on how to remove an app, restart, re-add, and fallback to <code>tccutil<\/code> in the Terminal when all else fails.<\/strike><\/p><\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/08\/26\/sandboxing-a-command-line-tool-with-paths-as-arguments\/\">Sandboxing a Command Line Tool With Paths As Arguments<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2021\/07\/13\/overview-of-tcc-bypasses-by-accident-and-design\/\">Overview of TCC Bypasses by Accident and Design<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2020\/12\/07\/tcc-doesnt-prevent-protected-folders-from-being-listed\/\">Sandbox Doesn&rsquo;t Protect Files From stat()<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Jeff Johnson (tweet): Many expert Mac users grant Full Disk Access to Terminal app, because the permissions dialogs quickly become very annoying when you try to do things in Terminal, as we&rsquo;ve already seen above.[&#8230;]What you may not realize is that if you grant Full Disk Access to Terminal, you thereby provide Full Disk Access [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2022-09-22T19:49:18Z","apple_news_api_id":"57a167aa-4d3c-4d20-b1e9-5e190617b5bf","apple_news_api_modified_at":"2022-09-23T11:51:39Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAw==","apple_news_api_share_url":"https:\/\/apple.news\/AV6Fnqk08TSCx6V4ZBhe1vw","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[2],"tags":[30,2077,355,48,318,1960],"class_list":["post-37108","post","type-post","status-publish","format-standard","hentry","category-technology","tag-mac","tag-macos-12","tag-privacy","tag-security","tag-terminal","tag-transparency-consent-and-control-tcc"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/37108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=37108"}],"version-history":[{"count":5,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/37108\/revisions"}],"predecessor-version":[{"id":37120,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/37108\/revisions\/37120"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=37108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=37108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=37108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}