{"id":1096,"date":"2011-12-19T11:54:17","date_gmt":"2011-12-19T15:54:17","guid":{"rendered":"http:\/\/antipaucity.com\/?p=1096"},"modified":"2011-12-19T11:54:17","modified_gmt":"2011-12-19T15:54:17","slug":"extended-file-attributes-with-ext234","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=1096","title":{"rendered":"extended file attributes with ext[2|3|4]"},"content":{"rendered":"<p>Most Unix\/Linux users, and &#8211; hopefully &#8211; all admins are familiar with the standard 9\u00a0bits\u00a0of permissions typically supported on various *nix file systems:<\/p>\n<blockquote><p><code>---------<\/code><br \/>\n<code>rwxrwxrwx<\/code><br \/>\n<code>uuugggooo<\/code><\/p><\/blockquote>\n<p>Where &#8220;u&#8221;, &#8220;g&#8221;, and &#8220;o&#8221; indicate &#8220;user&#8221;, &#8220;group&#8221;, and &#8220;other&#8221; while &#8220;rwx&#8221; indicates whether the item can be read, written, or executed.<\/p>\n<p>Also of note are file ownerships in the form of<\/p>\n<blockquote><p><code>user:group<\/code><\/p><\/blockquote>\n<p>So a file might be owned by <code>warren:warren<\/code> with read\/write privileges only for the owner: <code>rw-rw----<\/code>.<\/p>\n<p>That&#8217;s pretty handy.<\/p>\n<p>How many of you know there are <em>hidden<\/em>\u00a0permissions that do not show up in a normal use of <code>ls -l<\/code>?<\/p>\n<p>I didn&#8217;t until last week &#8211; and I&#8217;ve been using Linux for more than a decade \ud83d\ude41<\/p>\n<p>Turns out that &#8211; at least with ext2, etx3, and ext4 filesystems &#8211; there are a variety of other attributes that can be assigned to a file. One of them is the immutable flag<sup>*<\/sup>.<\/p>\n<p>(Using a related command to <code>ls<\/code>, <code><a href=\"http:\/\/linux.die.net\/man\/1\/lsattr\">lsattr<\/a><\/code>, a person can view the extended attribute flags of a file.)<\/p>\n<p>In specific, the immutable flag disallows even the <strong><em>owner<\/em><\/strong> from deleting his\/her own file! There was the source of a very ornery issue I ran into while doing an upgrade last week of a customer&#8217;s management environment. The upgrade installer ran into an issue wherein it interrupted its own process. But when it did, it left the filesystem in an inconsistent state &#8211; specifically with regards to an SSL certificate file and the machine identifier file (<code>agent.srv<\/code> and <code>mid<\/code>, if you&#8217;re curious) having the immutable flag set. When attempting to pick back up with the upgrade, the installer failed more [apparently] asymptomatically (and esoterically) than I had ever seen before.<\/p>\n<p>After several exchanges with senior product support, a working fix of running <code>chattr -i \/path\/to\/file<\/code> was provided. Neither myself, nor any of the senior admins at my customer had ever heard of <code><a href=\"http:\/\/linux.die.net\/man\/1\/chattr\">chattr<\/a><\/code>. So off to the <code>man<\/code> pages. Turns out that chattr is quite the command &#8211; but it&#8217;s not well publicized (at least, I don&#8217;t think it is).<\/p>\n<p>If you run into a file you own, but cannot delete, be sure to inspect the extended attributes with <code>lsattr<\/code>, and fix any mis-set flags with <code>chattr<\/code>.<\/p>\n<hr \/>\n<p><sup>*<sub>The entire list of alterable flags: &#8220;append only (a), compressed (c), no dump (d), extent format (e), immutable (i), data journalling (j), secure deletion (s), no tail-merging (t), undeletable (u), no atime updates (A), synchronous directory updates (D), synchronous updates (S), and top of directory hierarchy (T).&#8221; Non-modifiable, but visible with <code>lsattr<\/code>, flags: &#8220;huge file (h), compression error (E), indexed directory (I), compression raw access (X), and compressed dirty file (Z)&#8221;.<\/sub><\/sup><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most Unix\/Linux users, and &#8211; hopefully &#8211; all admins are familiar with the standard 9\u00a0bits\u00a0of permissions typically supported on various *nix file systems: &#8212;&#8212;&#8212; rwxrwxrwx uuugggooo Where &#8220;u&#8221;, &#8220;g&#8221;, and &#8220;o&#8221; indicate &#8220;user&#8221;, &#8220;group&#8221;, and &#8220;other&#8221; while &#8220;rwx&#8221; indicates whether the item can be read, written, or executed. Also of note are file ownerships in &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=1096\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">extended file attributes with ext[2|3|4]<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[41,48],"tags":[],"keyring_services":[],"class_list":["post-1096","post","type-post","status-publish","format-standard","hentry","category-technical","category-work"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/1096","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1096"}],"version-history":[{"count":0,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/1096\/revisions"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1096"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1096"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1096"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=1096"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}