Year: 2013
It’s a trap!
Via xkcd.
You can certainly build open source software in .N…
You can certainly build open source software in .NET. And many do. But it never feels natural. It never feels right. Nobody accepts your patch to a core .NET class library no matter how hard you try. It always feels like you’re swimming upstream, in a world of small and large businesses using .NET that really aren’t interested in sharing their code with the world – probably because they know it would suck if they did, anyway. It is just not a native part of the Microsoft .NET culture to make things open source, especially not the things that suck. If you are afraid the things you share will suck, that fear will render you incapable of truly and deeply giving back. The most, uh, delightful… bit of open source communities is how they aren’t afraid to let it “all hang out”, so to speak.
So as a result, for any given task in .NET you might have – if you’re lucky – a choice of maybe two decent-ish libraries. Whereas in any popular open source language, you’ll easily have a dozen choices for the same task. Yeah, maybe six of them will be broken, obsolete, useless, or downright crazy. But hey, even factoring in some natural open source spoilage, you’re still ahead by a factor of three! A winner is you!
I’m not inclined to make grand pronouncements abou…
I’m not inclined to make grand pronouncements about the future of software, but if anything kills off commercial software, let me tell you, it won’t be open source software. They needn’t bother. Commercial software will gleefully strangle itself to death on its own licensing terms.
Accessing current username in sudo scripts on CentOS
I got a bit of a puzzle at work today. Â I had a script that was executed as another user via sudo, but I wanted to access the original username in the script, to know who was executing it. Â Sudoers manual suggest working with “Defaults env_keep“. Â Looking into the /etc/sudoers, I noticed that $USERNAME variable was whitelisted (in line #3 below):
Defaults env_reset Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS" Defaults env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE" Defaults env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES" Defaults env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE" Defaults env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"
So, I tried to use the $USERNAME variable in my script but it was coming up with empty results. Â That made me look deeper into default Bash initialization, and I found out that $USERNAME variable setup wasn’t a part of it. Â However, $LOGNAME was (in /etc/profile). Â I think, so few people actually use it that nobody noticed or bothered about it until now. Â Anyway, the solution now was obvious – simply add $LOGNAME variable to the sudo white list. Â Appending this line to the above env_keep ones did the job:
Defaults   env_keep += "LOGNAME"
There. In hopes it will help future generations…
P.S.: All that happened on a more or less default installation of CentOS 6.3, but I’m sure other Red Hat based distributions have a similar issue.
P.P.S.: If your script is ALWAYS invoked via sudo, also have a look at $SUDO_UID, $SUDO_GID, and $SUDO_USER variables.