LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-21-2006, 10:29 PM   #1
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Rep: Reputation: 45
GMailFS HOWTO: Guide to Using Your GMail Account as a Linux File


GMailFS HOWTO: Guide to Using Your GMail Account as a Linux File System
last updated: 10/26/2006

Auther: Aaron Miller (armantic101@gmail.com)

I will try to keep this document as current as possible, however the official (and most up to date) version can be found at http://www.drkstr.org/HOWTO-GMailFS.html

Contents
1.0 Overview
2.0 Install Needed Software
2.1 Install FUSE
2.2 Install Python FUSE Bindings
2.3 Install LibGMail
2.4 Install GMailFS
3.0 Using Your GMail File System
3.1 Configure GMailFS
3.2 Mount GMail file system
4.0 Fine Tuning
4.1 Auto Archive GMailFS Messages to Prevent Inbox Clutter
4.2 Modify GMailFS to Display True File Name for EMail Attachment
5.0 Change Log




1.0 Overview


This is a quick guide to using your GMail account as a Linux file system, via GMailFS by Richard Jones. This might be useful to back up files or give your self access to your saved files from anywhere that has a web browser.


The GMailFS file system

The file system is created by posting email messages to your account that contain references to the inode, directory structure, and other file system information in the subject and email header. Actual files are saved as an attachment and files over the max attachment size are broken into multiple attachments.


Extra Reading:

http://richard.jones.name/google-hac...ilesystem.html
http://fuse.sourceforge.net/
http://sourceforge.net/projects/libgmail


System Requirements:

GMail email account
Linux Kernel 2.4 or later
Python 2.3 or later
FUSE - implements userspace file systems in Linux
FUSE Python Bindings - needed for file system code written in python
LibGMail - libraries for GMail access and message handling
GMailFS - the libraries for the GMail file system



2.0 Install Needed Software


2.1 Install FUSE

First we must enable functionality for Userspace Files Systems which are supported in Linux through the FUSE project.

For Kernels >= 2.6.14, you should enable kernel support by adding the fuse.ko module. For earlier kernels, FUSE will build the appropriate kernel module for you.

In your kernel config menu, find the following option and enable it as a module.
FileSystems->
<M>Filesystem in Userspace support

then compile and install the module with:
Code:
make modules && make modules_install
See the Kernel-HOWTO.html for more information on compiling the Linux kernel.


We will next need to download the FUSE tarball from:
http://fuse.sourceforge.net/
and extract with
Code:
tar -vxf fuse-2.5.3.tar.gz
Then build with
Code:
./configure --prefix=/usr 
make
make install
note: Make sure the --prefix points to where all your system libraries will be installed. Also, './configure' will not build the kernel module if it all ready detected on your system. Make sure it detects/does not detect, correctly.

Once FUSE is installed correctly run:
Code:
modprobe fuse 
ldconfig
ldconfig might be needed to update the library linker.


2.2 Install Python FUSE Bindings

You will need to install the Python FUSE bindings to get the Python FUSE libraries.

To download the correct bindings, issue the following commands in the directory you want to download them to.
Code:
cvs -d:pserver:anonymous@fuse.cvs.sourceforge.net:/cvsroot/fuse login
cvs -z3 -d:pserver:anonymous@fuse.cvs.sourceforge.net:/cvsroot/fuse co -P python
Just hit 'enter' at the password prompt.

Then from the root of the directory you just checked out from CVS:
Code:
python setup.py build
python setup.py install
Make sure to take note of where the install routine copied the build files. It will display at the end of the output from install. On my system it installed to '/usr/lib/python2.4/site-packages/' This is a shared directory python uses for libraries and dependencies.


2.3 Install LibGMail

Now to install LibGMail which is a library for reading/writing GMail messages and handles the connection process. You can download from:
http://sourceforge.net/projects/libgmail
and then extract with the same method as above. Once extracted, cd to the extracted directory and copy lgconstants.py & libgmail.py to same directory the FUSE python bindings were installed to earlier.
Code:
cp lgconstants.py /usr/lib/python2.4/site-packages/
cp libgmail.py /usr/lib/python2.4/site-packages/

