Everything In Between

The brutally honest, first-person account of Meitar Moscovitz's life.

Archive for March, 2010

How to work around “sorry, you must have a tty to run sudo” without sacrificing security

6 comments

While working on $client‘s Linux server last week, I found myself installing a cron job that ran as root. The cron job called a custom bash script that, in turn, called out to various custom maintenance tasks client had already written. One task in particular had to run as a different user.

During testing, I discovered that the odd-ball task failed to run, and found the following error in the system log:

sudo: sorry, you must have a tty to run sudo

I traced this error to a line trying to invoke a perl command as a user called dynamic:

sudo -u dynamic /usr/bin/perl run-periodic-tasks --load 5 --randomly

A simple Google search turned up an obvious solution to the error: use visudo to disable sudo’s tty requirement, allowing sudo to be invoked from any shell lacking a tty (including cron). This would have solved my problem, but it just felt wrong, dirty, and most troublingly insecure.

One reason why sudo ships with the requiretty option enabled by default is, among other reasons, to prevent remote users from exposing the root password over SSH. Disabling this security precaution for a simple maintenance task already running as root seemed totally unnecessary, not to mention irresponsible. Moreover, client‘s script didn’t even need a tty.

Thankfully, there’s a better way: use su --session-command and send the whole job to the background.

su --session-command="/usr/bin/perl run-periodic-tasks --load 5 --randomly" dynamic &

This line launches a new, non-login shell (typically bash) as the other user in a separate, background process and runs the command you passed using the shell’s -c option. Sending the command to the background (using &) continues execution of the rest of the cron job.

A process listing would look like this:

root     28109     1  0 17:10 ?        00:00:00 su --session-command=/usr/bin/perl run-periodic-tasks --load 5 --randomly dynamic
dynamic  28110 28109  0 17:10 ?        00:00:00 bash -c /usr/bin/perl run-periodic-tasks --load 5 --randomly

Note the parent process (PID 28109) is owned by root but the actual perl process (PID 28110) is being run as dynamic.

This in-script solution that replaces sudo -u user cmd with su --session-command=cmd user seems much better than relying on a change in sudo‘s default (and more secure) configuration to me.

Written by Meitar

March 17th, 2010 at 8:21 pm

What if the Ten Commandments were affirmative instead of negative?

6 comments

Of the Ten Commandments, only 3 are phrased in the affirmative. The other 7 are phrased as negatives. Why? Doesn’t that seem kind of oppressive to anyone else?

Here’s the Ten Commandments as listed on Wikipedia:

  1. I am the Lord your God
  2. You shall not make for yourself an idol
  3. You shall not make wrongful use of the name of your God
  4. Remember the Sabbath and keep it holy
  5. Honor your father and mother
  6. You shall not murder
  7. You shall not commit adultery
  8. You shall not steal
  9. You shall not bear false witness against your neighbor
  10. You shall not covet your neighbor’s wife

Well, it certainly sounds like Insert-Your-Favorite-Deity is having a bit of a power trip. Let’s take a closer look at these commandments, but this time let’s phrase them all in the affirmative.

  1. I am the Lord your God
  2. You shall identify falsehoods and treat them as such
  3. You shall respect the power of words, names, and language
  4. Remember the Sabbath and keep it holy
  5. Honor your father and mother
  6. You shall let other living beings live
  7. You shall honor the relationship contracts that you enter and those of others
  8. You shall honor the property of others
  9. You shall uphold truth as you have seen it
  10. You shall strive for your own happiness

Doesn’t that sound infinitely better already? Interestingly, I feel that this rephrasing not only covers more ground (e.g., “You shall honor the property of others” turns “You shall not steal” into protections against stealing and vandalism), but it’s also a lot more inclusive of diversity.

Now let’s take this one step further and rephrase even the ones that were originally affirmative so that they not only reflect positive ideals, but also engender self-empowerment in the reader. Now my ten commandments read as follows:

  1. I am lord over my own body and mind
  2. I identify falsehoods and treat them as such
  3. My power comes from words, names, and language
  4. I honor my memories and choose my traditions
  5. I honor my chosen family
  6. I protect and create free life
  7. I demand respect for the relationship contracts I enter and grant respect to those of others
  8. I gift wealth to others
  9. I uphold my own convictions
  10. I spread joy

I wonder what kind of world we would live in today if this list had been the Ten Commandments so fervently adhered to. Since nothing in life is unchangeable, I’m going to start believing that these self-empowering words are the Ten Commandments for me.

Written by Meitar

March 13th, 2010 at 4:23 pm

My tweets on 2010-05-25

