23 December 2014
"Securing EPM" presentation at UKOUG Apps14
The slides for the "Securing EPM" presentation I've given at UKOUG Apps14 in Liverpool two weeks ago, are now available here. Merry Christmas!
19 November 2014
HOWTO Setup gunicorn on OpenBSD 5.6
As part of a silly web project of mine, I'm having fun getting reacquainted with OpenBSD.
Today I wanted to set up Gunicorn, a powerful webserver that will eventually run my Django application. It was not a straightforward process, so I decided to document it for my fellow geeks.
Note also how we're writing the main process PID to file, and then using it to stop that same main process. Standard
If you know anything else I should do to further secure this setup, please let me know in comments!
Today I wanted to set up Gunicorn, a powerful webserver that will eventually run my Django application. It was not a straightforward process, so I decided to document it for my fellow geeks.
Preamble
This procedure assumes that you've already set up the following:- installed Python 3 (I tested with 3.4.1)
- created a custom
myuseraccount and logged on as such - created a virtualenv with
pyvenv /home/myuser - installed Django in the above-mentioned virtualenv
- created a Django project at
/home/myuser/myproject
Let's go!
- activate the virtualenv:
source bin/activate - install Gunicorn:
pip install gunicorn - create
/home/myuser/gunicorn_config.pywith the following contents:command = '/home/myuser/bin/gunicorn' pythonpath = '/home/myuser/myproject' chdir = '/home/myuser' pidfile = '/home/myuser/.gunicorn_myproject.pid' user = 'nobody' worker_tmp_dir = '/tmp' errorlog = '/var/log/gunicorn_myproject' # tweak the following lines to suit your setup bind = 'localhost:8001' workers = 4
You can add any further option as necessary, but it's important you keeppidfileanduser. sudoto root (I'd recommend to do that from another account, i.e. don't addmyusertowheel) and create/etc/rc.d/gunicorn_myprojectwith the following contents:#!/bin/sh daemon="/home/myuser/bin/python" daemon_flags="/home/myuser/bin/gunicorn -c /home/myuser/gunicorn_config.py -D myproject.wsgi" rc_stop() { kill `cat /home/myuser/.gunicorn_myproject.pid` } . /etc/rc.d/rc.subr rc_cmd $1Note how we are specifyingdaemonto be the python executable. This is the only way I've found to keep the rest of the machinery inrc.subrworking smoothly.chmod 555 /etc/rc.d/gunicorn_myproject- now you can start and stop Gunicorn with standard OpenBSD 5.x commands:
/etc/rc.d/gunicorn_myproject start - Typically, you'd then set nginx to proxy and cache requests, and firewall gunicorn from the outside.
root and then spawns processes as nobody; if I were to start it as myuser, it would not work. This is because gunicorn tries to change ownership of files and processes after startup, and OpenBSD doesn't seem to like it. This looks suboptimal to me, but I couldn't find a workaround.Note also how we're writing the main process PID to file, and then using it to stop that same main process. Standard
rc.subr machinery would expect me to specify a regex in the pexp variable, which would then be passed to pgrep to find the process; but this doesn't work with gunicorn because pgrep simply cannot distinguish between master and worker processes, since they appear to have the exact same command line.If you know anything else I should do to further secure this setup, please let me know in comments!
07 November 2014
If you are interested in Oracle EPM infrastructure...
... then you might want to pop in at UKOUG Apps 14 in Liverpool, on 10 December, to hear me describe the sad state of security in our little niche and how we can improve it.
I promise that I won't bamboozle you with security nerdspeak; it will mostly be an overview of "things EPM customers should ask for but somehow never do". Remember to pack your tinfoil hat!
I promise that I won't bamboozle you with security nerdspeak; it will mostly be an overview of "things EPM customers should ask for but somehow never do". Remember to pack your tinfoil hat!
02 November 2014
What to do if Apple Mail becomes invisible in OSX 10.10
Apple Mail is a solid application, but occasionally it can be infuriating.
Today, all of a sudden, when I opened it, the main viewer window would not appear. The program seemed to work fine in the background: I received notification of new emails, the unread count on the icon would get updated, but there was no window. Trying to use Exposé, "Bring all to Front", "Arrange all to front" wouldn't bring any improvement. Right-clicking on the icon and selecting "Show all windows" would show transparent squares with actual window titles, but trying to click on them would make no difference. File -> New Viewer Window seemed to produce new "transparent" windows, so the list under the Window menu would get longer but I still wouldn't see anything. Using Applescript to resize and reposition a window gave very strange results, with the window appearing half-broken (no Preview column, no Mailbox list, missing toolbars etc) and eventually disappearing again.
Out of desperation, I quit Mail and started digging in the filesystem. I eventually managed to fix the problem by doing the following:
When I then launched Mail, the Viewer window finally appeared and worked correctly. It had lost my original layout, so I had to set a couple of preferences again, but apart from that it seemed to work well and it didn't lose any mail or account information.
Today, all of a sudden, when I opened it, the main viewer window would not appear. The program seemed to work fine in the background: I received notification of new emails, the unread count on the icon would get updated, but there was no window. Trying to use Exposé, "Bring all to Front", "Arrange all to front" wouldn't bring any improvement. Right-clicking on the icon and selecting "Show all windows" would show transparent squares with actual window titles, but trying to click on them would make no difference. File -> New Viewer Window seemed to produce new "transparent" windows, so the list under the Window menu would get longer but I still wouldn't see anything. Using Applescript to resize and reposition a window gave very strange results, with the window appearing half-broken (no Preview column, no Mailbox list, missing toolbars etc) and eventually disappearing again.
Out of desperation, I quit Mail and started digging in the filesystem. I eventually managed to fix the problem by doing the following:
cd /Users/your-user/Library/Containers/com.apple.mail/Data/Library
# 'tar' is just for safety, delete the gz file if fix works
tar -czvf ~/Desktop/Preferences.tar.gz Preferences
rm -rf Preferences When I then launched Mail, the Viewer window finally appeared and worked correctly. It had lost my original layout, so I had to set a couple of preferences again, but apart from that it seemed to work well and it didn't lose any mail or account information.
19 October 2014
Read this before you upgrade to OSX 10.10 "Yosemite".
A few notes for people looking to upgrade to OS X 10.10 "Yosemite".
- If you are a homebrew user, you might want to backup your /usr/local directory and then remove or rename it before running the upgrade. This is, reportedly, why my upgrade was stuck on "about a minute remaining" for almost 20 minutes; basically Yosemite will go through that dir and "fix" a lot of your hacks.
- For the same reason, backup your PostgreSQL data. If you don't, you'll have to fix it as reported on this StackOverflow question, i.e. recreating some dirs under (guess what) /usr/local.
- iStatMenus 3.27 was branded "incompatible" and disabled at first boot. After manually launching it, it had to "upgrade some components", but it seems to have been working fine since then. All its configuration was lost though. You might have a better experience with (paid upgrade) iStat Menus 5.
- IntelliJ PyCharm 3.4 seems to crash on startup. Apparently this is a known problem for all JetBrains products at this time (as commenter Bardia confirms below), due to them using Java 1.6 which is not officially supported on Yosemite. To fix it, I opened /Applications/PyCharm.app/Contents/Info.plist and edited the JVMVersion key from "1.6*" (i.e. "any 1.6 version") to "1.6+" ("any version greater than 1.6"). This found the 1.7 Oracle JVM I had previously installed, and launched successfully. However, it looks like the standard interface fonts now look bad (but not the custom ones used in actual editor tabs, somehow). I'll probably have to read through the relevant thread in the IntelliJ forums at some point.
- my not-regularly-updated homebrew was broken because it expected Ruby 1.8 to be available, whereas Yosemite ships only 2.0. To fix it, I successfully followed the instructions on this comment, just running the listed commands with sudo (because my homebrew is oldish and sudo-ed and I can't be arsed to reinstall and I'm a bad boy like that).
- The upgrade freed about 10GB of space, which is nice but makes me slightly nervous about what was removed.
- "Dark mode" is gorgeous, but the the new system fonts and overall "flatness" just make me sick. Apple Mail now looks sad. Guess I'll have to get used to it for now.
- Animations feel a bit glitchier than before, on my beefy 2012 MBPr (2.6 i7 with 16GB RAM). It took about 5 minutes before I got the first system crash (pointer still moving but desktop completely unresponsive). Apple must be working hard behind the scenes to sell me a new laptop. EDIT: I've found the way to get pre-upgrade performance -- System Preferences -> Accessibility -> Display -> Reduce Transparency should be ticked. It makes a HUGE difference.
- The upgrade didn't seem to make much of a difference with my HDMI problems (I have a new external monitor that can do 3840x2160, but it stopped working via HDMI earlier today, well before the upgrade. Hopefully it's a cable issue.)
I will likely update this post in the following days, as I experience more problems.
Subscribe to:
Posts (Atom)