2.4 Install GMailFS

Now for the meat and potatoes. Download GMailFS from:
http://richard.jones.name/google-hac...ilesystem.html
and extract as before. Cd to the extracted directory and copy the following files to their correct location:
Code:
cp gmailfs.py /usr/bin/
cp mount.gmailfs /sbin/
cp gmailfs.conf /etc/

Assuming everything installed correctly, we should now be ready to use our GMail account as a Linux file system.



3.0 Using Your GMail File System


3.1 Configure GMailFS

First thing we should do is open the /etc/gmail.conf file in a text editor and update the following lines.
Code:
username=yourusername
password=yourpassword
fsname=yourfsname
The fsname should be equally complex and secretive as your password. If someone were to guess your file system name, they could interject files into your file system by sending you malicious emails.

Once you are done updating gmail.conf, restrict access so only root can read or write:
Code:
chmod 600 /etc/gmail.conf
This prevents other users from reading your GMail password!


3.2 Mount GMail file system

First we need to create a mount point for the GMail file system and allow access for any non-root users we would like to use it.
Code:
mkdir /mnt/gmail
chown yourusername.yourgroup /mnt/gmail
note: For security reasons, GMailFS will only allow users to mount to directories owned by them.

Now for the mounting. Update your /etc/fstab file with a text editor and add the line:
Code:
/usr/bin/gmailfs.py  /mnt/gmail  gmailfs  noauto  0  0
you can then mount the GMail file system as with
Code:
mount /mnt/gmail
You can also mount it manually with:
Code:
mount -t gmailfs /usr/bin/gmailfs.py <mount point> -o username=yourusername,password=yourpassword,fsname=yourfsname


4.0 Fine Tuning


Here are some tips on fine tuning the GMail file system that are unnecessary but could be useful.

4.1 Auto Archive GMailFS Messages to Prevent Inbox Clutter

To do this, you will need to log into your GMail account and set up an appropriate filter. You can do this by going to settings->filters->create new filter then add in a filter that will archive everything containing this line in the subject:
Code:
q=__g__<fsname>__h__
I also added one to star every file that contains the previous subject line and has an attachment. This is usefull to me since I use my GMail File System to back up my school/work documents.


4.2 Modify GMailFS to Display True File Name for Email Attachment

Since I wanted to use this to back up my documents and get access to them when I am away from my computer, I was annoyed that GMailFS stored the file attachments by picking a random file name. After a little tinkering, I was able to get the attachment file names to more adequately represent the file.

note:The following instructions requires you to modify the python source code of gmailfs.py. I was able to get it to work (sort of) by reading the code and little trial and error. Use at your own risk.


From reading the source code, it appears that gmailfs.py creates a random file in the memory then copies the actual file to it, then adds the temp file as an attachment. The result is a randomly named file attachment which gives us no clue as to what the file actually is. After looking at tempfile.py in the python lib directory, it looks like you can pass a name to the function instead of using the default random one. Our goal is to change the gmailfs.py source to pass the desired name as a parameter to avoid a random name by default.

Here is what I changed in each method
note: changes are in bold
Code:
#/usr/bin/gmailfs.py

def close(self, path):
...
if self.needsWriting:
      self.commitToGmail(path)
...


def write(self, path, buf, off):
...
if self.currentOffset == -1 or off<self.currentOffset or off>self.currentOffset:
      self.commitToGmail(path)
...
if self.currentOffset/self.blocksize>currentBlock:
       self.needsWriting = 1
        self.commitToGmail(path)
...


def commitToGmail(self, path):
...
ind = string.rindex(path,'/')
name = path[ind+1:]
tmpf = tempfile.NamedTemporaryFile('w+b',-1,"",name,None)
...


