3
# ecryptapi.py, Copyright 2008 Mike Rooney (https://launchpad.net/~mrooney)
7
# This is a graphical GTK utility to manage an encrypted ~/Private
8
# directory, allowing the user to mount and unmount, as well as enable
9
# auto-mounting at login.
11
# This program is free software: you can redistribute it and/or modify
12
# it under the terms of the GNU General Public License as published by
13
# the Free Software Foundation, either version 3 of the License, or
14
# (at your option) any later version.
16
# This program is distributed in the hope that it will be useful,
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
# GNU General Public License for more details.
21
# You should have received a copy of the GNU General Public License
22
# along with this program. If not, see <http://www.gnu.org/licenses/>.
26
AUTOMOUNT_FILE = os.path.expanduser("~/.ecryptfs/auto-mount")
27
AUTOUMOUNT_FILE = os.path.expanduser("~/.ecryptfs/auto-umount")
28
PRIVATE_LOCATION_FILE = os.path.expanduser("~/.ecryptfs/Private.mnt")
29
PRIVATE_LOCATION = os.path.exists(PRIVATE_LOCATION_FILE) and open(PRIVATE_LOCATION_FILE).read().strip()
31
def setAutoMount(doAuto):
32
"""Enable or disable automounting for this user."""
34
command = "touch %s" % AUTOMOUNT_FILE
35
#open(AUTOMOUNT_FILE, "w")
37
command = "rm %s" % AUTOMOUNT_FILE
38
#os.remove(AUTOMOUNT_FILE)
40
return commands.getstatusoutput(command)
43
"""Return whether or not automounting is enabled for this user."""
44
return os.path.exists(AUTOMOUNT_FILE)
46
def setAutoUnmount(doAuto):
47
"""Enable or disable automounting for this user."""
49
command = "touch %s" % AUTOUMOUNT_FILE
51
command = "rm %s" % AUTOUMOUNT_FILE
53
return commands.getstatusoutput(command)
56
"""Return whether or not automounting is enabled for this user."""
57
return os.path.exists(AUTOUMOUNT_FILE)
59
def setMounted(doMount):
60
"""Set the mounted (unencrypted) state of ~/Private."""
62
command = "mount.ecryptfs_private"
64
command = "umount.ecryptfs_private"
66
return commands.getstatusoutput(command)
69
"""Return whether or not ~/Private is mounted (unencrypted)."""
71
mounts = open("/proc/mounts").read()
72
return PRIVATE_LOCATION in mounts
77
encryptedHome = False #TODO: implement
78
encryptedPrivate = PRIVATE_LOCATION
79
return not (encryptedHome or encryptedPrivate)