Thursday, July 12, 2012

Fun with SELinux and Apache

I was so proud of myself getting UserDir to work in Apache.  I thought I was set.  But when I tried to log into my account on my web server I got an error message saying it could not find my user directory so it was dropping me in /.  This was not good.  I let it go for a little while since this was a learning platform and not a production system.  But today I decided to find out why this was happening.

I looked at the file name (remember that in Unix/Linux everything is a file) and it was okay.  I checked the permissions on the file and they were okay.  Then I looked at the SELinux settings

ls -dZ ~

and what I saw was

drwx--x--x.  <username> <groupname> unconfirmed_t:object_r:httpd_sys_content_t:s0  /home/<username>

which was how the instructions I read said they should be.  On another VM I ran the same command and I saw user_home_dir_t instead of httpd_sys_content_t and I had no problems with the home directory there so I changed the context back on the web server VM

chcon -t user_home_dir_t  ~

and then I logged out and back in.  Hurrah!  I was in my home directory again.  I wanted to verify the web server was still able to access my test PHP scripts in ~/public_html directory.  Not a chance.  The dreaded 403 Forbidden message was displayed.  Now what do I do?

I did a Google search to see if I could set two context types in SELinux but I couldn't find anything that indicated I could.  The tool chcon has an option for a range of contexts but I couldn't find an example of how it worked.  My next option was to try the end user forum for the Linux distro I'm using for my test server.  Since I didn't have an account at CentOS I created one.  Why not?  It's always nice to have ready access to information.

A search of the CentOS forums showed an option that I didn't see, or glossed over, the first time I tried setting up UserDir.  So I typed the command

setsebool -P httpd_enable_home_dirs 1

and tried to access the web server again.  Success!  Now I can have my cake (UserDir access on my web server) and eat it too (access to my home dir in my web server).

Lesson learned: read all the documentation.

Monday, July 2, 2012

On shedding weight

Something that all geeks/nerds/etc. need to be aware of is weight.  I mean that excess fat on the body that makes one look, well, fat.  Being lonely, unwanted, too <whatever> to care is not an excuse.  The biggest problem in science fiction fandom, geekdom, etc., other than social ineptitude, is being obese or morbidly obese which leads to Type 2 Diabetes.  I know this because I was diagnosed last year and it caused me to mildly panic.  Fortunately I had helpful guidance in shedding weight (115 pounds so far) and being able to keep it off.  I say shedding instead of losing because something that is lost can be found.

I found that the quickest way to shed weight is to stop eating "recreational sugar" products.  This includes, but is not limited to: candy bars, ice cream, sugary soda (I drink diet soda so I'm not exactly cheating), cake, cookies (which I like to bake so now I have to find sugar free alternatives), and other sweet goodness.  It's okay to eat apples, sweet corn, etc. because the sugar is a natural and not added, but in moderation.  Everything is in moderation.  I gave up eating small pizzas by my self, even though I *love* pizza.

Exercise also helps.  Just don't over do it.  Start slow and work you way up.  Pick I time when you feel comfortable doing it.  I walk two miles in the morning three times a week, and add in other walks when I can.  I have a small dog that I take for a walk in the evening.

Back to Diabetes.  This can be a killer.  A friend did not have his diabetes diagnosed and continued to live an unhealthy lifestyle.  He was supposed to go to a New Years party some years ago but never showed up.  He just disappeared off the fannish radar.  Since this was before Twitter and Facebook became ubiquitous parts of everyday life no one thought twice about his silence until it lasted too long.  Several mutual friends went to his apartment to check on him and found an unpleasant surprise.  He was a groomsman at my wedding; I was a pallbearer at his funeral.  I don't like this kind of symmetry.

Please, please, please take care if you are over-weight.