def write(self, path, buf, off):
...
written = f.write(path,buf,off)
...


def release(self, path, flags):
...
f.close(path)


def fsync(self, path, isfsyncfile)
...
f.commitToGmail(path)
...
The overall strategy here was to find out how the program new what the actual file name was then copy this code into the commitToGmail function, then use it as a parameter when it calls tempfile.NamedTemporaryFile(). Since it uses a variable by the name of 'path' to get the file name, we need to add that as a parameter to the commitToGmail() function, and any function that calls it.

FIXME: The file name to the attachment will display the correct file name + some random letters and #'s at the end. This was the best I could achieve with my lack of knowledge with python. Does anyone that actually knows python have any ideas on how to fix this?



5.0 Change Log


05/21/2006 - First Version, changes to come!
05/22/2006 - added python to system requirements
05/22/2006 - updated overview to give a description of the gmailfs structure
10/25/2006 - cleaned up. checked instructions to make sure they were not outdated.
--------------------------------------------------------

Last edited by drkstr; 10-25-2006 at 11:22 PM.
 
Old 05-22-2006, 12:01 AM   #2
craigevil
Senior Member
 
Registered: Apr 2005
Location: OZ
Distribution: Debian Sid/RPIOS
Posts: 4,883
Blog Entries: 28

Rep: Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533
I remember reading somewhere doing this violates the Gmail TOS, but I may be wrong.
 
Old 05-22-2006, 12:33 AM   #3
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Original Poster
Rep: Reputation: 45
Quote:
Originally quoted by: craigevil
I remember reading somewhere doing this violates the Gmail TOS, but I may be wrong.
I read the user agreement prior to posting this: http://www.google.com/mail/help/terms_of_use.html It does not apear to list it as a violation. Let me know if I overlooked anything but I think we're good to go as long as you do not house any illigal content in the file system.

regards,
...drkstr

Last edited by drkstr; 05-23-2006 at 01:16 AM.
 
Old 06-27-2006, 03:38 PM   #4
aroche
LQ Newbie
 
Registered: Apr 2006
Posts: 20

Rep: Reputation: 0
Smile help please !!!!!!!!

Hi

I was just wondering have you had experence in running gmailfs on mandrake 2006, I have followed ur document but am still unable to get it to mount gmail. I am using python 2.4 so I'm not sure if this is the correct version. I can post the errors from my computer if you have some time to take a look at them, I have searched google and came up with null. Compiling seems fine, So any help would be brill, pulling my hair out trying to get this to work.

Thanks

Al.
 
Old 06-27-2006, 05:10 PM   #5
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Original Poster
Rep: Reputation: 45
Welcome to LQ!

You need to provide a little bit more information if I am to help you. How far do you get before it stops working, and what kind of error messages do you get? Also, let me know if you did anything different then what is in the howto.

regards,
...aaron
 
Old 06-27-2006, 05:16 PM   #6
circuithead
LQ Newbie
 
Registered: Aug 2005
Posts: 15

Rep: Reputation: 0
wow thanks

i can think of the apps now

Very very sweet, i shall play and we shall see

will make an excellent backup and mirror for my development server
 
Old 06-27-2006, 05:41 PM   #7
powadha
Member
 
Registered: Nov 2003
Location: Zwolle
Distribution: Arch
Posts: 651

Rep: Reputation: 31
Or you can just save the trouble and install the Firefox extension https://addons.mozilla.org/firefox/1593/

I've played a bit with libgmail for fun a while back and found it very buggy and slow. Perhaps it has become better but well, too much work for very little gain. The extension installs in seconds and does the job.

Just for the fun of getting it to work this is a nice howto though.

Last edited by powadha; 06-27-2006 at 05:42 PM.
 
Old 06-28-2006, 03:08 AM   #8
aroche
LQ Newbie
 
Registered: Apr 2006
Posts: 20

Rep: Reputation: 0
gmailfs

