Menu

[r5782]: / trunk / gui / sharing / models.py  Maximize  Restore  History

Download this file

266 lines (255 with data), 13.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#+
# Copyright 2010 iXsystems
# All rights reserved
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted providing that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# $FreeBSD$
#####################################################################
from django.db import models
from django import forms
from django.contrib.auth.models import User
import datetime
import time
from os import popen
from django.utils.text import capfirst
from django.forms.widgets import RadioFieldRenderer
from django.utils.safestring import mark_safe
from django.utils.encoding import force_unicode
from django.utils.translation import ugettext_lazy as _
from datetime import datetime
from storage.models import MountPoint as MountPoint
from freenasUI.choices import *
from freeadmin.models import Model
mountpoint_limiter = { 'mp_path__startswith': '/mnt/' }
class CIFS_Share(Model):
cifs_name = models.CharField(
max_length=120,
verbose_name="Name"
)
cifs_comment = models.CharField(
max_length=120,
verbose_name="Comment",
blank=True,
)
cifs_path = models.ForeignKey(MountPoint, limit_choices_to=mountpoint_limiter,
verbose_name="Path")
cifs_ro = models.BooleanField(
verbose_name="Export Read Only")
cifs_browsable = models.BooleanField(
verbose_name="Browsable to Network Clients", default=True)
cifs_inheritperms = models.BooleanField(
verbose_name="Inherit Permissions")
cifs_recyclebin = models.BooleanField(
verbose_name="Export Recycle Bin")
cifs_showhiddenfiles = models.BooleanField(
verbose_name="Show Hidden Files")
cifs_guest = models.CharField(
max_length=120,
choices=whoChoices(),
default="www",
verbose_name="Guest account",
help_text="Use this option to override the username ('ftp' by default) which will be used for access to services which are specified as guest. Whatever privileges this user has will be available to any client connecting to the guest service. This user must exist in the password file, but does not require a valid login."
)
cifs_guestok = models.BooleanField(
verbose_name="Allow guest access")
cifs_guestonly = models.BooleanField(
verbose_name="Only allow guest access")
cifs_hostsallow = models.CharField(
max_length=120,
blank=True,
verbose_name="Hosts allow",
help_text="This option is a comma, space, or tab delimited set of hosts which are permitted to access this share. You can specify the hosts by name or IP number. Leave this field empty to use default settings."
)
cifs_hostsdeny = models.CharField(
max_length=120,
blank=True,
verbose_name="Hosts deny",
help_text="This option is a comma, space, or tab delimited set of host which are NOT permitted to access this share. Where the lists conflict, the allow list takes precedence. In the event that it is necessary to deny all by default, use the keyword ALL (or the netmask 0.0.0.0/0) and then explicitly specify to the hosts allow parameter those hosts that should be permitted access. Leave this field empty to use default settings."
)
cifs_auxsmbconf = models.TextField(
max_length=120,
verbose_name="Auxiliary paramters",
blank=True,
help_text="These parameters are added to [Share] section of smb.conf"
)
def __unicode__(self):
return self.cifs_name
class Meta:
verbose_name = "Windows Share"
class FreeAdmin:
icon_model = u"WindowsShareIcon"
icon_add = u"AddWindowsShareIcon"
icon_view = u"ViewAllWindowsSharesIcon"
icon_object = u"WindowsShareIcon"
class AFP_Share(Model):
afp_name = models.CharField(
max_length=120,
verbose_name="Name",
help_text="The volume name is the name that appears in the Chooser ot the 'connect to server' dialog on Macintoshes to represent the appropriate share. If volumename is unspecified, the last component of pathname is used. No two volumes may have the same name. The volume name cannot contain the ':' character. The volume name is mangled if it is very long. Mac codepage volume name is limited to 27 characters. UTF8-MAC volume name is limited to 'Volume Name Length' parameter in Services:Apple Share"
)
afp_comment = models.CharField(
max_length=120,
verbose_name="Share Comment",
blank=True
)
afp_path = models.ForeignKey(MountPoint, limit_choices_to=mountpoint_limiter, verbose_name="Volume Path")
afp_sharepw = models.CharField(
max_length=120,
verbose_name="Share password",
blank=True,
help_text="This option allows you to set a volume password, which can be a maximum of 8 characters long (using ASCII strongly recommended at the time of this writing)."
)
afp_sharecharset = models.CharField(
max_length=120,
verbose_name="Share character set",
blank=True,
help_text="Specifies the share character set. For example UTF8, UTF8-MAC, ISO-8859-15, etc."
)
afp_allow = models.CharField(
max_length=120,
verbose_name="Allow List",
blank=True,
help_text="This option allows the users and groups that access a share to be specified. Users and groups are specified, delimited by commas. Groups are designated by a @ prefix."
)
afp_deny = models.CharField(
max_length=120,
verbose_name="Deny List",
blank=True,
help_text="The deny option specifies users and groups who are not allowed access to the share. It follows the same format as the allow option."
)
afp_ro = models.CharField(
max_length=120,
verbose_name="Read-only access",
blank=True,
help_text="Allows certain users and groups to have read-only access to a share. This follows the allow option format."
)
afp_rw = models.CharField(
max_length=120,
verbose_name="Read-write access",
blank=True,
help_text="Allows certain users and groups to have read/write access to a share. This follows the allow option format. "
)
afp_diskdiscovery = models.BooleanField(
verbose_name="Disk Discovery",
help_text="Allow other systems to discover this share as a disk for data, as a Time Machine backup volume or not at all."
)
afp_discoverymode = models.CharField(
max_length=120,
choices=DISKDISCOVERY_CHOICES,
default='Default',
verbose_name="Disk discovery mode",
help_text="Note! Selecting 'Time Machine' on multiple shares will may cause unpredictable behavior in MacOS. Default mode exports the volume as a data volume for users."
)
afp_dbpath = models.CharField(
max_length=120,
verbose_name="Database Path",
blank=True,
help_text="Sets the database information to be stored in path. You have to specifiy a writable location, even if the volume is read only."
)
afp_cachecnid = models.BooleanField(
verbose_name="Cache CNID",
help_text="If set afpd uses the ID information stored in AppleDouble V2 header files to reduce database load. Don't set this option if the volume is modified by non AFP clients (NFS/SMB/local)."
)
afp_crlf = models.BooleanField(
verbose_name="Translate CR/LF",
help_text="Enables crlf translation for TEXT files, automatically converting macintosh line breaks into Unix ones. Use of this option might be dangerous since some older programs store binary data files as type 'TEXT' when saving and switch the filetype in a second step. Afpd will potentially destroy such files when 'erroneously' changing bytes in order to do line break translation."
)
afp_mswindows = models.BooleanField(
verbose_name="Windows File Names",
help_text="This forces filenames to be restricted to the character set used by Windows. This is not recommended for shares used principally by Mac computers."
)
afp_noadouble = models.BooleanField(
verbose_name="No .AppleDouble",
help_text="This controls whether the .AppleDouble directory gets created unless absolutely needed. This option should not be used if files are access mostly by Mac computers. Clicking this option disables their creation."
)
afp_nodev = models.BooleanField(
verbose_name="Zero Device Numbers",
help_text="Always use 0 for device number, helps when the device number is not constant across a reboot, cluster, ..."
)
afp_nofileid = models.BooleanField(
verbose_name="Disable File ID",
help_text="Don't advertise createfileid, resolveid, deleteid calls."
)
afp_nohex = models.BooleanField(
verbose_name="Disable :hex Names",
help_text="Disable :hex translations for anything except dot files. This option makes the '/' character illegal."
)
afp_prodos = models.BooleanField(
verbose_name="ProDOS",
help_text="Provide compatibility with Apple II clients."
)
afp_nostat = models.BooleanField(
verbose_name="No Stat",
help_text="Don't stat volume path when enumerating volumes list, useful for automounting or volumes created by a preexec script."
)
afp_upriv = models.BooleanField(
verbose_name="AFP3 Unix Privs",
help_text="Use AFP3 unix privileges."
)
def __unicode__(self):
return unicode(self.afp_path)
class Meta:
verbose_name = "Apple Share"
class FreeAdmin:
icon_model = u"AppleShareIcon"
icon_add = u"AddAppleShareIcon"
icon_view = u"ViewAllAppleSharesIcon"
icon_object = u"AppleShareIcon"
class NFS_Share(Model):
nfs_comment = models.CharField(
max_length=120,
verbose_name="Comment",
blank=True,
)
nfs_path = models.ForeignKey(MountPoint, limit_choices_to=mountpoint_limiter, verbose_name="Volume Path")
nfs_allroot = models.BooleanField(
verbose_name="Map All Remote users as local Root",
help_text="When enabled, map all remote access to local root. THIS SETTING IS NOT RECOMMENDED FOR SECURITY REASONS."
)
nfs_network = models.CharField(
max_length=120,
verbose_name="Authorized network",
help_text="Network that is authorized to access the NFS share. Specify network numbers of the form 1.2.3.4/xx where xx is the number of bits of netmask.",
blank=True,
)
nfs_alldirs = models.BooleanField(
verbose_name="All dirs",
help_text="Allow mounting of any subdirectory under this mount point if selected. Otherwise, only the top level directory can be mounted.",
)
nfs_ro = models.BooleanField(
verbose_name="Read Only",
help_text="Export the share read only. Writes are not permitted."
)
nfs_quiet = models.BooleanField(
verbose_name="Quiet",
help_text="Inibit syslog warnings if there are problems with exporting this share."
)
def __unicode__(self):
return unicode(self.nfs_path)
class Meta:
verbose_name = "UNIX Share"
class FreeAdmin:
icon_model = u"UNIXShareIcon"
icon_add = u"AddUNIXShareIcon"
icon_view = u"ViewAllUNIXSharesIcon"
icon_object = u"UNIXShareIcon"
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.