Merge lp:~mrooney/ecryptfs/pythonapi into lp:~ecryptfs/ecryptfs/ecryptfs-utils

Proposed by Michael Rooney
Status: Merged
Merged at revision: not available
Proposed branch: lp:~mrooney/ecryptfs/pythonapi
Merge into: lp:~ecryptfs/ecryptfs/ecryptfs-utils
Diff against target: None lines
To merge this branch: bzr merge lp:~mrooney/ecryptfs/pythonapi
Reviewer Review Type Date Requested Status
Dustin Kirkland  Approve
Review via email: mp+6858@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michael Rooney (mrooney) wrote :

Dustin, this is the API branch and is ready to go. I created a new python/ directory in src/ which the UI utilities assume is shipped as a dist/site package of python named "ecryptfs" (for example as /usr/lib/python2.6/dist-packages/ecryptfs/)

The two things to resolve before packaging are:
 - should it be somewhere different in the ecryptfs source?
 - I'm expecting an 'ecryptfs' module to be added to dist-packages but 'ecryptfs-utils' already exists for the swig wrappers. They should perhaps be unified, and you can't import something with a dash in the name in python anyway so the existing module is suboptimal. If it isn't too invasive we might want to move the three methods (ecryptfs_passphrase_blob, ecryptfs_passphrase_sig_from_blob, ecryptfs_add_blob_to_keyring) to ecryptapi.py and adjust any references.

Revision history for this message
Michael Rooney (mrooney) wrote :

Hi Dustin, I just wanted to ping you on this to see if you had any updates. Probably it is fine to have these two different python folders, one for the swig wrappers and one for native python which exists currently. This way it could be merged as-is.

This merge is blocking the nautilus integration merge which would be pretty awesome to have for Karmic and is coming along nicely.

Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Approved, merged. One (minor?) change... I renamed ecryptapi.py to ecryptfsapi.py.

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'src/python'
2=== added file 'src/python/__init__.py'
3=== added file 'src/python/ecryptapi.py'
4--- src/python/ecryptapi.py 1970-01-01 00:00:00 +0000
5+++ src/python/ecryptapi.py 2009-05-28 13:27:44 +0000
6@@ -0,0 +1,82 @@
7+#!/usr/bin/env python
8+#
9+# ecryptapi.py, Copyright 2008, 2009 Michael Rooney <mrooney@ubuntu.com>
10+# Date: 2009-05-28
11+# Version: 0.4
12+#
13+# This is a python API for interacting with ecryptfs-utils and its
14+# encrypted directories.
15+#
16+# This program is free software: you can redistribute it and/or modify
17+# it under the terms of the GNU General Public License as published by
18+# the Free Software Foundation, either version 3 of the License, or
19+# (at your option) any later version.
20+#
21+# This program is distributed in the hope that it will be useful,
22+# but WITHOUT ANY WARRANTY; without even the implied warranty of
23+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24+# GNU General Public License for more details.
25+#
26+# You should have received a copy of the GNU General Public License
27+# along with this program. If not, see <http://www.gnu.org/licenses/>.
28+
29+import commands, os
30+
31+AUTOMOUNT_FILE = os.path.expanduser("~/.ecryptfs/auto-mount")
32+AUTOUMOUNT_FILE = os.path.expanduser("~/.ecryptfs/auto-umount")
33+PRIVATE_LOCATION_FILE = os.path.expanduser("~/.ecryptfs/Private.mnt")
34+PRIVATE_LOCATION = os.path.exists(PRIVATE_LOCATION_FILE) and open(PRIVATE_LOCATION_FILE).read().strip()
35+
36+def set_automount(doAuto):
37+ """Enable or disable automounting for this user."""
38+ if doAuto:
39+ command = "touch %s" % AUTOMOUNT_FILE
40+ #open(AUTOMOUNT_FILE, "w")
41+ else:
42+ command = "rm %s" % AUTOMOUNT_FILE
43+ #os.remove(AUTOMOUNT_FILE)
44+
45+ return commands.getstatusoutput(command)
46+
47+def get_automount():
48+ """Return whether or not automounting is enabled for this user."""
49+ return os.path.exists(AUTOMOUNT_FILE)
50+
51+def set_autounmount(doAuto):
52+ """Enable or disable automounting for this user."""
53+ if doAuto:
54+ command = "touch %s" % AUTOUMOUNT_FILE
55+ else:
56+ command = "rm %s" % AUTOUMOUNT_FILE
57+
58+ return commands.getstatusoutput(command)
59+
60+def get_autounmount():
61+ """Return whether or not autounmounting is enabled for this user."""
62+ return os.path.exists(AUTOUMOUNT_FILE)
63+
64+def set_mounted(doMount):
65+ """Set the mounted (unencrypted) state of ~/Private."""
66+ if doMount:
67+ command = "mount.ecryptfs_private"
68+ else:
69+ command = "umount.ecryptfs_private"
70+
71+ return commands.getstatusoutput(command)
72+
73+def get_mounted():
74+ """Return whether or not ~/Private is mounted (unencrypted)."""
75+ if PRIVATE_LOCATION:
76+ mounts = open("/proc/mounts").read()
77+ return PRIVATE_LOCATION in mounts
78+ else:
79+ return False
80+
81+def needs_setup():
82+ """
83+ Return whether or not an encrypted directory has been set up by ecryptfs
84+ for this user, either Home or Private.
85+ """
86+ encryptedHome = False #TODO: implement
87+ encryptedPrivate = PRIVATE_LOCATION
88+ return not (encryptedHome or encryptedPrivate)

Subscribers

People subscribed via source and target branches