Hi Aaron

Ok so i followed your doc and added in everything the same way you did but then when i go to mount the filesystem it throws back a load of "code/crap " see below. I have tried different version of the mount.gmailfs and got different errors i can also post them up but bassically it was giving out about not enough arguments given and "username" is not a valid argument stuff like that, i will post them up in 20 min if thats any help.


Thanks again for the help on this one

Regards

Al.

command im running:

mount -t gmailfs /usr/bin/gmailfs.py /home/alan/gmail -o username=gmailaccount,password=passwd,fsname=12344

Ignored option :rw
Ignored option :0
Traceback (most recent call last):
File "/sbin/mount.gmailfs", line 164, in ?
main(mountpoint, namedOptions, useEncfs)
File "/sbin/mount.gmailfs", line 90, in main
gmailfs.main(mountpoint, namedOptions)
File "/usr/bin/gmailfs.py", line 1130, in main
server = Gmailfs(mountpoint, **namedOptions)
File "/usr/bin/gmailfs.py", line 542, in __init__
Fuse.__init__(self, mountpoint, **kw)
File "/usr/lib/python2.4/site-packages/fuse.py", line 559, in __init__
self.parser = parserclass(*args, **kw)
File "/usr/lib/python2.4/site-packages/fuse.py", line 223, in __init__
SubbedOptParse.__init__(self, *args, **kw)
File "/usr/lib/python2.4/site-packages/fuseparts/subbedopts.py", line 239, in __init__
OptionParser.__init__(self, *args, **kw)
TypeError: __init__() got multiple values for keyword argument 'usage'
 
Old 06-28-2006, 05:22 AM   #9
aroche
LQ Newbie
 
Registered: Apr 2006
Posts: 20

Rep: Reputation: 0
gmailfs

And here is the other message again, tryied to recompile the fuse.py but still get the same errors...


mount -t gmailfs /usr/bin/gmailfs.py /home/alan/gmail -o username=gmailaccount,password=passwd,fsname=12


Ignored option :rw
Traceback (most recent call last):
File "/sbin/mount.gmailfs", line 164, in ?
main(mountpoint, namedOptions, useEncfs)
File "/sbin/mount.gmailfs", line 90, in main
gmailfs.main(mountpoint, namedOptions)
File "/usr/bin/gmailfs.py", line 1130, in main
server = Gmailfs(mountpoint, **namedOptions)
File "/usr/bin/gmailfs.py", line 542, in __init__
Fuse.__init__(self, mountpoint, **kw)
File "/usr/lib/python2.4/site-packages/fuse.py", line 559, in __init__
self.parser = parserclass(*args, **kw)
File "/usr/lib/python2.4/site-packages/fuse.py", line 223, in __init__
SubbedOptParse.__init__(self, *args, **kw)
File "/usr/lib/python2.4/site-packages/fuseparts/subbedopts.py", line 239, in __init__
OptionParser.__init__(self, *args, **kw)
TypeError: __init__() got an unexpected keyword argument 'username'
 
Old 06-28-2006, 04:20 PM   #10
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Original Poster
Rep: Reputation: 45
Quote:
Ok so i followed your doc and added in everything the same way you did but then when i go to mount the filesystem it throws back a load of "code/crap " see below. I have tried different version of the mount.gmailfs and got different errors i can also post them up but bassically it was giving out about not enough arguments given and "username" is not a valid argument stuff like that, i will post them up in 20 min if thats any help.


Thanks again for the help on this one

Regards

Al.

command im running:

mount -t gmailfs /usr/bin/gmailfs.py /home/alan/gmail -o username=gmailaccount,password=passwd,fsname=12344
Are you typing this directly as quoted? this command is supposed to be one line. Try it like this:
Code:
mount -t gmailfs /usr/bin/gmailfs.py /home/alan/gmail \
-o username=gmailaccount,password=passwd,fsname=12344
Or try mounting it using the fstab. If it works with the fstab then that will tell if there is a problem with the command or not.