leave a comment

  • I ♥ my server logs, too. ;) ♺ @ConfidentInCali: Checking my server logs, some people read my blog at church! Presbyterians are kinky freaks. #
  • Proud of myself for my Spanish translation at http://SexEdEverywhere.com. I impressed 2 native speakers! Vote to get us even more resources! #
  • ♺ @KinkForAll Thinking abt your KinkForAll presentation topic yet? #KFASF #039;s only 15 days away! Read others' ideas+sign up http://tr.im/kfasf #
  • Dear everyone, please #smile at a stranger today. It's good for you, for them, and for our planet. Sincerely, everyone else. Thank you! :) #
  • Hang out w/me at 3PM Eastern, 12PM Pacific TOMORROW when I appear on San Francisco community radio. Listen live from http://FCCFreeRadio.com #
  • ♺ @thesexademic "He said he didn't have a condom. [I said] that's fine; I was ready to be a mom…he magically [found one]" http://tfl.nu/4u76 #
  • @seraglioletters @starletfallen Yay! Smiles are among the most viral contagions I know. Glad you keep spreading them around. Enjoy your day! in reply to seraglioletters #
  • Reason №7624 why I love being an information worker: I've managed to make work for myself that necessitates consuming AND producing content. #
  • ♺ @KinkOnTap Busty snowlady prompts anon complaint, cops ask family to "tone down" display. HEY ANON, GET OFF MY LAWN! http://icio.us/b0f0sz #
  • Home after much-needed dinner socializing with @sarahdopp. Among other things, I realized I need to visit other SF neighborhoods more often. #
  • I hate it when I'm full of #ideas but they don't make it to the outside of my head coherently no matter what form they try to take. #burnout #
  • Augh. You know you need to take a break from work when you're stressing over what to wear to your RADIO interview the next day. #TimeToRelax #

Written by Meitar

March 7th, 2010 at 2:00 pm

Posted in General

My tweets on 2010-03-06

leave a comment

  • KinkForAll San Francisco venue contract signed+sealed+delivered: http://tr.im/QLJD Pls SIGN UP if you haven't yet: http://tr.im/kfasf #KFASF #
  • ♺ @KinkForAll Signed up for KinkForAll San Francisco yet? It's free & helps us estimate participation levels! http://tr.im/kfasf Thx! #KFASF #
  • Credit card statements are like little time machines. Every line-item is a #memory transporting me to the time or place I made the purchase. #
  • Finally published my post abt #submission & how many people get it totally wrong: http://vb.ly/25cz I really need more hrs in my days. #BDSM #

Written by Meitar

March 6th, 2010 at 2:00 pm

Posted in General

My tweets on 2010-03-05

leave a comment

Written by Meitar

March 5th, 2010 at 2:00 pm

Posted in General

My tweets on 2010-03-04

leave a comment

  • Looking over contract for #KFASF at Women's Building on Mar 21. Almost there but I'm still $290 short. Can you donate at http://tr.im/kfasf? #
  • http://j.mp/seeiwhc isn't leading cuz competition got 500+ votes in 1 day. Oh, Internet. :) S'ok; we're gonna do SEE anyway. /cc @audaciaray #
  • @audaciaray Ya, I know. =) Frankly, I'm thrilled y'all have managed to get us actively sharing our sexual health promotion ideas! GREAT JOB! in reply to audaciaray #
  • Working on my next presentation, possibly for #5MoF @Noisebridge in a couple weeks. Working title: "Community Organizing FOR GREAT JUSTICE!" #
  • Dear all, pls wish @helio_girl health, happiness. She's feverish & slept all day. 1 way to show love: vote for SEE at http://j.mp/seeiwhc :) #
  • Shout outs to @mrsexsmith, @saraeileen, Rachel, and Elizabeth for their donations to #KFASF We're only $220 away now! http://tr.im/kfasf :D #
  • @heathercorinna @sarahdopp Sounds like "driven" to me. Could be manic but I do exactly the same thing & I'm better now that I'm off my meds. in reply to heathercorinna #
  • Are you (or do you want to be) involved in a #social justice #community project? If so, what's most important to you about it & why? Thx. :) #
  • @heathercorinna @sarahdopp Wait…there's a difference between "driven" & "completely off your nut?" Why did nobody tell me this years ago? :) in reply to heathercorinna #
  • Switching frm 5MoF.net talk to long-brewing blog post on submissive masculinity was surprisingly productive. Good to have multiple projects. #
  • @kristina_lloyd You did a fantastic job w/Erotica Cover Watch. I've learned lots from you. Please let us into what your new projects are! :) in reply to kristina_lloyd #

Written by Meitar

March 4th, 2010 at 2:00 pm

Posted in General

My tweets on 2010-03-03

leave a comment

Written by Meitar

March 3rd, 2010 at 2:00 pm

Posted in General

My tweets on 2010-03-02

leave a comment

Written by Meitar

March 2nd, 2010 at 2:00 pm

Posted in General

My tweets on 2010-03-01

leave a comment

Written by Meitar

March 1st, 2010 at 2:00 pm

Posted in General