{"id":284,"date":"2016-07-05T10:52:05","date_gmt":"2016-07-05T08:52:05","guid":{"rendered":"https:\/\/balanceofcowards.net\/boc_blog\/?p=284"},"modified":"2018-05-22T10:24:09","modified_gmt":"2018-05-22T08:24:09","slug":"running-firefox-as-a-different-user","status":"publish","type":"post","link":"https:\/\/balanceofcowards.net\/boc_blog\/2016\/07\/running-firefox-as-a-different-user\/","title":{"rendered":"[:en]Running Firefox as a different user: A convenience hack for social networks and instant messaging[:]"},"content":{"rendered":"<p>[:en]Social convention requests that I be active on <a href=\"https:\/\/www.facebook.com\" target=\"_blank\">Facebook<\/a>. Recently, I have also been persuaded to get myself a <a href=\"http:\/\/www.whatsapp.com\" target=\"_blank\">WhatsApp<\/a> account. I have two issues with that:<\/p>\n<ul>\n<li>I strongly prefer to keep social networks in a &#8222;privacy container&#8220;. It is no business of Facebook, where I surf on the web. Thus, I&#8217;d like to keep social networking sessions separate from my day-to-day surfing (this also applies to my Google account, of course).<\/li>\n<li>When chatting, it is an absolute necessity for me to be able to use my keyboard. Smartphones are, in my opinion, not a good device to use for chatting. Typing on a touchscreen slows me down in an unbearable manner&#8212;not mentioning the fact that half of my data is not available on my smartphone.<\/li>\n<\/ul>\n<p>As long as I used Facebook, I was content to open up a Firefox &#8222;private window&#8220; whenever someone messaged me, continuing the conversation from there. This required a single login, but I regularly could type that faster than the page loaded. However, with WhatsApp this is different. The web interface requires me to scan a QR code every time I want to log in. I will not comment on the architectural reasons behind that (it&#8217;s just too ridiculous). However, another approach is needed.<\/p>\n<p>My plan, therefore: Having a dedicated Firefox session for social networks and chatting.<\/p>\n<p>Unfortunately, Firefox does not support running two separate processes as the same user. It <em>does<\/em> support having different user profiles&#8212;but those cannot run in parallel. I would have had to shut down my regular session to open the social network session. Not an option!<\/p>\n<p>So I came up with the idea of creating a dedicated user for running this Firefox session. Turns out this is not quite as straightforward as expected, but with a bit of hacking it works surprisingly well.<\/p>\n<p>Step 1: I need a new user. I&#8217;ll call this one &#8222;snim&#8220; for &#8222;Social Networks and Instant Messaging&#8220;. Under Ubuntu:<br \/>\n <span class=\"lang:sh decode:true  crayon-inline \" >sudo adduser &#8211;disabled-password snim<\/span><br \/>\nI disabled the password, because I do not want to ever log into that account. It&#8217;s just there for running my Firefox process.<\/p>\n<p>At this point I expected step 2 would be as easy as allowing a <code>sudo<\/code> for Firefox. Turns out it is not: Firefox needs access to the current X11 session and requires a full user environment to play nicely with temporary files and the likes. So <code>sudo -u snim firefox<\/code> actually does not work. Well, the solution is to create a small shell script, instead:<\/p>\n<pre class=\"lang:sh decode:true \" title=\"firefox_hack\" >#!\/bin\/bash                                                                                                                                 \r\nxhost + # Allow X11 access\r\nsu -c firefox - snim # Execute firefox in the environment of \"snim\"\r\n<\/pre>\n<p>There&#8217;s still the problem that this script would ask me for the password of &#8222;snim&#8220;&#8212;which I deliberately deactivated before. So, instead I&#8217;ll have to add a line to the <code>\/etc\/sudoers<\/code> file that allows me to execute that script without asking for a password. The line is simple:<\/p>\n<pre class=\"lang:default decode:true \" title=\"\/etc\/sudoers\" ># ... (stuff before)\r\n\r\n# ... at the end: the firefox-hack\r\nmyusername   ALL=(ALL) NOPASSWD: \/path\/to\/my\/firefox_hack\r\n<\/pre>\n<p>Of course, &#8222;myusername&#8220; has to be replaced with the actual user name and &#8222;\/path\/to\/my\/firefox_hack&#8220; should be the path to the script above.<\/p>\n<p>Having that, a <code>sudo \/path\/to\/my\/firefox_hack<\/code> will start a separate Firefox session without asking for a password. In that session I can now keep Facebook, WhatsApp and Google logged into my accounts at all time, without having any other data from my regular browsing session &#8222;spill over&#8220;. I keep the three websites open in tabs, set Firefox to remember my tabs, and define a shortcut for the <code>sudo<\/code> command above. Bam! Convenient privacy-aware social networking and chatting :)<\/p>\n<p>[:]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[:en]Social convention requests that I be active on Facebook. Recently, I have also been persuaded to get myself a WhatsApp account. I have two issues with that: I strongly prefer to keep social networks in a &#8222;privacy container&#8220;. It is no business of Facebook, where I surf on the web. Thus, I&#8217;d like to keep [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,1],"tags":[],"class_list":["post-284","post","type-post","status-publish","format-standard","hentry","category-sys","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/balanceofcowards.net\/boc_blog\/wp-json\/wp\/v2\/posts\/284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/balanceofcowards.net\/boc_blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/balanceofcowards.net\/boc_blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/balanceofcowards.net\/boc_blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/balanceofcowards.net\/boc_blog\/wp-json\/wp\/v2\/comments?post=284"}],"version-history":[{"count":5,"href":"https:\/\/balanceofcowards.net\/boc_blog\/wp-json\/wp\/v2\/posts\/284\/revisions"}],"predecessor-version":[{"id":289,"href":"https:\/\/balanceofcowards.net\/boc_blog\/wp-json\/wp\/v2\/posts\/284\/revisions\/289"}],"wp:attachment":[{"href":"https:\/\/balanceofcowards.net\/boc_blog\/wp-json\/wp\/v2\/media?parent=284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/balanceofcowards.net\/boc_blog\/wp-json\/wp\/v2\/categories?post=284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/balanceofcowards.net\/boc_blog\/wp-json\/wp\/v2\/tags?post=284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}