regards,
...aaron
 
Old 06-29-2006, 05:51 AM   #11
aroche
LQ Newbie
 
Registered: Apr 2006
Posts: 20

Rep: Reputation: 0
gmailfs

Hi Aaron

yep tried that and still no joy, also built Fedora core 5 on a test machine and having the same problems.

The error is still the same no matter what way i try it, do you think it could be something to do with python 2.4 ?

is this possible that its messing up everything?

also which version of linux did you get it working ? i can download that and see why it works on that and not on mandrake.

Al.
 
Old 07-01-2006, 03:36 AM   #12
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Original Poster
Rep: Reputation: 45
Sorry it took me a while to get back to you, I have been out of town.

Please post the contents of your ~/gmailfs.log

Maybe this will give us a hint to the cause of the problem.

regards,
...aaron

**edit**
Have you messed around with section 4.2 in the HOWTO at all? If so, I would start over with the clean source and make sure it's working before modifying it.

Also, I forgot to answer some of your questions. I am using Slackware 10.2 with Python 2.4.1. Neither of these things should be causing the problem though.

Last edited by drkstr; 07-01-2006 at 04:34 AM.
 
Old 07-01-2006, 04:31 AM   #13
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Original Poster
Rep: Reputation: 45
Quote:
Originally Posted by powadha
I've played a bit with libgmail for fun a while back and found it very buggy and slow. Perhaps it has become better but well, too much work for very little gain. The extension installs in seconds and does the job.

Just for the fun of getting it to work this is a nice howto though.
Yeah, I made sure to say that this is just for fun in the intro. I just thought it was interesting so I decided to write something out on it real quick. I like using it as a quick and easy method to transfer files to any computer that has a web browser, but this is pretty much all it's good for.

Thanks for the input!
...aaron
 
Old 07-03-2006, 12:54 PM   #14
aroche
LQ Newbie
 
Registered: Apr 2006
Posts: 20

Rep: Reputation: 0
Gmailfs

Hi Aaron

Sorry for the delay i wasnt able to log in to my computer from home on saturday but i do have the logs now.


Thanks

al.



