Tag Archives: Site

SFTP, SSHFS, VPN + exportFS, and WebDav.

While working on some code, I needed to get something I could access much faster and much easier than my current methods.  So after some testing, I’ve come across a solution.

I started with my simple SSH session.  This proves to not be so helpful when editing multiple files or needing to move around easier.  While the power of command line is great, it isn’t so great for developing larger scripts or moving around between multiple files easily.

So onto SFTP.  I used a sftp shelled user by adding that user to a group and forcing that group in my sshd.conf to always use sftp:

This works very awesome and is much more secure than FTP. It is using the SSh backend, which is very secure but foces it down to a ftp layer. The jailed user can’t run any commands, no forwarding, and is chrooted to a directory (their home in this case). However, this was slow. On average it would take 4 seconds to load a file. Directory listings where fairly fest (usually 1 second, sometimes 2). Unacceptable delays just to edit a file.

Since SFTP was out of the question, I figured it would be similar, but gave it a try anyways. I setup SSHFS using OSXFuse and SSHFS and then MacFusion.app (A simple GUI to test with, if it worked I would learn to use the CLI). With that setup, it was even worse. Files would open in 1-2 seconds, but directory listings just took forever, sometimes not even loading at all.

As SSHFS was not a option and since I wanted to try it anyways, I tried to setup VPN. OpenVPN being the choice here, I spent a few hours working on setting this up. This took a bit to configure as my firewall was blocking a lot of the connections, even once I got the right port configured, the firewall still blocked access. But once I sorted out allowing that private traffic and getting the certs in the right place, I got connected to my new VPN. I will note that if you don’t sign the certificate, it doesn’t produce a valid .crt file. So make sure to say yes to that.

After setting up VPN, I needed to setup exportfs so I could export the directory I wanted. More troubles with that. A combination of the correct options on server side (rw,sync,no_subtree_check,insecure,anonuid=1000,anongid=1001,all_squash) and the right ones on the client side (-o rw,noowners -t nfs) to finally get it to work properly. Alas after all these troubles, it was the same issue as SSHFS. Slow directory loading. This was unacceptable and would not do.

Finally, tried WebDav. At first I was trying it in a directory, but my location directive for php files in Nginx was wreaking havoc. So I just setup another subdomain to deploy this under. It also appears that Nginx at least on Ubuntu 12.04 (possibly similar versions on Debian as well) has the dav module and extension (for full support) built into it. I simply just needed to setup the configuration for it. Really easy to do and didn’t take much time, I think I set that up in less than 30 minutes).

The result is great. WebDav is fast. Directory listings are almost instant and files open in just a second. While OS X (Mountain Lion) does not seem to have the correct support for WebDav and attempts to look foe resource files and other hidden files (such as a .ql_disablethumbnails which I assume is for QuickLook to not load a thumbnail). So it was over to my FTP client that supported WebDav. Wish I could of had native Finder support for it, but oh well.

A IRC user said it best though and I couldn’t agree more now: < rnowak> SleePy: webdav rocks, totally underused.

Read More

SMF on Nginx+SPDY

No surprise here as SPDY is a server side thing, SMF works no problem using Nginx+SPDY. So there should be no problem with the SPDY plugin/module at all in any other web server. Just need to set it up on your web server. Nginx currently has a patch for it. But I would suspect that this will be merged into its trunk soon and make its way to stable in Nginx.

Read More

Pastebin rewrote

I have taken my original code I wrote for my SMF powered pastebin and rewrote this script. This was a massive rewrite from the original code and hopefully it works out well for anyone else who is looking into using it.

I wrote it so it should be plugable with different databases, user information and templating engines. The design was mostly to implant it into my mixed environment of SMF and WordPress, but also to make it robust so it could be used in other ways.

The source of the code is up on GitHub at https://github.com/jdarwood007/pastebin

Read More

SMF in WordPress

For some reason, while using WordPress and including SMF’s SSI.php, it would not detect my logged in SMF session. Baffled and almost thinking this was a SMF bug of some sorts, I began to debug this process.

Well it turns out it is sorta a SMF old PHP support issue, but the problem lies in WordPress. This is the function in WordPress wp-includes/load.php

The problem here, is that they add magic quotes to the cookie. Not quite sure why they are even doing this. But it broke adding SMF. The part in SMF which failed because of this is in SMFs Sources/Load.php in the loadUserSettings function

Because of old PHP support in SMF, its trying to combat a cookie security issue that existed below PHP 4.3.9. Now I don’t use that version, but I rather not strip out the code. The preg match was failing because it was not finding that valid string in the cookie. Since all the double quotes where escaped with a slash \.

For my code, I called in Settings.php from SMF and then did a stripslashes on the cookie. Then I included SSI.php, with the results I expected of it finding my active SMF session.

I should note because SMF uses a lot of global variables, that I had to globalize all of those before hand. I just borrowed the globals from SSI.php and put them into that scripts function.

Read More

Password Generator is open source

I have rewrote my Password Generator script and after doing so, I have enabled it so you can see the source of this code. Simply click the link on the right side when viewing that page and the entire source code will be revealed.
Developers are welcome to reuse any part of the code as long as credit is given where appropriate. Although this script may be over the top for normal password generation, I developed it to create truly random passwords.

Read More

SMF Package Manager Generator

Hello,
Originally I had wrote my original SMF Package Manager Generator a few years ago. It was sloppy coding, poor JavaScript and relied heavily on the server. Not my absolute best work, but was something I was proud on at the time from my efforts to dive into JavaScripting.

However, todays times are different. So with JQuery out there, I decided to take breaks from my projects for a couple hours for a few days and put forth a effort to rewrite this. Needless to say, I had the initial code wrote in only a few hours. My original script took me a few days alone. That didn’t count the package-info creator I made later which also took a while.

The new script attempts to rely all on JavaScripting via JQuery. It was a fun experience to build it this way. Although, because of JavaScript’s security measures, I couldn’t leave downloading the file outside of the server. So alas, I still have to process the actual download via the server. There is a work around with using Data URIs, however it didn’t provide the filename and sounds a bit flaky when the length of the url gets to be a bit long. I included both as a option though.

Oh and Its on github, because I see no reason to not share the code. Including the code I used to integrate it into my WordPress blog.

Read More

WordPress templates on non wordpress pages

I have a couple pages such as my password generate that are non wordpress templates. However I want these to be styled as if they where from my wordpress. So after some google searches, I came up with very little information. I decided to dive into the code and came up with something that works for what I need it to do and requires little code edits to any of my pages to work.

This does also require a template edit to your wordpress templates. Sadly I couldn’t avoid this, I looked around and tried to see if I could modify the_content(), however it doesn’t look very pleasant to do so. I might in the future look into doing this. If somebody has a better solution that requires no wordpress template edits, please let me know. Back on topic, I modified page.php in my template and changed:

To this line:

Next I will just dump a file I named wp-ssi.php and explain how it works at the end.

Now for all my files I add at the very top. Of course, you need to substitute the path to match yours.

As for wp-ssi.php, I will can explain more about how that works.
(more…)

Read More

Converting part of a svn repository to git

In moving my projects over to git, I stumbled across a troublesome issue. In one of my projects existed a folder along side trunk, tags and branches that had stuff I needed to be converted. However I wanted to convert these as individual git repositories.

So, after reading “git –help svn clone” and finding nothing to help me with this issue, I headed to the search engines. It took some time between search engines and asking some friends. As a note, Git 1.7 has sparse abilities, however I never got that far to try it out. I found out that git 1.6.4 included a new parameter which does the job just nicely.

I stumbled across this on the Tech Debug blog.

So in the end the following command is an example of what I did, with real data omitted.

This did the job exactly as I needed it to. It converted just the folder in the repository without so much of a complaint. Now that I review the git man page for svn, I do see I missed it.

When tracking multiple directories (using –stdlayout, –branches, or –tags options), git svn will attempt to connect to the
root (or highest allowed level) of the Subversion repository. This default allows better tracking of history if entire projects
are moved within a repository, but may cause issues on repositories where read access restrictions are in place. Passing
–no-minimize-url will allow git svn to accept URLs as-is without attempting to connect to a higher level directory. This option
is off by default when only one URL/branch is tracked (it would do little good).

Read More

Auto updating git repositories

I have my git repos cloned on my site. In order to keep my git viewer up to date, I need those clones to continue to be up to date.

Thankfully, there is a simple way to do this. git does have a –git-dir=/path, However this does not appear to work. You still need to change into the working directory in order to pull the updates. So after some work, I came up with this:

I simply add this as a cron tab, using > /dev/null to eat the output. However if an error occurs, I should receive a email with what exactly went on.

Read More

Postfix with ubuntu 11.10

In addition to my Dovecot issues, postfix as well had failed and I wasn’t able to send emails. However, getting them was more important at that point.

After some trials, I found I needed to add this to my main.cf
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth

Which has resolved postfix from not working. Hopefully I fixed all my issues since my upgrade.

Read More

Highslide for Wordpress Plugin