Merged display.dll into USER.
[wine.git] / documentation / linux-fat-permissions
blob146ade7cf233920534380245c675403d21f9dc36
1 This document describes how FAT and VFAT file system permissions work
2 in Linux with a focus on configuring them for Wine.
4 Introduction
5 ------------
6 Linux is able to access DOS and Windows file systems using either the
7 FAT (older 8.3 DOS filesystems) or VFAT (newer Windows 95 or later
8 long filename filesystems) modules.  Mounted FAT or VFAT filesystems
9 provide the primary means for which existing applications and their
10 data are accessed through Wine for dual boot (Linux + Windows)
11 systems.
13 Wine maps mounted FAT filesystems, such as "/c", to driver letters,
14 such as "c:", as indicated by the wine.conf file.  The following
15 excerpt from a wine.conf file does this:
16     [Drive C]
17     Path=/c
18     Type=hd
20 Although VFAT filesystems are preferable to FAT filesystems for their
21 long filename support the term "FAT" will be used throughout the
22 remainder of this document to refer to FAT filesystems and their
23 derivatives.  Also, "/c" will be used as the FAT mount point in
24 examples throughout this document.
26 Most modern Linux distributions either detect or allow existing FAT
27 file systems to be configured so that can be mounted, in a location
28 such as /c, either persistently (on bootup) or on an as needed basis.
29 In either case, by default, the permissions will probably be configured
30 so that they look something like:
31     ~>cd /c
32     /c>ls -l
33     -rwxr-xr-x   1 root     root           91 Oct 10 17:58 autoexec.bat
34     -rwxr-xr-x   1 root     root          245 Oct 10 17:58 config.sys
35     drwxr-xr-x  41 root     root        16384 Dec 30  1998 windows
36 where all the files are owned by "root", are in the "root" group and
37 are only writable by "root" (755 permissions).  This is restrictive in
38 that it requires that Wine be run as root in order for applications to
39 be able to write to any part of the filesystem.
41 There three major approaches to overcoming the restrictive permissions
42 mentioned in the previous paragraph:
43     1) Run Wine as root
44     2) Mount the FAT filesystem with less restrictive permissions
45     3) Shadow the FAT filesystem by completely or partially copying it
46 Each approach will be discusses in the following "Running Wine as
47 root", "Mounting FAT filesystems" and "Shadowing FAT filesystems"
48 sections.
50 Running Wine as root
51 --------------------
52 Running Wine as root is the easiest and most thorough way of giving
53 applications that Wine runs unrestricted access to FAT files systems.
54 Running wine as root also allows applications to do things unrelated
55 to FAT filesystems, such as listening to ports that are less than
56 1024.  Running Wine as root is dangerous since there is no limit to
57 what the application can do to the system.
59 Mounting FAT filesystems
60 ------------------------
61 The FAT filesystem can be mounted with permissions less restrictive
62 than the default.  This can be done by either changing the user that
63 mounts the FAT filesystem or by explicitly changing the permissions
64 that the FAT filesystem is mounted with.  The permissions are
65 inherited from the process that mounts the FAT filesystem.  Since the
66 process that mounts the FAT filesystem is usually a startup script
67 running as root the FAT filesystem inherits root's permissions.  This
68 results in the files on the FAT filesystem having permissions similar
69 to files created by root.  For example:
70     ~>whoami
71     root
72     ~>touch root_file
73     ~>ls -l root_file
74     -rw-r--r--   1 root     root            0 Dec 10 00:20 root_file
76 which matches the owner, group and permissions of files seen on the
77 FAT filesystem except for the missing 'x's.  The permissions on the
78 FAT filesystem can be changed by changing root's umask (unset
79 permissions bits).  For example:
80     ~>umount /c
81     ~>umask
82     022
83     ~>umask 073
84     ~>mount /c
85     ~>cd /c
86     /c>ls -l
87     -rwx---r--   1 root     root           91 Oct 10 17:58 autoexec.bat
88     -rwx---r--   1 root     root          245 Oct 10 17:58 config.sys
89     drwx---r--  41 root     root        16384 Dec 30  1998 windows
90 Mounting the FAT filesystem with a umask of 000 gives all users
91 complete control over the it.
92 Explicitly specifying the permissions of the FAT filesystem when it is
93 mounted provides additional control.  There are three mount options
94 that are relevant to FAT permissions: "uid", "gid" and "umask".  They
95 can each be specified when the filesystem is manually mounted.  For
96 example:
97     ~>umount /c
98     ~>mount -o uid=500 -o gid=500 -o umask=002 /c
99     ~>cd /c
100     /c>ls -l
101     -rwxrwxr-x   1 sle      sle            91 Oct 10 17:58 autoexec.bat
102     -rwxrwxr-x   1 sle      sle           245 Oct 10 17:58 config.sys
103     drwxrwxr-x  41 sle      sle         16384 Dec 30  1998 windows
104 which gives "sle" complete control over /c.  The options listed above
105 can be made permanent by adding them to the /etc/fstab file:
106     ~>grep /c /etc/fstab
107     /dev/hda1  /c  vfat  uid=500,gid=500,umask=002,exec,dev,suid,rw 1 1
108 Note that the umask of 002 is common in the user private group file
109 permission scheme.  On FAT file systems this umask assures that all
110 files are fully accessible by all users in the specified group (gid).
112 Shadowing FAT filesystems
113 -------------------------
114 Shadowing provides a finer granularity of control.  Parts of the
115 original FAT filesystem can be copied so that the application can
116 safely work with those copied parts while the application continue to
117 directly read the remaining parts.  This is done with symbolic links.
118 For example, consider a system where an application named "AnApp" must
119 be able to read and write to the c:\windows and c:\AnApp directories
120 as well as have read access to the entire FAT filesystem.  On this
121 system the FAT filesystem has default permissions which should not be
122 changed for security reasons or can not be changed due to lack of root
123 access.  On this system a shadow directory might be set up in the
124 following manner:
125     ~>cd /
126     />mkdir c_shadow
127     />cd c_shadow
128     /c_shadow>ln -s /c_/* .
129     /c_shadow>rm windows AnApp
130     /c_shadow>cp -R /c_/{windows,AnApp} .
131     /c_shadow>chmod -R 777 windows AnApp
132     /c_shadow>perl -p -i -e 's|/c$|/c_shadow|g' /usr/local/etc/wine.conf
133 The above gives everyone complete read and write access to the
134 "windows" and "AnApp" directories while only root has write access to
135 all other directories.
137 Steven Elliott (elliotsl@mindspring.com)