330 06/28/06 09:09:26 INFO Starting gmailfs in child process (PID 30792)
331 06/28/06 09:09:26 INFO waiting for /home/alan/gmail to become a mountpoint
332 06/28/06 09:09:27 ERROR gmailfs child died, exiting...
333 06/28/06 11:21:37 ERROR OpenSSLProxy is missing. Can't use HTTPS proxy!
334 06/28/06 11:21:37 INFO Starting gmailfs in child process (PID 2568)
335 06/28/06 11:21:37 INFO waiting for /home/alan/gmail to become a mountpoint
336 06/28/06 11:21:38 ERROR gmailfs child died, exiting...
337 06/28/06 11:21:45 ERROR OpenSSLProxy is missing. Can't use HTTPS proxy!
338 06/28/06 11:21:45 INFO Starting gmailfs in child process (PID 2577)
339 06/28/06 11:21:45 INFO waiting for /home/alan/gmail to become a mountpoint
340 06/28/06 11:21:46 ERROR gmailfs child died, exiting...
341 06/28/06 11:21:50 ERROR OpenSSLProxy is missing. Can't use HTTPS proxy!
342 06/28/06 11:21:50 INFO Starting gmailfs in child process (PID 2582)
343 06/28/06 11:21:50 INFO waiting for /home/alan/gmail to become a mountpoint
344 06/28/06 11:21:51 ERROR gmailfs child died, exiting...
345 06/28/06 11:21:59 ERROR OpenSSLProxy is missing. Can't use HTTPS proxy!
346 06/28/06 11:21:59 INFO waiting for /home/alan/gmail to become a mountpoint
347 06/28/06 11:21:59 INFO Starting gmailfs in child process (PID 2589)
348 06/28/06 11:22:00 ERROR gmailfs child died, exiting...
349 06/28/06 11:25:01 ERROR OpenSSLProxy is missing. Can't use HTTPS proxy!
350 06/28/06 11:25:01 INFO Starting gmailfs in child process (PID 2695)
351 06/28/06 11:25:01 INFO waiting for /home/alan/gmail to become a mountpoint
352 06/28/06 11:25:02 ERROR gmailfs child died, exiting...
353 06/28/06 11:25:08 ERROR OpenSSLProxy is missing. Can't use HTTPS proxy!
354 06/28/06 11:25:08 INFO waiting for /home/alan/gmail to become a mountpoint
355 06/28/06 11:25:08 INFO Starting gmailfs in child process (PID 2702)
356 06/28/06 11:25:09 ERROR gmailfs child died, exiting...
357 06/28/06 11:25:12 ERROR OpenSSLProxy is missing. Can't use HTTPS proxy!
358 06/28/06 11:25:12 INFO Starting gmailfs in child process (PID 2707)
359 06/28/06 11:25:12 INFO waiting for /home/alan/gmail to become a mountpoint
360 06/28/06 11:25:13 ERROR gmailfs child died, exiting...
361 06/28/06 11:26:09 ERROR OpenSSLProxy is missing. Can't use HTTPS proxy!
362 06/28/06 11:26:09 INFO Starting gmailfs in child process (PID 2750)
363 06/28/06 11:26:09 INFO waiting for /home/alan/gmail to become a mountpoint
364 06/28/06 11:26:10 ERROR gmailfs child died, exiting...
365 06/29/06 09:59:18 ERROR OpenSSLProxy is missing. Can't use HTTPS proxy!
366 06/29/06 09:59:18 INFO Starting gmailfs in child process (PID 17340)
367 06/29/06 09:59:18 INFO waiting for /home/alan/gmail to become a mountpoint
368 06/29/06 09:59:19 ERROR gmailfs child died, exiting...
369 06/29/06 09:59:23 ERROR OpenSSLProxy is missing. Can't use HTTPS proxy!
370 06/29/06 09:59:23 INFO Starting gmailfs in child process (PID 17346)
371 06/29/06 09:59:23 INFO waiting for /home/alan/gmail to become a mountpoint
372 06/29/06 09:59:24 ERROR gmailfs child died, exiting...
373 06/29/06 11:55:25 ERROR OpenSSLProxy is missing. Can't use HTTPS proxy!
374 06/29/06 11:55:25 INFO Starting gmailfs in child process (PID 20993)
375 06/29/06 11:55:25 INFO waiting for /home/alan/gmail to become a mountpoint
376 06/29/06 11:55:26 ERROR gmailfs child died, exiting...
377 06/29/06 11:55:36 ERROR OpenSSLProxy is missing. Can't use HTTPS proxy!
378 06/29/06 11:55:36 INFO waiting for /home/alan/gmail to become a mountpoint
379 06/29/06 11:55:36 INFO Starting gmailfs in child process (PID 21003)
380 06/29/06 11:55:37 ERROR gmailfs child died, exiting...
 
Old 07-03-2006, 01:14 PM   #15
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Original Poster
Rep: Reputation: 45
Try installing (or upgrading) the SSL package for your distro and see if this helps. I am supprised you don't have it already however. This is a pretty common thing to have. If you have installed the latest version of SSL on your computer and still get this error, GmailFS might be looking for it in the wrong place. A simlink should get around this quite nicely.

regards,
...aaron
 
  


Reply

Tags
gmail, howto



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot access my gmail account in Mepis Charos MEPIS 7 07-28-2005 12:52 AM
Mount Gmail-like account as drive snutz411 Linux - Networking 41 06-05-2005 12:08 AM
ANYBODY WANT A GMAIL Account jon2kx General 9 08-17-2004 05:39 AM
I want a GMail account! jrbush82 General 1 08-06-2004 08:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration